PDA

View Full Version : How to use Newton in Linux?



Relfos
02-08-2006, 05:30 PM
I'm creating a crossplataform game engine, and I decided to use Newton to do the game physics. Its all ok in Windows, but I started porting it to windows. My only problem now is with Newton, when compiling I get linker erros. The linux SDK distributed only have a .a file, not a .so file, its possible to link a .a file or convert it to a .so file?

cragwolf
02-08-2006, 10:57 PM
You could try the following but I don't know if it will really work. There are probaby subtleties that I'm missing.

1. Extract the object files from the static library by doing this:


ar x libblah.a

This will create a number of object files, *.o.

2. Compile these object files into a shared library with gcc (or g++?):


gcc -shared -o libblah.so *.o

I think one possible problem is that if the original object files weren't compiled with the -fpic switch, the above will not work because code that goes into a shared library needs to be position-independent (http://en.wikipedia.org/wiki/Position-independent_code), which is what the -fpic switch does.

cragwolf
02-08-2006, 11:09 PM
Anyway, I thought that over a year ago the author of Newton said he would distribute a shared library for Linux in the next release. Well, we've had several next releases and it seems we're still stuck on a static library. Damn these closed-source projects!

Relfos
03-08-2006, 11:03 PM
Thanks for the answer, I'll try that.
I also found something similar in the Newton forums, altough this solution is for MacOS.


you can create one easily yourself with the help of 'ar'

mkdir sometmpdir && cd sometmpdir
ar x libnewton64.a
gcc -dynamiclib -flat_namespace *.o -o libnewton64.dylib

thats it ... what you get is a mac os x shared library ... hope this is allowed...

tux
04-08-2006, 05:52 AM
Thanks for the answer, I'll try that.
I also found something similar in the Newton forums, altough this solution is for MacOS.


you can create one easily yourself with the help of 'ar'

mkdir sometmpdir && cd sometmpdir
ar x libnewton64.a
gcc -dynamiclib -flat_namespace *.o -o libnewton64.dylib

thats it ... what you get is a mac os x shared library ... hope this is allowed...

I tried that, the g3 lib is the only one that decompiles, but the dylib is only 64k so i doubt it compiled again properly

Relfos
04-08-2006, 11:46 AM
I tried cragwolf method and it compiled and linked without problems. The program also runned without errors, altough it was a OpenGL test program and it didnt use the physics engine.
I'll try porting another demo, one that uses some physics stuff to see if it really works :wink:

technomage
08-08-2006, 06:57 PM
I followed the suggestion as well but I get a

Linking SDLNewtonBasicDemo
/usr/bin/lb: cannot find -lnewton

even though I am using the -Fl switch with the path to the libNewton.a and libNewton.so

any ideas? what arguments did you use to compile your app under linux?

Dean

technomage
13-08-2006, 09:40 AM
Hi people, still no joy on linking newton under free pascal.

anyone got any ideas? This is holding up my testing of JEDI-SDL 1.0 :cry:

technomage
16-08-2006, 09:36 PM
I have made some progress.

It seems that the linker is very case sensitive, it doesn not rely on the NewtonDLL declaration but it seems to use the name of the unit (in this case newton) to locate the libraries, since the sdk ships with libNewton.a rather than libnewton.a this causes a problem, so we either need to rename the lib (which i did) or rename the unit to Newton.pas to get this to work.

That said I now get the following errors on linking.



Linking SDLNewtonBasicDemo
/usr/lib/libnewton.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info`
/usr/lib/libnewton.so: undefined reference to `operator delete(void*)`
/usr/lib/libnewton.so: undefined reference to `__gxx_personality_v0`
/usr/lib/libnewton.so: undefined reference to `__cxa_pure_virtual`
/usr/lib/libnewton.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info`
/usr/lib/libnewton.so: undefined reference to `__cxa_guard_release`
/usr/lib/libnewton.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info`
/usr/lib/libnewton.so: undefined reference to `__cxa_guard_abort`
/usr/lib/libnewton.so: undefined reference to `operator new(unsigned int)`
/usr/lib/libnewton.so: undefined reference to `_cxa_guard_acquire


now I am a bit stumped on this one it appears to be missing something but I have no idea what. Any ideas anyone?

Dean

technomage
21-08-2006, 08:31 PM
I figured out how to get this working.

For some reason I can't post the code here so here it the link to the topic on the Newton forum.

http://www.newtondynamics.com/forum/viewtopic.php?t=2758

You need to be a member of the forum to read it I'm afraid.

Dean

cragwolf
22-08-2006, 02:28 AM
Heheh, the answer was buried in between parentheses in my first post in this thread, and even I did not know it. Good detective work, Dean!