PDA

View Full Version : create .lib using Visual Studio



pospiech
28th March 2008, 10:43
I want to use qextserialport with Visual Studio 2005. I compiled the libary but get only a .dll and .a file.

How do I have to modify the .pro file to get a .lib file?

Matthias

jpn
28th March 2008, 11:41
MSVC doesn't produce .a files, MinGW does. Could you show us the compiler output?

pospiech
28th March 2008, 11:45
MSVC doesn't produce .a files, MinGW does. Could you show us the compiler output?
No. MSVC does produce .a files, but how are these related to .lib files? mingw produces .lib
files directly.

I have no idea what the compiler output should contain but here it is:


E:\Daten\Dev\Qt\Bibliotheken\qextserialport-1.1\qextserialport>qmake

E:\Daten\Dev\Qt\Bibliotheken\qextserialport-1.1\qextserialport>nmake

Microsoft (R) Program Maintenance Utility, Version 8.00.50727.762
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

cl -c -nologo -Zm200 -Zc:wchar_t- -O2 -MD -W3 -w34100 -w34189 -GR -EHsc
-DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_TTY_WIN_ -DQT_THREAD_SUPPORT -DQT_DL
L -DQT_NO_DEBUG -DQT_CORE_LIB -I"c:\Programme\Qt4\include\QtCore" -I"c:\Programm
e\Qt4\include\QtCore" -I"c:\Programme\Qt4\include" -I"c:\Programme\Qt4\include\A
ctiveQt" -I"build\moc" -I"." -I"c:\Programme\Qt4\mkspecs\default" -Fobuild\obj\
@C:\DOKUME~1\Matthias\LOKALE~1\Temp\nm293.tmp
qextserialbase.cpp
qextserialport.cpp
win_qextserialport.cpp
.\win_qextserialport.cpp(343) : warning C4100: 'c': Unreferenzierter formaler Pa
rameter
Code wird generiert...
link /LIBPATH:"c:\Programme\Qt4\lib" /NOLOGO /INCREMENTAL:NO /DLL /MANIF
ESTFILE:"build/obj\qextserialport.intermediate.manifest" /OUT:build\qextserialpo
rt.dll @C:\DOKUME~1\Matthias\LOKALE~1\Temp\nm294.tmp
mt.exe -nologo -manifest "build\obj\qextserialport.intermediate.manifest
" -outputresource:build\qextserialport.dll;2

Matthias

ChristianEhrlicher
28th March 2008, 12:03
.lib -> static lib msvc
.d -> static lib mingw

.a or .lib -> static import lib (mingw/msvc)
.dll -> shared lib

so you either have to create your lib as static lib or make sure to export (search forum for Q_DECL_EXPORT / Q_DECL_IMPORT) to functions/classes you want to access from outside the lib.

pospiech
28th March 2008, 12:47
.lib -> static lib msvc
.d -> static lib mingw

.a or .lib -> static import lib (mingw/msvc)
.dll -> shared lib

what is the difference between "static import" and "static lib" ?

I have the .a lib. But the code request the .lib file. Can I simply rename it?



so you either have to create your lib as static lib

The main question of this thread was the "how do I do this".



or make sure to export (search forum for Q_DECL_EXPORT / Q_DECL_IMPORT) to functions/classes you want to access from outside the lib.
This implies to change the whole code if the lib, doesn't it?
This is beyond the work I want to spent on the code of an 3dparty libary.

Matthias

ChristianEhrlicher
28th March 2008, 12:58
When you compile a library with msvc you will never ever get a .a lib
A static import lib contains only stubs to the functions in the shared lib. It's needed by the linker to resolve them.

When you use qmake -> RTM (http://doc.trolltech.com/4.3/qmake-variable-reference.html#config) or just compile the code into your app instead creating an own lib.

pospiech
28th March 2008, 13:31
When you compile a library with msvc you will never ever get a .a lib
You are correct. I had an old .a file from a mingw compilation

I now added 'staticlib' to CONFIG and recieve a .lib file now.
Thanks,

Matthias