Advertisement

Creating a .so from a .a library

Started by September 27, 2005 04:02 PM
3 comments, last by GameDev.net 18 years, 11 months ago
Hi, Newton provides a .a file in their library. My game, however - is .NET. I would like to wrap Newton and use it in my engine, but this requires a .so file, which is not provided. Is it possible for me to "roll my own" ? I do not have source code, only the library file and the headers.
Ollie "It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
I don't think that's possible. As well as being built as a shared library (-shared), .so must contain position-independent code and as such must be compiled specially. So, unless the library has been compiled with -fPIC (even though it's still a static lib), I doubt it's going to work.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
Aight - thanks for the snappy reply Fruny, I'll pass this information on to the Newton developer :)
Ollie "It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
well, you could try:

ld --whole-archive -share -o foo.so foo.a


/Nico
Quote: Original post by Fruny
I don't think that's possible. As well as being built as a shared library (-shared), .so must contain position-independent code and as such must be compiled specially. So, unless the library has been compiled with -fPIC (even though it's still a static lib), I doubt it's going to work.


It can work, I did it once for some X library that my dist decided for some obscure reason to supply as .a only. I didn't do it exactly like NicoDeLuciferi (though his way probably works), I just extracted al the .o files from the lib with ar, and then instructed ld to build a shared library out of them. I didn't have any problems using the resulting .so.

This topic is closed to new replies.

Advertisement