PDA

View Full Version : Working with a static library I have written in Qt



Guilo
10th November 2011, 16:39
Hi all !

Here is my problem : I have a project that has two subprojects, both are libraries. One is QJson and the other one is home-made and uses Qt. I then have an other project that will use these two libraries. I want this main project to use my set of library statically.

Here is what I have in my .pro :


LIBS += -L$$PWD/../../../libmylib/lib/
LIBS += -lqjson -lmylib


INCLUDEPATH += $$PWD/../../../libmylib/include
DEPENDPATH += $$PWD/../../..libmylib/include

Everything works fine under MAC OS X.

Now, I want this project to work on Windows. And here are the issues. My main project complains about undefined references to mylib. MyLib project has generated qjson.a and qjson.dll, mylib.a (no dll).

Shouldn't my library be outputed as a .lib ? Why don't I have a dll for mylib ?

Thanks

ChrisW67
10th November 2011, 22:32
The linker command typically assumes dynamic linking, try listing the library file explicitly:


LIBS += -lqjson $$PWD/../../../libmylib/lib/mylib.a


You are getting the .a suffix because you are using (I assume) the MinGW/GCC compiler.
You get no DLL because I assume you pro file for mylib specifies static in the CONFIG variable.

Guilo
11th November 2011, 21:11
Thanks for your answer. Your assumptions are true. But however, linking with the mylib.a doesn't work neither. I still get some undefined references.

I will make some tries with samples projects...

Added after 1 26 minutes:

Mylib was using QJson itself. So I mixed it all and now it works with mylib as a static library. Thanks.

Next step is to get this built for Symbian. Is there any documentation anywhere on how to link to a static library for Symbian ?

Thanks

Guilo
12th November 2011, 13:13
I have found this (http://www.developer.nokia.com/Community/Wiki/TSQ001521_-_Using_shared_and_static_libraries_in_Qt_for_Symbi an) that tells me how to link to a symbian library. The issue is that when I built ly library for symbian, it didn't output any .lib or .dll file anywhere. Any idea ?