Tinkering around
Tinkering around
I wanted to build FreeBASIC from source. Since I don't have a working fbc available I think it's the bootstrap archive is for me. I have setup 4 gcc based compilers on my computer:
Cygwin64:
+Cygwin GCC (/usr/bin/gcc)
+Mingw64 GCC (/usr/bin/x86_64-w64-mingw32-gcc)
MSYS2:
+Mingw64 GCC (pacman -S mingw64/mingw-w64-x86_64-gcc)
+Ucrt64 GCC (pacman -S ucrt64/mingw-w64-ucrt-x86_64-gcc)
I could confirm the 4 compilers are able to generate binaries correctly. So I have 4 working compilers. What should I do now? I already grabbed the xz archive.
Cygwin64:
+Cygwin GCC (/usr/bin/gcc)
+Mingw64 GCC (/usr/bin/x86_64-w64-mingw32-gcc)
MSYS2:
+Mingw64 GCC (pacman -S mingw64/mingw-w64-x86_64-gcc)
+Ucrt64 GCC (pacman -S ucrt64/mingw-w64-ucrt-x86_64-gcc)
I could confirm the 4 compilers are able to generate binaries correctly. So I have 4 working compilers. What should I do now? I already grabbed the xz archive.
Re: Tinkering around
I'm not sure if I have seen user feed back for using the bootstrap package on windows. I'm interested to see how this goes for you.
Have a look at:
- Bootstrapping fbc on a new system
- Compiling FB on Windows
For the bootstrap package:
- unpack the bootstrap package and file and run 'make bootstrap'
How well it goes for you will depend on what tools you have installed and environment settings, e.g. PATH.
I don't think I have ever built the STANDALONE version of fbc from the bootstrapped version. Usually, right after I build the bootstrap version, I use it to rebuild a standalone fbc on that windows system.
Of course, can also download a release package, and use that to build fbc's source code. But all the ending steps and the tools required to be installed are about the same.
Have a look at:
- Bootstrapping fbc on a new system
- Compiling FB on Windows
For the bootstrap package:
- unpack the bootstrap package and file and run 'make bootstrap'
How well it goes for you will depend on what tools you have installed and environment settings, e.g. PATH.
I don't think I have ever built the STANDALONE version of fbc from the bootstrapped version. Usually, right after I build the bootstrap version, I use it to rebuild a standalone fbc on that windows system.
Of course, can also download a release package, and use that to build fbc's source code. But all the ending steps and the tools required to be installed are about the same.
Re: Tinkering around
I realized Cygwin's mingw64 is not worth to try with. It's actually a cross compiler everyone. It makes use of a sys-root where dlls and headers are stored. The resulted binary even though generated successfully will failed to run (it's an example C++ program) because of missing of libraries. One has to copy the dlls in said sys-root next to the binary for it to be able to run. So, it you want mingw64, then just use a proper mingw64 distro and forget Cygwin.
I'm testing the normal Cygwin's gcc. It seems the result of uname caused it to be bootstrapped for the target cygwin-x86_64 which is an non-existent target. What should I do now? I know I could just forget Cygwin and continue with MSYS2 but it seems interesting for me to bring fbc to Cygwin target.
I'm testing the normal Cygwin's gcc. It seems the result of uname caused it to be bootstrapped for the target cygwin-x86_64 which is an non-existent target. What should I do now? I know I could just forget Cygwin and continue with MSYS2 but it seems interesting for me to bring fbc to Cygwin target.
Re: Tinkering around
How to build a STANDALONE version of fbc? I have a bin/fbc.exe in my bootstrapped source but this fbc doesn't see any includes! I have to pass -i [path to inc] for it to be able to see the headers. I want to have something similar to the fbc distribution you provided to us.coderJeff wrote:I'm not sure if I have seen user feed back for using the bootstrap package on windows. I'm interested to see how this goes for you.
Have a look at:
- Bootstrapping fbc on a new system
- Compiling FB on Windows
For the bootstrap package:
- unpack the bootstrap package and file and run 'make bootstrap'
How well it goes for you will depend on what tools you have installed and environment settings, e.g. PATH.
I don't think I have ever built the STANDALONE version of fbc from the bootstrapped version. Usually, right after I build the bootstrap version, I use it to rebuild a standalone fbc on that windows system.
Of course, can also download a release package, and use that to build fbc's source code. But all the ending steps and the tools required to be installed are about the same.
p/s: even if I used my bootstrapped fbc to build a normal fbc from source the resulted fbc.exe will also unable to see any includes. I only used "make" and nothing else. Maybe I'm missing something after "make", e.g: "make SOMETHING".
Re: Tinkering around
Options for fbc's makefile are listed in the makefile
'make'
- builds a normal fbc, which is intended to be installed in to a toolchain's directories
'make install'
- copies the normal build in to the toolchain's directories
- if you plan to have many toolchains installed, this could possibly work well for you
'make FBC=d:/path/bin/fbc.exe ENABLE_STANDALONE=1'
- builds the standalone version of fbc in the same directory as the makefile
- To get the standalone version to work, you will need to copy a bunch of files from the toolchain in to fbc's directories
When I make the releases, I use the contrib/release/build.sh shell script. I've never made a cygwin release, so the build script doesn't have commands for it.
'make'
- builds a normal fbc, which is intended to be installed in to a toolchain's directories
'make install'
- copies the normal build in to the toolchain's directories
- if you plan to have many toolchains installed, this could possibly work well for you
'make FBC=d:/path/bin/fbc.exe ENABLE_STANDALONE=1'
- builds the standalone version of fbc in the same directory as the makefile
- To get the standalone version to work, you will need to copy a bunch of files from the toolchain in to fbc's directories
When I make the releases, I use the contrib/release/build.sh shell script. I've never made a cygwin release, so the build script doesn't have commands for it.
Re: Tinkering around
Bootstrapping fbc with Cygwin's gcc fails at this:
src/gfxlib2/win32/gfx_win32.c:126:12: error: #if with no expression
126 | #if _WIN64
| ^
compilation terminated due to -Wfatal-errors.
make: *** [makefile:714: src/gfxlib2/obj/cygwin-x86_64/gfx_win32.o] Error 1
I have checked the fbc source, it seems support for Cygwin target is already available. I have no idea why it fails at this. Seems not related to this change of Cygwin since they even tell us to check for _WIN64.
https://cygwin.com/faq/faq.html#faq.pro ... g-cygwin64
Please have a look at this coderJeff. Thanks.
src/gfxlib2/win32/gfx_win32.c:126:12: error: #if with no expression
126 | #if _WIN64
| ^
compilation terminated due to -Wfatal-errors.
make: *** [makefile:714: src/gfxlib2/obj/cygwin-x86_64/gfx_win32.o] Error 1
I have checked the fbc source, it seems support for Cygwin target is already available. I have no idea why it fails at this. Seems not related to this change of Cygwin since they even tell us to check for _WIN64.
https://cygwin.com/faq/faq.html#faq.pro ... g-cygwin64
Please have a look at this coderJeff. Thanks.
Re: Tinkering around
Should probably be '#ifdef _WIN32'
I don't think anyone has built the cygwin target in years. I know I haven't.
I'll give cygwin64 a try. I'm downloading cygwin64 now.
EDIT:
ah, OK.
With that little fix, next will be to install libffi-devel
And then after that, 'make bootstrap' will fail because there is no bootstrap/cygwin-x86_64 directory.
Not sure why I didn't see that coming. :|
So, needed is a working fbc development tree, a modified makefile to add cygwin to the bootstrap package, and build a new bootstrap package.
I don't think anyone has built the cygwin target in years. I know I haven't.
I'll give cygwin64 a try. I'm downloading cygwin64 now.
EDIT:
ah, OK.
With that little fix, next will be to install libffi-devel
And then after that, 'make bootstrap' will fail because there is no bootstrap/cygwin-x86_64 directory.
Not sure why I didn't see that coming. :|
So, needed is a working fbc development tree, a modified makefile to add cygwin to the bootstrap package, and build a new bootstrap package.
Re: Tinkering around
Are you really sure we could substitute '#ifdef _WIN64' with '#ifdef _WIN32'? I don't know much about the Windows API but it seems this ifdef has reasons to be there.coderJeff wrote:Should probably be '#ifdef _WIN32'
I don't think anyone has built the cygwin target in years. I know I haven't.
I'll give cygwin64 a try. I'm downloading cygwin64 now.
EDIT:
ah, OK.
With that little fix, next will be to install libffi-devel
And then after that, 'make bootstrap' will fail because there is no bootstrap/cygwin-x86_64 directory.
Not sure why I didn't see that coming. :|
So, needed is a working fbc development tree, a modified makefile to add cygwin to the bootstrap package, and build a new bootstrap package.
Yeah, I see. You forgot to generate the bootstrap for Cygwin target in makefile.
EDIT:
After followed your instructions I bootstrapped fbc on Cygwin successfully. But I'm sure _WIN32 and _WIN64 is different. If you are unsure like me please keep the code as is, changing '#ifdef _WIN64' to '#ifdef _WIN32' might lead to many unexpected problems because of the different between UINT_PTR and UINT. Be careful.
https://stackoverflow.com/questions/667 ... 4bit-build
If the Cygwin target is broken I will just leave it and go for MSYS2. It's safer IMHO.
EDIT2:
Even though the bootstrap of fbc on Cygwin now successful this bin/fbc.exe can't compile any program. It fails with this:
test.bas() error 91: Executable not found: "/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/as.exe"
I'm sure as.exe is there in /usr/bin/as.exe
EDIT3:
Maybe replacing '#ifdef _WIN64' with '#ifdef __x86_64__' is a better solution? I don't know if it's right or not but I think it's less wrong than replacing '#ifdef _WIN64' with '#ifdef _WIN32'.
The bootstrap successful, too. But the resulted bin/fbc.exe still fails the same way.
EDIT4:
Well, it seems I should give up on Cygwin altogether. With MSYS2 it's pretty straightforward. I have a working fbc now. Thanks for your help anyway, coderJeff.
Re: Tinkering around
I meant that '#if' needs to be '#ifdef' to correct the error. Sorry for my sloppy typing. At this point I wasn't really thinking of anything deeper.j8w344c6 wrote:Are you really sure we could substitute '#ifdef _WIN64' with '#ifdef _WIN32'? I don't know much about the Windows API but it seems this ifdef has reasons to be there.
I didn't get that error. And I was able to build a standalone version from the bootstrap version. The standalone version would still need some work to run. Since fbc will be looking for executables in <fbcpath>/bin/cygwin-x86_64, and needs cygwin1.dll, etc, so all that stuff has to get copied over the fbc directories.Even though the bootstrap of fbc on Cygwin now successful this bin/fbc.exe can't compile any program. It fails with this:
test.bas() error 91: Executable not found: "/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/as.exe"
Yeah, up to you. cygwin build is not totally broken IMHO, but it needs some attention to make it more accessible to interested users.Well, it seems I should give up on Cygwin altogether.
- fix code errors
- add cygwin bootstrap package to release
- build a normal release
- build a standalone release (if possible). If too much of the cygwin tree needs to be copied in to the fbc directories, it hardly seems worth it to have a standalone release
- update documentation
- automation scripts for building and testing the release
@j8w344c6, I appreciate your feedback. I learned a few things with your tinkering around.
Re: Tinkering around
Sorry. I misunderstood you. Your change from #if to #ifdef fixed the problem.coderJeff wrote:I meant that '#if' needs to be '#ifdef' to correct the error. Sorry for my sloppy typing. At this point I wasn't really thinking of anything deeper.j8w344c6 wrote:Are you really sure we could substitute '#ifdef _WIN64' with '#ifdef _WIN32'? I don't know much about the Windows API but it seems this ifdef has reasons to be there.
I don't build a standalone version of fbc since I don't know how to ^^coderJeff wrote:I didn't get that error. And I was able to build a standalone version from the bootstrap version. The standalone version would still need some work to run. Since fbc will be looking for executables in <fbcpath>/bin/cygwin-x86_64, and needs cygwin1.dll, etc, so all that stuff has to get copied over the fbc directories.Even though the bootstrap of fbc on Cygwin now successful this bin/fbc.exe can't compile any program. It fails with this:
test.bas() error 91: Executable not found: "/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/as.exe"
But I will give you more insight about the problem I faced.
fbc even when built for the Cygwin target still expects Windows style backslash of path delimiter. It's the problem about failing to resolve paths.
I find out this when I tried to build a normal fbc with my previously bootstrapped fbc on the same source tree.
I used this command: make prefix=$HOME/fbc
It failed with:
FBC src/compiler/obj/cygwin-x86_64/ast-gosub.o
src/compiler/ast-gosub.bas(5) error 23: File not found, "C:\Toolchain\cygwin64\home\Administrator\test1/src/compiler/fb.bi" in '#include once "fb.bi"'
src/compiler/ast-gosub.bas(5) error 133: Too many errors, exiting
make: *** [makefile:704: src/compiler/obj/cygwin-x86_64/ast-gosub.o] Error 1
Yeah, definitely fbc is failed resolving paths.
When I tried to compile a simple test.bas it failed with:
test.bas() error 91: Executable not found: "/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/as.exe"
This can be fixed by this:
AS=`cygpath -w /usr/bin/as` LD=`cygpath -w /usr/bin/ld` ./fbc test.bas -o test
Yeah, you have to specify the paths to AS and LD, further more they have to be converted to Windows style path with cygpath -w.
There is problem even when I have test.bas built. It seems the program can't receive any inputs.coderJeff wrote:Yeah, up to you. cygwin build is not totally broken IMHO, but it needs some attention to make it more accessible to interested users.Well, it seems I should give up on Cygwin altogether.
- fix code errors
- add cygwin bootstrap package to release
- build a normal release
- build a standalone release (if possible). If too much of the cygwin tree needs to be copied in to the fbc directories, it hardly seems worth it to have a standalone release
- update documentation
- automation scripts for building and testing the release
@j8w344c6, I appreciate your feedback. I learned a few things with your tinkering around.
Regardless of it's a random key from the keyboard or enter, even Ctrl-Z and Ctrl-C don't work. I finally to have end test.exe process via Windows Task Manager.
This is what printed on the screen:
./test
Hello from FreeBASIC!
Press any key to continue...
f
d
sds
ds
dsd
sd
sd
sds
And this is test.bas:
print "Hello from FreeBASIC!"
print "Press any key to continue..."
sleep
Re: Tinkering around
I have a somewhat wild idea. What about decoupling Cygwin and Win32/Win64 altogether? Our Cygwin code still expects and integrates with Win32/Win64 environment. What about just treat Cygwin as just another Linux/Unix platform? What if we remove any Win32/Win64 specific parts from our Cygwin code and let gfxlib2 to use Cygwin's X server as the backend instead of force it using the win32's gfxlib2?
Ah, this is so wild. I think I'm too right giving up on Cygwin.
Ah, this is so wild. I think I'm too right giving up on Cygwin.
Re: Tinkering around
This is not too wild at all. I picked up a random X11 application on Cygwin's setup-x86_64.exe and it worked pretty well. You have to start the XWin Server first, then on the system tray you will see the icon of X applications menu where you could choose the X11 application to launch. It's like a Start Menu of X11. Even big application like the Gambas development environment (so many dependencies) worked fine. The only drawback IMO is the font is not beautiful, it seems there is no hinting and it looks alien to the rest of Windows (of course, since it's a X11 application and not a Win32 native one).j8w344c6 wrote:I have a somewhat wild idea. What about decoupling Cygwin and Win32/Win64 altogether? Our Cygwin code still expects and integrates with Win32/Win64 environment. What about just treat Cygwin as just another Linux/Unix platform? What if we remove any Win32/Win64 specific parts from our Cygwin code and let gfxlib2 to use Cygwin's X server as the backend instead of force it using the win32's gfxlib2?
Ah, this is so wild. I think I'm too right giving up on Cygwin.
Edit: BTW, how to exit the XWin Server? It constantly using 25% of my CPU. I choose the exit it from the system tray icon but it does nothing. It's still there and running.
Edit2: It seems the only way is to restart Windows. It's the safest, since I don't know which is the right process to end on the Windows Task Manager.
Re: Tinkering around
This is when tried to compile examples/graphics/flame.bas:
flame.bas(12) error 23: File not found, "C:\Toolchain\cygwin64\home\Administrator\test1\bin/C:\Toolchain\cygwin64\home\Administrator\test1\bin/../include/freebasic/fbgfx.bi" in '#include "fbgfx.bi"'
Yeah, definitely fbc fails to resolve path since it's mixing Windows' backslash and Cygwin's forward slash.
flame.bas(12) error 23: File not found, "C:\Toolchain\cygwin64\home\Administrator\test1\bin/C:\Toolchain\cygwin64\home\Administrator\test1\bin/../include/freebasic/fbgfx.bi" in '#include "fbgfx.bi"'
Yeah, definitely fbc fails to resolve path since it's mixing Windows' backslash and Cygwin's forward slash.
Re: Tinkering around
I think I find out the problem. It's Cygwin but the rtlib is still of win32 and it call Windows API functions from windows.h to get the current path. Of course the Windows API will return Windows style path. Mixing with Cygwin's style path we would come up with the mixed path we currently have.
Windows style path: C:\Toolchain\cygwin64\home\Administrator\test1\bin
Cygwin style path: ../include/freebasic/fbgfx.bi
The mess we currently have: C:\Toolchain\cygwin64\home\Administrator\test1\bin/../include/freebasic/fbgfx.bi
Unfortunately I don't have the ability to code so I can't fix the problem myself. Might be coderJeff will have a look at it someday.
Windows style path: C:\Toolchain\cygwin64\home\Administrator\test1\bin
Cygwin style path: ../include/freebasic/fbgfx.bi
The mess we currently have: C:\Toolchain\cygwin64\home\Administrator\test1\bin/../include/freebasic/fbgfx.bi
Unfortunately I don't have the ability to code so I can't fix the problem myself. Might be coderJeff will have a look at it someday.