[Solved] Linking in a static library
-
Other ideas, for the link-section try to use this:
@
CONFIG( Debug ) {
LIBS += -shared -L../Libraries/Widgets/debug -lWidgets
PRE_TARGETDEPS += ../Libraries/Widgets/debug/libWidgets.a
} else {
@ -
Hmmm... weird. It does contain Widgets_dll in several places. Does that mean it was build wrong?
Adding -static to the LIBS variable did not help. Or did I misunderstand your second solution?
-
[quote author="franku" date="1345213035"]Other ideas, for the link-section try to use this:
@
CONFIG( Debug ) {
LIBS += -shared -L../Libraries/Widgets/debug -lWidgets
PRE_TARGETDEPS += ../Libraries/Widgets/debug/libWidgets.a
} else {
@[/quote]I don't understand this. I don't want a shared library, but a static one.
-
Ok. If the libwidgets.a lib was built as static lib, then it should not contain references to any dll (I looked for it in some static lib i have for sure and there wasn't). If the -static solution does not static link then in my opinion the build of libwidgets.a went wrong. I do not know yet where or when static and dll libs are used in common.
However, the order of -static and -lwidgets is important. You may have read in the linked comment above. But in my opinion, maybe I am false, the lib is built wrong.
-
Sorry, this was a typo. I ment -static
-
Thank you for your help so far.
I think so you are right something goes wrong in the build, but I for the life of me can't figure out what it might me. I have pasted my "build output":http://pastebin.com/cmxjEV42 online. While inspecting the contents of the CONFIG variable, I did find a "shared" there. The documentation lists "dll" as the keyword that triggers building a shared library, but I tried removing it explicitly anyway. That did not help.
I had already tried putting the -static in the LIBS (before the lib itself), without result.
Other suggestions are welcome.
-
Ok, I will have a look in the build process. Maybe I find out what happens.
rgds, .. frank -
Do you have the output for your application being lonked, too?
Uups, linked. With icecream in one hand.
-
Sorry for the absense.
I managed to link properly! I noticed from the output that the ar tool was used, and that gave me a good feeling. I deleted the Makefiles and all object files from the libary, and the makefiles and produced binary from the application itself. I then build the library again, and no more .dll strings appeared in the result. Then, I build and linked the application, and it just worked.
It seems that, even after cleaning, manually running qmake and doing a complete rebuild, I still had some stale stuff that messed up my build.
Thanks for your help!
-
Glad having helped to [solve]
:-) -
Hi Andre,
I am facing the similar problem.
I am unable to link my static library to my application.
My application is unable to see the functions inside the library.
I get 'undefined reference to' when I access the function.
Any thoughts on this?
Thanks,
Kumar