DLL on linux

Started by
4 comments, last by MaulingMonkey 18 years, 10 months ago
hello I have one main program (a game) and an engine I created to use on it. But I want to make a library of my engine to use on the game. How could I do this? I'm using MinGW and Kurumin with KDE. I already made a library with the .cpp and .h from my engine and put the libengine.so on /usr/local/lib. I've set my game (Project -> Settings -> Link -> Libraries) to load this library I created. But when it's time to call some .h I need from the engine, it returns that it couldn't be found. Can someone point me some tutorials or explain me what's going on? I'm a newbie on linux programming
Advertisement
"call some .h"..?
Quote:Original post by Catafriggm
"call some .h"..?


I meant when I want to call any .h file.

e.g.

I have the class Image and then I have to use an object from another class called Graphics (I have to declare it like #include "graphics.h")

But if it is inside a library, I don't know how to call it in the right way. Besides that, I don't know either how to set my library on MinGW
You're saying that
#include"anyheader.h", returns an error?

You have to have your headers at /usr/local/include (or at your path of choice). Or you could use compiler flag -I to specify your custom location of the headers.

If linking is the problem (ie. linker complains that yourlib.so cannot be found) you should run ldconfig which updates the /etd/ld.so.cache.

If this does not help, you should give us more specific information about the problem. Perhaps the name of your IDE you seem to be using. Some code snippets and the error messages.

EDIT: Fixed typo (-L -> -I), thanks NMI

[Edited by - Winograd on May 27, 2005 4:36:25 AM]
Quote:Original post by Winograd
You have to have your headers at /usr/local/include (or at your path of choice). Or you could use compiler flag -L to specify your custom location of the headers.


No, -L was for libraries, -I is for include files.

If your program is crashing at runtime when you attempt to call your library function, with a message related to not being able to load the library, then it sounds like /usr/local/lib isn't being searched. Two fixes:

1) Add it to the permanent path (preferred).
1.1) You'll need to be root.
1.2) Edit /etc/ld.so.conf, add /usr/local/lib to the list.
1.3) Run /sbin/ldconfig.

2) Set an environment variable (temporary, not prefered).
2.1) This won't work for SUID or SGID programs, for security reasons.
2.2) Run export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
3.3) Note: /usr/local/lib will be searched before any paths in your /etc/ld.so.conf - this can break programs if a lower version of a library is in /usr/local/lib when an application depends on the higher version installed in /usr/lib.
3.4) Reason why the variable's paths are searched first: LD_LIBRARY_PATH is more of a debugging tool for testing new versions of libraries.
3.5) Reason why it would be a security issue if it worked with SUID/SGID: The user could create a mallicious .so file which does nasty things whenever a function is called. If SUID or SGID, those things would be done as root (or owning user, if not root) - this means the user would in effect be able to immediately gain root's (or someone else's) privilages.

This topic is closed to new replies.

Advertisement