how to compile FB for Cygwin

Linux specific questions.
srvaldez
Posts: 2023
Joined: Sep 25, 2005 21:54

how to compile FB for Cygwin

Postby srvaldez » Dec 05, 2018 10:50

I installed cygwin x64, and would like a cygwin version of FB, how do you compile FB using a current standalone FB ?

I tried, and while everything compiles just fine, using the newly built FB fails to compile any example program
I get the following errors
error 23: File not found, crt2.o
ld: cannot find G:\cygwin64\usr\local\bin\..\lib\freebasic\win64\fbextra.x: No such file or directory
ld: cannot find G:\cygwin64\usr\local\bin\..\lib\freebasic\win64\fbrt0.o: No such file or directory
ld: cannot find -lfb
ld: cannot find -lfbgfx
ld: cannot find -lmsvcrt
ld: cannot find -lmingw32
ld: cannot find -lmingwex
ld: cannot find -lmoldname

renaming the directory lib\freebasic\cygwin-x86_64 to lib\freebasic\win64 eliminates the directory not found and after copying the cygwin version of the missing libraries and crt2.o to lib\freebasic\win64, I get
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x16): undefined reference to `__cxa_atexit'
/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x16): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__cxa_atexit'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(init.o):init.c:(.text+0x9c): undefined reference to `__getreent'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(init.o):init.c:(.text+0x9c): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__getreent'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(io_input.o):io_input.c:(.text+0x1af): undefined reference to `__locale_ctype_ptr'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(io_input.o):io_input.c:(.text+0x1af): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__locale_ctype_ptr'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(io_input.o):io_input.c:(.text+0x1c7): undefined reference to `__locale_ctype_ptr'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(io_input.o):io_input.c:(.text+0x1c7): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__locale_ctype_ptr'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(io_input.o):io_input.c:(.text+0x221): undefined reference to `__locale_ctype_ptr'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(io_input.o):io_input.c:(.text+0x221): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__locale_ctype_ptr'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(io_input.o):io_input.c:(.text+0x2e1): undefined reference to `__locale_ctype_ptr'
G:\cygwin64\usr\local\bin\..\lib\freebasic\win64/libfb.a(io_input.o):io_input.c:(.text+0x2e1): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__locale_ctype_ptr'
marcov
Posts: 2757
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: how to compile FB for Cygwin

Postby marcov » Dec 05, 2018 10:53

Did you recompile the C parts of the FB rtl with the cygwin compiler?

getreent is probably something related to unix style directory handling, locale_ctype_ptr is locale related, which probably won't be a surprise. (link libintl?)
srvaldez
Posts: 2023
Joined: Sep 25, 2005 21:54

Re: how to compile FB for Cygwin

Postby srvaldez » Dec 05, 2018 11:24

marcov wrote:Did you recompile the C parts of the FB rtl with the cygwin compiler?

yes, but I suspect it's going to take more than my naive approach to cross-compile to cygwin.
srvaldez
Posts: 2023
Joined: Sep 25, 2005 21:54

Re: how to compile FB for Cygwin

Postby srvaldez » Dec 05, 2018 14:26

can someone point me to the information that was posted by jonathanbrickman0000 https://freebasic.net/forum/viewtopic.php?t=3390 ?
dkl
Site Admin
Posts: 3209
Joined: Jul 28, 2005 14:45
Location: Germany

Re: how to compile FB for Cygwin

Postby dkl » Dec 05, 2018 18:00

Keep in mind that cygwin and mingw-w64 are different toolchains, and FB uses either win64 (mingw-w64, 64bit) or cygwin-x86_64 (cygwin, 64bit), which cannot be mixed. It has to be treated as if cross-compiling (even though it's both 64bit Windows).

It should work something like this:
1. get win64 fbc (needed for bootstrapping)
2. get FB sources for the same FB version as the win64 fbc (must be compatible to code generated by bootstrap compiler)
3. in Cygwin shell, where gcc is Cygwin's gcc (not mingw), compile rtlib for cygwin-x86_64: make rtlib
4. result should be lib/freebasic/cygwin-x86_64/libfb.a etc. If it produced lib/win64/ instead, then the makefile's host system detection is broken, and you can try again but use "make rtlib TARGET_OS=cygwin TARGET_ARCH=x86_64" this time.
5. copy libfb.a etc. from lib/freebasic/cygwin-x86_64/ to path/to/FreeBASIC-win64/lib/cygwin-x86_64/ (next to lib/win64/)
6. in Cygwin shell, cross-compile a cygwin-x86_64-hosted fbc using the win64 fbc: make compiler TARGET_OS=cygwin TARGET_ARCH=x86_64 FBC='path/to/FreeBASIC-win64/fbc.exe -i path/to/FreeBASIC-win64/inc'
7. after that, bin/fbc.exe should work
8. you can build gfxlib2 in the same way as rtlib: make gfxlib2 TARGET_OS=cygwin TARGET_ARCH=x86_64
9. make install
10. then you can get latest FB sources and run: make && make install
srvaldez
Posts: 2023
Joined: Sep 25, 2005 21:54

Re: how to compile FB for Cygwin

Postby srvaldez » Dec 05, 2018 19:46

thank you dkl
I followed your instructions to best of my understanding, it built the libraries in the cygwin-x86_64 folder, however, after having installed the newly built FB, and trying to build FB again, it looks for libraries in the win64 folder instead, if I rename the cygwin-x86_64 folder to win64, it then complains of missing libraries such as msvcrt and also of missing crt2.o
dkl
Site Admin
Posts: 3209
Joined: Jul 28, 2005 14:45
Location: Germany

Re: how to compile FB for Cygwin

Postby dkl » Dec 05, 2018 20:31

Maybe we need to add "-target cygwin-x86_64" to the FBC variable above (in the fbc cross-compile step). Looking at the makefile, it doesn't add it automatically.

With that you will probably also need FreeBASIC-win64/bin/cygwin-x86_64/{as,ar,ld,gcc}.exe and cc1.exe etc. plus the Cygwin libraries in FreeBASIC-win64/lib/cygwin-x86_64/, all of which can hopefully be copied out of the Cygwin installation.

By the way you can check the output of fbc -v to see host and target; the newly built fbc.exe must say cygwin-x86_64 (as opposed to win64), otherwise it's wrong/bugged.

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 1 guest