porting libraries

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Posts: 117
Joined: Oct 18, 2007 8:10

porting libraries

Postby aleofjax » Dec 26, 2007 12:07

I wasn't sure how to search for this, so I'm asking here:

Say I found a really cool library that I want to use in FB, but it's written in C. How do I go about making it useable in FB? I do know c/c++, but would I have to rewrite every line of code, or is there a simpler way to port it? Maybe this should be in the beginners section, I don't know.

Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois

Postby cha0s » Dec 26, 2007 13:41

Is it compiled with gcc? If so, just make a header with the declarations and stuff, and add #inclib "thelib", where the library is named "libthelib.a"
Posts: 117
Joined: Oct 18, 2007 8:10

Postby aleofjax » Dec 26, 2007 14:33

I don't know what it was compiled with, but I do have the static library. When I try to #inclib though, something goes wrong. Here's the code, and the .bas file is in the same directory as libChipmunk.a

Code: Select all

#inclib "libChipmunk.a"

Here's the compiler log:

Code: Select all

FreeBASIC Compiler - Version 0.18 (08-13-2007) for win32 (target:win32)
Copyright (C) 2004-2007 The FreeBASIC development team.

compiling:    C:\FB\chipmunk\ChipmunkStaticLib1\test.bas -o C:\FB\chipmunk\ChipmunkStaticLib1\test.asm
assembling:   C:\PROGRA~1\FREEBA~1\bin\win32\as.exe --strip-local-absolute "C:\FB\chipmunk\ChipmunkStaticLib1\test.asm" -o "C:\FB\chipmunk\ChipmunkStaticLib1\test.o"
linking:      -T "C:\PROGRA~1\FREEBA~1\bin\win32\i386pe.x" -subsystem console -s --stack 1048576,1048576 -L "C:\PROGRA~1\FREEBA~1\lib\win32" -L "./" "C:\PROGRA~1\FREEBA~1\lib\win32\crt2.o" "C:\PROGRA~1\FREEBA~1\lib\win32\crtbegin.o" "C:\FB\chipmunk\ChipmunkStaticLib1\test.o" -o "C:\FB\chipmunk\ChipmunkStaticLib1\test.exe" -( -llibChipmunk.a -lfb -lgcc -lmsvcrt -lkernel32 -lmingw32 -lmingwex -lmoldname -lsupc++ "C:\PROGRA~1\FREEBA~1\lib\win32/fbrt0.o" -) "C:\PROGRA~1\FREEBA~1\lib\win32\crtend.o"

I don't know how to figure out what the problem is from this. I really hope I don't have to compile everything myself, I wouldn't know where to start.

As an alternative solution, could you maybe point me toward a properly compiled 2d rigid body physics lib?
Posts: 824
Joined: Dec 07, 2005 22:58

Postby maddogg6 » Dec 26, 2007 14:51


http://www.freebasic.net/forum/viewtopi ... hysics+lib

*me thinks ODE has already been ported*
Look for the ODE folder in FB/inc. But I dont see example bundled with FBC distro.
Posts: 117
Joined: Oct 18, 2007 8:10

Postby aleofjax » Dec 26, 2007 15:39

Thanks! I'm downloading ode now, and I just noticed a Newton.bi in /inc, which looks like it should be similar in use. Lemme go see if I can get ODE to work!
Posts: 117
Joined: Oct 18, 2007 8:10

Postby aleofjax » Dec 26, 2007 16:24

Yep, ODE is fully ported, thanks to our good friend Joshy here! Unfortunately, it seems to be made just for 3d implimentations. I'm nowhere near ready to start up with that! That's why I was trying to find a way to use chipmunk.

I'm sure there's a way to use ODE for 2d progs, but it just seems too complicated for me to grasp at my n00b stature. I'm gonna go look at newton some more and see if I can find a 2d implimentation there.

Thanks for the help guys!
Posts: 717
Joined: Dec 04, 2005 0:16
Location: Varazdin, Croatia, Europe

Postby duke4e » Dec 26, 2007 16:34

FB port of HGE has additional 2D physics library (box2D). You can learn HGE in a day + you'll have awesome 2D physics.

Just check it here http://www.freebasic.net/forum/viewtopic.php?t=9701
Posts: 8132
Joined: May 28, 2005 3:28

Postby D.J.Peters » Dec 26, 2007 17:51

hello aleofjax
you are welcome to use the OpenDE FreeBASIC package
i ported the drawstuff lib to FreeBASIC so you test the
included examples.

here are the download links for Win32 and Linux:

Posts: 775
Joined: Jul 01, 2005 18:45

Postby VirusScanner » Dec 28, 2007 0:16

You wrote this:
#inclib "libChipmunk.a"

You should write this:
#inclib "Chipmunk"

The linker automatically adds the "lib" and the ".a", so the way you're doing it it will look for liblibChipmunk.a.a, which will obviously not be found.
Posts: 117
Joined: Oct 18, 2007 8:10

Postby aleofjax » Dec 28, 2007 4:10

Well, that's aufully nice of the linker. It'd be nice if the compiler log could have mentioned something about that. "Unable to open liblibChipmunk.a.a" or something like that. Maybe in a future release?

Thanks for the tip VS! I should be creating some really cool stuff now ... as soon as I learn all the chipmunk functions, that is.

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 1 guest