Skip to main content
GameDev.net gamedev.net
🔒 Locked

Linking with DevC++

Started by The Najdorf Nov 16, 2005 at 11:03 PM 2 replies 2.1k views
Original Post
The Najdorf
The Najdorf
When I want to link opengl or SDL with devC++, i have to write, under the linking options, "-lSDLmain -lSDL -lopengl" or something like that. however I searched my computer I didnt find any file called "lopengl" to what file is he referring to when I write "lopengl", "lSDLmain" etc? plus, can you tell me what are those '.a" and ".o" files? Thanks
Got a Mac? Check out my game at [a]http://www.radicalrebound.com[/a]
Kwizatz
Kwizatz
Usually the -l flags refer to lib*.a files, you should use -lopengl32 for OpenGL.

lib*.a files are library files (either static or referencing a dll), the equivalent to *.lib files for VC++, .o files are object files, the equivalent to .obj in VC++.

Hope that helps.
The Najdorf
The Najdorf
Oh, thanks!

That's why I never managed to link stuff, I was linking to the ".lib" (VC++) things instead of the ".a" (GCC)!

So the ".a" files are different from the ".lib", but are the "dll"s for VC++ and GCC different or not?
Got a Mac? Check out my game at [a]http://www.radicalrebound.com[/a]
Kwizatz
Kwizatz
Quote:
Original post by The Najdorf
Oh, thanks!

That's why I never managed to link stuff, I was linking to the ".lib" (VC++) things instead of the ".a" (GCC)!

So the ".a" files are different from the ".lib", but are the "dll"s for VC++ and GCC different or not?


No, they're not different, they have the same structure, however, because of the function overloading feature of C++, the way objects work, and the lack of a standard in this particular, different compilers mangle C++ function names differently, for example, lets say you have a function void foo(int), one compiler might mangle it and name it as void_foo_int where other would mangle it as int_foo_void, when you try to compile a program against a dll which was compiled on a different compiler, it will not be able to find the symbol void_foo_int, because its set as int_foo_void on the DLL.

The issue is not trivial, you cannot just make dummy libraries with aliases to the correct function names, because internally one compiler is likelly to handle objects different from another, the solution is to stick to C APIs, using extern "C" for the functions you want to expose in the case where cross compiler compatibility is desired, or you could use something like COM or CORBA.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.