Unofficial FreeBASIC 1.04.0 OS X release

General discussion for topics related to the FreeBASIC project or its community.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by srvaldez »

thank you :)
venom
Posts: 16
Joined: Apr 03, 2015 20:55
Location: Germany

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by venom »

Just a quick update: The fix for the warnings has been committed and merged. Once FB 1.05 is released, the warnings will be gone.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by srvaldez »

thank you
venom
Posts: 16
Joined: Apr 03, 2015 20:55
Location: Germany

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by venom »

Just a bit of information to get you excited: I just ran a graphical demo (qbsprite.bas) on OS X without XQuartz.
I'm currently writing an SDL2-backend for gfxlib2. It's still in an early stage (no Keyboard support yet, not optimized for non-32bit-modes yet, no OpenGL support...), but it does run on Linux (on X11, didn't try Wayland yet) and OS X, and it already has mouse support. ;)
I hope that I'll have it ready for the 1.05 release (depends on how much time I'm able to invest in the near future), and I also hope that this is a step that brings us closer to new platforms (Android, for example).
bihai
Posts: 36
Joined: Mar 25, 2015 7:56

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by bihai »

venom wrote:Just a bit of information to get you excited: I just ran a graphical demo (qbsprite.bas) on OS X without XQuartz.
I'm currently writing an SDL2-backend for gfxlib2. It's still in an early stage (no Keyboard support yet, not optimized for non-32bit-modes yet, no OpenGL support...), but it does run on Linux (on X11, didn't try Wayland yet) and OS X, and it already has mouse support. ;)
I hope that I'll have it ready for the 1.05 release (depends on how much time I'm able to invest in the near future), and I also hope that this is a step that brings us closer to new platforms (Android, for example).
We can't wait for that! thank you!
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by srvaldez »

that is good news indeed :)
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by srvaldez »

hello venom, any news ?
panoramic
Posts: 5
Joined: Feb 28, 2013 18:17
Location: France
Contact:

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by panoramic »

You can download it here (i don't know how long this link will stay valid, it would be cool if this could be uploaded to sourceforge where the other releases reside
hello venom,

The link you gave in the first post of this thread is dead.
Can you make it available again ? (Or from somebody else who has downloaded this release of fbc for OsX)
I would like to test it on a MacBook, and maybe to use it in a Basic language project which needs an OsX compiler as base.
Thank you in advance.
TeeEmCee
Posts: 375
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by TeeEmCee »

I don't have a copy of that, but I have a slightly old build of my branch of FB 1.06. It includes a bunch of OSX-specific bugfixes and missing features like #inclib support and header fixes, so you might like to use it anyway (it's not far off being able to be merged in):

Build: http://tmc.castleparadox.com/temp/fbc-1 ... 05.tar.bz2
Source: https://github.com/rversteegen/fbc/commits/mac

I probably didn't compile libfbgfx2 with ENABLE_XQUARTZ though. I use SDL.

I never saw this thread before. I did however notice venom's SDL2 branch on github, and if I ever have enough free time I would like to pick it up. Likewise I would also like to see v1ctor's SDL 1.2 (Emscripten) branch get merged as a serious backend; I'm going to play with Emscripten next.
panoramic
Posts: 5
Joined: Feb 28, 2013 18:17
Location: France
Contact:

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by panoramic »

Thank you for your help, TeeEmCee.
I downloaded your build, and I tried to compile a very simply source : test.bas

Code: Select all

print "test"
end
First of all, I had the error : error 23: File not found, crt1.o
I copy crt1.o to lib/freebasic/darwin-x86_64.

It's OK, but now,
with the command ./fbc test.bas, I get the error :

ld: library not found for -lgcc

with the command ./fbc -r -gen gcc test.bas, I get a C file (test.c), and if I compile it with then command gcc test.c -o test, I get errors :

Undefined symbols for architecture x86_64:
"_fb_End", referenced from:
_fb_ctor__test in test-3f3a4f.o
"_fb_PrintLongint", referenced from:
_fb_ctor__test in test-3f3a4f.o
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I cannot find a solution.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by srvaldez »

hello panoramic
try compiling with the following command
fbc -w all -R -RR -asm att -gen gcc -Wc -O2 -v test.bas
-v means verbose but it also prints the gcc command used to compile the file as well as the assembling and linking commands
-R an -RR tells FB to keep the c and asm files, you may omit those.
if you don't have libgcc then perhaps installing Xcode will solve the problem.
TeeEmCee
Posts: 375
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by TeeEmCee »

(Sorry, I was too busy to check the forum.)
Where did you get crt1.o from? It's meant to be in a standard system-wide location, so that the linker will find it when compiling. Maybe XCode puts it somewhere private?

Is there a copy of libgcc.a or libgcc.so anywhere on your harddisk? Normally it is in a special subdirectory for a specific gcc/clang version, not in the usual place for libraries.

The error "clang: error: linker command failed with exit code 1" seems to indicate that you have a recent version of XCode, which does not include gcc or many of the classic NeXTSTEP/OSX cctools but only clang (and gcc symlinked to clang; apparently ld is also a front for clang?). I am using a real gcc. I thought that the FB -gen gcc emitter does not support clang at all, at least I have never managed to get it to work. However, apparently it works for srvaldez! It appears that the clang in the latest XCode versions is not the same as the open source version of clang, and may be more compatible with gcc than the public versions are.
It appears that when compiling with clang libgcc should not be linked, but it's harmless to link it; that isn't a problem specific to OSX. However it's only with modern XCode that you would find a system that is missing libgcc.

Unfortunately I can't test with a recent XCode version on my Mac, because XCode doesn't support it. However if I get crosscompiling from GNU/Linux working then I'll be able to use a recent clang and investigate. I'll try that soon.

srvaldez's advice is for fbc 1.05 (or fbc 1.04?) for the previously posted FB build for OSX. It shouldn't make any difference for my build.

You can try linking manually instead of letting fbc do it. For example:

Code: Select all

fbc test.bas -g -m test -r
LIBDIR=path/to/freebasic/lib/freebasic/darwin-x86_64
clang -g $LIBDIR/fbrt0.o test.c -o test -L$LIBDIR -lfbmt
It's not practical, but it's very useful to know whether it works. Then we can pass -v to clang to see what the correct things to pass to the linker are.

You can also try installing gcc separately (and making sure it's in your $PATH), e.g. from homebrew or macports.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by srvaldez »

panoramic wrote: It's OK, but now,
with the command ./fbc test.bas, I get the error :

I cannot find a solution.
I know this is an old post but I am posting this for others (including myself) that might run into this problem.
from the terminal

Code: Select all

sudo ln -s /usr/lib/libSystem.B.dylib /usr/local/lib/libgcc.dylib
TeeEmCee
Posts: 375
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by TeeEmCee »

I can guess what the proper solution for that problem is. What do you get when you run "gcc -print-libgcc-file-name"?

Calling the the linker ourselves instead of letting gcc do it, even though we depend on gcc and it has numerous platform-specific quirks, is a recipe for disaster. Same reason that the FreeBSD port is broken.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Unofficial FreeBASIC 1.04.0 OS X release

Post by srvaldez »

TeeEmCee wrote:What do you get when you run "gcc -print-libgcc-file-name"?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin17.0.0/libclang_rt.builtins-x86_64.a
however, libgcc_s.1.dylib is a symlink to /usr/lib/libSystem.B.dylib that symlink is part of the system, I did not create that link, and I have had no issue whatever using my solution above.
[edit] after having installed gcc toolchain the symlink I suggested is no longer needed.
Post Reply