PDA

View Full Version : .dll .lib



Atomic_Sheep
20th May 2014, 13:03
Hello,

I'm trying to create my own library and include it in my own project, however I'm a bit stuck. I've managed to compile a .dll however when I go to add it into my project using the technique from:

http://qt-project.org/doc/qtcreator-2.7/creator-project-qmake-libraries.html

I can't see the .dll file and the only type of file that the pop up window allows is a .lib. Two questions arise:

1.) Firstly, how does one compile a .lib file? I have tried:


TEMPLATE = lib
CONFIG += staticlib

as per http://qt-project.org/doc/qt-4.8/qmake-common-projects.html

however, with this, I'm unable to get anything to compile, I just get the .o and .a files to be created but no binary.


TEMPLATE = lib
CONFIG += dll

works fine, a .dll is created without any problems.

2.) Secondly why isn't it possible to add a .dll file using the method of right clicking in the .pro file and clicking 'add library'? Is there a way of doing this? (apart from manually adding all the fields - the whole reason why I'm doing it using a wizard is to see what needs to be added... tried saving some time, but in the end, would have probably been quicker to read up on the .pro documentation and just do it manually but anyway.)

ChrisW67
22nd May 2014, 09:23
1) The libsomething.a file is the static library. You are clearly using the GCC compiler/tools while reading advice for/from people using the Microsoft compiler/tools. The MS tools create static libraries in files name something.lib.

2) On Windows your linker will use a "link library" that contains stub code to load and use a matching dynamic library at run time. The "link library" matching something.dll will be named libsomething.a or something.lib under MinGW and Microsoft tools respectively. You cannot (in general) link a DLL without the matching link library. Under some circumstances MinGW will allow you to directly link against a DLL but that is not portable behaviour.