PDA

View Full Version : Including a static library



jepessen
5th May 2011, 16:17
Hi.
I'm trying to add an external library (libmesh) to a project that must be created under Linux environment.

I've downloaded and compiled the library myself, so it's in a not standard location. The location is in

mydir/lib/libmesh.so

while headers are located in

mydir/include

in this directory I've many subfolders (base, geom etc).

The first thing that I'd like to know is how I can include all include subfolders without declare a INCLUDEPATH for everyone, but telling that I want to use all subfolders of mydir/include.

Then, I'd like to know how include the .so file in my project.

I've tried to use

LIBS += $$quote(mydir/lib/libmesh.so)

and

LIBS += -L$$quote(mydir/lib/libmesh.so)

but nothing happens: I got a lot of "undefined reference" errors.

Have you any suggestion?

mcosta
5th May 2011, 16:20
For include subdirs try with



SUBPATH = $$system(ls include)
for(d, SUBPATH):INCLUDEPATH += include/$$d



The correct syntax for libraries is



LIBS += -L$$quote(mydir/lib) -lmesh

ChrisW67
6th May 2011, 03:17
Have you any suggestion?

If the library file you wish to link against has a name ending in .so then it is a dynamic library, not a static library which would end in .a. If both dynamic and static versions of the library exists, then the linker will usually take the dynamic library by default.

jepessen
6th May 2011, 09:35
Thanks for our reply.

I've seen the QMake documentation and I've seen some example. Thanks. I've another problem, but I'll put it in another thread.
Thanks again to everyone.