Importing a C++ static library and linking

Archives Forums/Linux Discussion/Importing a C++ static library and linking

JoshK(Posted 2013) [#1]
I compiled Leadwerks as a Linux static library and am trying to build a BlitzMax application that imports it. When it gets to the linking phase I get a lot of "undefined reference" for the OpenAL and OpenGL commands.

I need to import OpenAL, OpenGL, and X11 into my BlitzMax program so the static library can use them. Simply importing pub.OpenAL doesn't do it. Does anyone know how to solve this? Thank you.


dawlane(Posted 2013) [#2]
Never tried using a static library with Blitz Max or including any GL, Openal library, etc statically in my own code as you can never tell what the libraries license allows and I wouldn't want to find that someone want's my code because I statically linked to some GPL library.

But to link a library you would use Import "-lname.a". The .a is usually associated with static libs. Any Framework that uses the library should come before the Import and Strict should come after any imports.
E.G.
Import "-lopenal.a"

The above is an example you will never find any GPL/LGPL library as a static binary due to license issues. Licenses can be found in /usr/share/doc.

EDIT: If possible Josh send me some test code.


JoshK(Posted 2013) [#3]
The OpenAL and OpenGL libraries are shared objects.


dawlane(Posted 2013) [#4]
OpenAL and OpenGL libraries are shared
And I take that you have already tried using Import "-lopenal", Import "-lx11".
Is the leadwerks lib compiled as 32bit or 64bit?


JoshK(Posted 2013) [#5]
Ah, you are right, thank you. On to other issues...


JoshK(Posted 2013) [#6]
The trick here is to have this code AFTER the library that needs it is imported:
Import "-lopenal"