Reputation: 113
I am trying to make a library for my project. (Qt5 , Qt Creator, VS2010 compiler)
I started with a minimal test sample to check how its working.
1-I have made a library that contain a Class with a method
2-I compile it and get Dll and Lib files
3- In main aplication i add this lib and its path to .pro and tested library successfully.
Now, i want to get rid of DLL and use lib file as an static library.
So i added this line to my library .pro file
CONFIG+=staticlib
Now, i get lib file after compile, but i can not use it in my project and i get Unresolved external symbols… errors
when i remove CONFIG+=staticlib , it works again! but its not static.
these are the lines i added to .pro file of main project to load/link library
INCLUDEPATH +="G:/TestLib/testLib"
LIBS +=-l"G:/Build/debug/testLib"
So the question is : is it possible to have my own static library in Qt (none-commercial license)?
If yes, what is wrong with my approach ?
shoud i change something in LIBS+=... to specify its a static library?
I have read This Article and it seems nothing is wrong with my code.
Any help please?
EDIT : Problem solved
The problem was that we don’t need Q_DECL_EXPORT and Q_DECL_IMPORT for static libraries!
which is not mentioned in that sketchy illusory article explicitly.
Upvotes: 4
Views: 3007
Reputation: 113
Problem solved
The problem was that we don’t need Q_DECL_EXPORT
and Q_DECL_IMPORT
for static libraries! which is not mentioned in that sketchy illusory article explicitly.
Q_DECL_EXPORT
and Q_DECL_IMPORT
are necessary for dynamic libraries.
Upvotes: 3