x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

CeGCC adventures

Moderators: C:Amie

Jump to page : 1
Now viewing page 1 [15 messages per page]

Karpour Page Icon Posted 2020-05-08 9:38 PM
#
Avatar image of Karpour
Subscribers
Factorite (Elite)

Posts:
232
Location:
Austria
Status:
Okay so.. I have no idea what I'm doing. I did a lot of C/C++ development in the past, but only for microcontroller firmware, so nothing where I ever touch the windows API
So.. after a quick Google search to figure out what the difference between gcc and mingw32 is, I got the cdmingw32 package from https://sourceforge.net/projects/cegcc/files/cegcc/0.59.1/mingw32ce-...

I use VS code for all my development work, but since I'm on windows, I simply used the remote development extension to fire up VS code inside the windows subsystem for linux, so I can develop inside linux on my windows machine.

Alright, so I just untar that file..
tar -xjvf mingw32ce-0.59.1.tar.bz2


Aaaand I hit my first roadblock.. While executing 32-bit binaries is no problem on 64 bit linux, WSL is all weird and doesn't support that, so CEGCC won't run there. Time for coming up with a plan B!



(1.png)



Attachments
----------------
Attachments 1.png (191KB - 0 downloads)
 Top of the page
Karpour Page Icon Posted 2020-05-08 10:02 PM
#
Avatar image of Karpour
Subscribers
Factorite (Elite)

Posts:
232
Location:
Austria
Status:
So I had this Ubuntu vServer I wasn't using much anyway, so I used the Remote SSH plugin for VS code, which works the same way as the WSL one, except it runs the VS code on a remote server rather than the linux container inside windows.

And GCC works! Next step: compiling something

In the end I hopefully have a CE dev setup with all the modern bells and whistles and autocomplete (that I can't live without)



(2.PNG)



Attachments
----------------
Attachments 2.PNG (156KB - 0 downloads)
 Top of the page
Karpour Page Icon Posted 2020-05-08 10:51 PM
#
Avatar image of Karpour
Subscribers
Factorite (Elite)

Posts:
232
Location:
Austria
Status:
Okay, it's alive!

I downloaded the sample project files from the CeGCC website: http://www.mit.edu/afs.new/sipb/user/geofft/opt/mingw32ce/share/doc...

set the path in ~/.bashrc
export PATH=/opt/mingw32ce/bin:$PATH
Installed build-essential because make wasn't installed
apt install build-essential
and tried to make the project.. For now I'm stuck here:
$ make menu-resource.exe 
arm-mingw32ce-gcc -g -D_WIN32_IE=0x0400 -c menu-resource.c 
/opt/mingw32ce/libexec/gcc/arm-mingw32ce/4.4.0/cc1: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory 
Makefile:11: recipe for target 'menu-resource.o' failed 
make: *** [menu-resource.o] Error 1
Not sure what libmpfr.so really is, but I'll try yo figure it out! (EDIT) There we go, https://www.mpfr.org/, let's try installing this and see if CeGCC is happy then! Okay, so libmpfr is installed, but a different version. Other people solved it by symlinking libmpfr.so.1 to that new version, not sure if that'll work, but let's try..
rroot@ohnitsch:/usr/lib/x86_64-linux-gnu# ll | grep libmpfr 
lrwxrwxrwx  2 root root       16 Feb  7  2018 libmpfr.so.6 -> libmpfr.so.6.0.1 
-rw-r--r--  1 root root   523280 Feb  7  2018 libmpfr.so.6.0.1 
root@ohnitsch:/usr/lib/x86_64-linux-gnu# ln -s libmpfr.so.6.0.1 libmpfr.so.1
No luck with that, to be honest I don't know how this really works, maybe because it's a 64-bit library and a 32-bit executable?
root@ohnitsch:/opt/mingw32ce/libexec/gcc/arm-mingw32ce/4.4.0# ldd ./cc1 
        linux-gate.so.1 (0xf7eeb000) 
        libmpfr.so.1 => not found 
        libgmp.so.3 => not found 
        libc.so.6 => /lib32/libc.so.6 (0xf7d01000) 
        /lib/ld-linux.so.2 (0xf7eed000)


Leaving this for now, trying more tomorrow, if anyone has ideas let me know

Edited by Karpour 2020-05-08 11:23 PM
 Top of the page
Karpour Page Icon Posted 2020-05-09 1:02 AM
#
Avatar image of Karpour
Subscribers
Factorite (Elite)

Posts:
232
Location:
Austria
Status:
Okay, after asking in a linux chat, this seems to be a dead end, i'll be unlikely to get this compiler working on modern 64-bit linux because of dependency issues.
A suggested solution was installing it inside a chroot with an old Debian install, which I have 0 experience with, but.. this might be a good time to learn about chroot
 Top of the page
ntware Page Icon Posted 2020-05-09 1:46 AM
#
Avatar image of ntware
Subscribers
H/PC Philosopher

Posts:
481
Location:
Florida, US
Status:
chroot (Change root) is dead simple. Basically what it does is setup a new root file system from a random directory that you select, and then jump to that. It is similar to a virtual machine, but instead uses the same kernel as the host machine. Check debootstrap, this is a script that makes it all for you. It downloads Debian from the web, places it in a folder, and then chroots into it. Chroot is very useful to run 32-bit stuff without creating a dependency hell in your environment. However, I would say that the safest approach 100% guaranteed is to actually run this thing on a VM. If you like to do things on the terminal, you can quickly setup an old 32-bit Debian or Ubuntu docker container.
 Top of the page
C:Amie Page Icon Posted 2020-05-09 9:32 AM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
15,378
Location:
United Kingdom
Status:
Karpour,


Is this viable to get code running on legacy H/PC's? Does it just target ARM or can it target SH3/MIPS too? If the answer is yes, what if we came up with a full guide solution for this? I am sure that others would be interested in a guide to setup VS Code on Windows and how to have it target. We could then create a Virtual Machine disk image (Hyper-V, VMWare, Virtual Box) with a pre-configured bare bones minimum 32-bit Debian install in it that people could download to target to perform the building.

We could record the instructions to install Debian for anyone who wants to roll their own.

I agree with ntware, if you're targeting a clean solution that you don't want to spend ages unpicking when you're done with the experiment, a VM is the cleanest and most portable/achievable solution.
 Top of the page
Karpour Page Icon Posted 2020-05-09 11:03 AM
#
Avatar image of Karpour
Subscribers
Factorite (Elite)

Posts:
232
Location:
Austria
Status:
ntware: Yeah, debootstrap is what I got recommended as well! I'll try around with that for now!

C:Amie: CeGCC only compiles for ARM, so you're stuck with CE3.0 and up.

In short, my motivation was to create a simple way to use VS code as essentially a Windows CE IDE.. Ideas I had so far:


  • Set up embedded Visual C++ in a VM, and somehow write scripts to copy source over, compile it and copy result back (very ugly solution)

  • Use WINE to run cl.exe, nmake.exe, etc under Linux

  • Try if cl.exe, nmake.exe, work natively on windows 10 (probably what I should've tried first)

  • Use CeGCC on linux, has the advantage of having gcc + mingw32 in one



I don't like the idea of having to fire up a VM everytime just to use a compiler, ideal would be something that works natively on Windows or inside WSL!
 Top of the page
C:Amie Page Icon Posted 2020-05-09 12:04 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
15,378
Location:
United Kingdom
Status:
Well, CE 2.10 as that had ARM compilers too.

I've lived in VM's for over a decade, so the work flow isn't an issue for me - plus I have always on servers so what's another VM in that scenario? I can see how it would be in your case though

The simplest target solution would be to have a watcher script running on the VC++ system that whenever a code drop occurs into a folder, treat it like Hudson and perform continuous integration over it. You might need a lock file on the script to halt it during file copies, but the VM could fire it every 5 seconds. Getting compiler debug data back would be annoying though unless you put a log scanner on an output file.

Are you looking to use eVC++ 3, eVC++ 4 or VC++ 6?
 Top of the page
Karpour Page Icon Posted 2020-05-09 4:51 PM
#
Avatar image of Karpour
Subscribers
Factorite (Elite)

Posts:
232
Location:
Austria
Status:
The adventure continues!

I set up Debian Lenny in Virtualbox, just for trying

added the following lines to /etc/apt/sources.list to allow apt-get to work

deb http://archive.debian.org/debian-archive/debian/ lenny main contrib non-free 
deb http://archive.debian.org/debian-security/ lenny/updates main contrib non-free
Installed libmpfr
apt-get install libmpfr1ldbl


Next step: wget CeGCC, check the other dependencies and try to run it, but the weather is too nice in Amsterdam, so that'll have to wait

Edited by Karpour 2020-05-09 5:08 PM
 Top of the page
Karpour Page Icon Posted 2020-05-09 6:08 PM
#
Avatar image of Karpour
Subscribers
Factorite (Elite)

Posts:
232
Location:
Austria
Status:
Addition to previous post: ISO I used for Debian is debian-5010-i386-netinst.iso

Installing libmpfr also solved the other missing dependency

debian:/opt/mingw32ce/libexec/gcc/arm-mingw32ce/4.4.0# ldd cc1 
        linux-gate.so.1 =>  (0xb7796000) 
        libmpfr.so.1 => /usr/lib/libmpfr.so.1 (0xb7751000) 
        libgmp.so.3 => /usr/lib/libgmp.so.3 (0xb770e000) 
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb75b2000) 
        /lib/ld-linux.so.2 (0xb7797000)
Pulled the testproject files again from http://www.mit.edu/afs.new/sipb/user/geofft/opt/mingw32ce/share/doc... Also had to install bzip2 since that's not included. Had to edit the makefile since apparently the names of the bins changed at some point
ARCH=           arm-mingw32ce
Add mingw32ce to path again
export PATH=/opt/mingw32ce/bin:$PATH
AAAAND...
debian:/opt/testproject# make menu-resource.exe 
arm-mingw32ce-gcc -g -c menu-resource.c 
arm-mingw32ce-windres menu-resource.rc menu-resource.rsc 
arm-mingw32ce-gcc -g -o menu-resource.exe menu-resource.o menu-resource.rsc -lcommctrl 
debian:/opt/testproject# ls | grep .exe 
menu-resource.exe


YES! Successfully compiled

Some additional info: The binaries of CeGCC likely won't run even in a chroot environment, since the elf format is so old that it won't run on a current kernel.
So it seems the only way to run these binaries in a VM. Of course someone could try to build it on a current kernel, that might be a thing to look into in the future!

Edited by Karpour 2020-05-09 7:00 PM
 Top of the page
ShadowMaster Page Icon Posted 2020-05-10 11:22 PM
#
Avatar image of ShadowMaster
Subscribers
H/PC Philosopher

Posts:
279
Location:
Chile
Status:
Definitely keeping an eye on this. Big fan of GCC.
 Top of the page
smb_gaiden Page Icon Posted 2020-05-11 5:48 PM
#
Avatar image of smb_gaiden
Factorite (Elite)

Posts:
208
Status:
Quote
Karpour - 2020-05-09 10:08 AM

debian:/opt/testproject# make menu-resource.exe 
arm-mingw32ce-gcc -g -c menu-resource.c 
arm-mingw32ce-windres menu-resource.rc menu-resource.rsc 
arm-mingw32ce-gcc -g -o menu-resource.exe menu-resource.o menu-resource.rsc -lcommctrl 
debian:/opt/testproject# ls | grep .exe 
menu-resource.exe


YES! Successfully compiled

Some additional info: The binaries of CeGCC likely won't run even in a chroot environment, since the elf format is so old that it won't run on a current kernel.
So it seems the only way to run these binaries in a VM. Of course someone could try to build it on a current kernel, that might be a thing to look into in the future!


Congratulations!

Seeing windres again gave me a quick daytime nightmare. Was a blocking point in getting the tcc development environment to self-host compile and link for target on target. The windres codebase was huge and snipping out dependencies was taking a couple weeks before abandoning due to lack of the same free time.
 Top of the page
hpc:factor« View previous thread · Developers Arena · View next thread »

Jump to page : 1
Now viewing page 1 [15 messages per page]

Jump to forum:
Seconds to generate: 0.063 - Cached queries : 50 - Executed queries : 28
Server Time now is: Tuesday, 27 October 2020 - 0:49