Linker errors when building DLL dependent on static lib
-
All
Here is a preface - I have a C++ + Qt application, it consists of several projects and we are using MSVC 2012 to build it. Now, I'm implementing build scripts to start deploying build server. So, I started creating Qt .pro files for each and every project we have.
Now the problem - we use Crypto++ library(http://www.cryptopp.com/) which we build from source code and the output is static lib, and we have DLL which depends on cryptlib.lib.
I wrote .pro file for Cryptlib and I'm able to build it using qmake/jom
@ QT -= core gui
QMAKE_CFLAGS += /Zc:wchar_tTEMPLATE = lib TARGET = cryptlib Release:DESTDIR = ./Release Debug:DESTDIR = ./Debug CONFIG += staticlib precompile_header DEFINES += _USING_V110_SDK71_ WINVER=0x0501 WIN32 _WINDOWS _MBCS DEFINES -= UNICODE PRECOMPILED_HEADER = pch.h DEPENDPATH += . include(CryptoPP.pri)@
I wrote .pro file for my DLL - it compiles fine, but I'm getting linker errors on linkage phase. The most interesting thing is that when I build cryptlib with MSVC2012 and then build DLL with qmake - then it link OK.
What could be wrong? I checked all proj settings in MSVC projects and applied in my pro files. I checked names mangling in both libs built with MSVC and QT - mangled names look the same. Now I got stuck
@# ---------------------------------------------------- # This file is generated by the Qt Visual Studio Add-in. # ------------------------------------------------------ QT -= gui core QMAKE_CFLAGS += /Zc:wchar_t TEMPLATE = lib TARGET = PSGLicensing Release:DESTDIR = ./Release Debug:DESTDIR = ./Debug CONFIG += dll DEFINES += _AFXDLL _USING_V110_SDK71_ WIN32 _WINDOWS _WINDLL _USRDLL DLL_LIBRARY PSGLICENSING_DLL_BUILD _MBCS _VC80_UPGRADE=0x0710 DEFINES -= UNICODE PRECOMPILED_HEADER = stdafx.h DEPENDPATH += . win32:CONFIG(release, debug|release): LIBS += -L$$_PRO_FILE_PWD_/../CryptoPP/Release/ -lcryptlib else:win32:CONFIG(debug, debug|release): LIBS += -L$$_PRO_FILE_PWD_/../CryptoPP/Debug/ -lcryptlib INCLUDEPATH += $$_PRO_FILE_PWD_/../CryptoPP/ DEPENDPATH += $$_PRO_FILE_PWD_/../CryptoPP/ win32:CONFIG(release, debug|release): PRE_TARGETDEPS += $$_PRO_FILE_PWD_/../CryptoPP/Release/cryptlib.lib else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$_PRO_FILE_PWD_/../CryptoPP/Debug/cryptlib.lib include(PSGLicensing.pri)@
Here is jom output
@ C:\Qt\Qt5.2.1\Tools\QtCreator\bin\jom.exe -f Makefile.Release link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:Release\PSGLicensing.dll.embed.manifest /OUT:Release\PSGLicensing.dll @C:\Users\ANDRIY~1.GLO\AppData\Local\Temp\PSGLicensing.dll.6212.16.jom Creating library Release\PSGLicensing.lib and object Release\PSGLicensing.exp GenerateRandomBlock.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CryptoPP::CFB_CipherTemplate<class CryptoPP::AbstractPolicyHolder<class CryptoPP::CFB_CipherAbstractPolicy,class CryptoPP::CFB_ModePolicy> >::ProcessData(unsigned char *,unsigned char const *,unsigned int)" (?ProcessData@?$CFB_CipherTemplate@V?$AbstractPolicyHolder@VCFB_CipherAbstractPolicy@CryptoPP@@VCFB_ModePolicy@2@@CryptoPP@@@CryptoPP@@UAEXPAEPBEI@Z) GenerateRandomBlock.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CryptoPP::CFB_CipherTemplate<class CryptoPP::AbstractPolicyHolder<class CryptoPP::CFB_CipherAbstractPolicy,class CryptoPP::CFB_ModePolicy> >::Resynchronize(unsigned char const *,int)" (?Resynchronize@?$CFB_CipherTemplate@V?$AbstractPolicyHolder@VCFB_CipherAbstractPolicy@CryptoPP@@VCFB_ModePolicy@2@@CryptoPP@@@CryptoPP@@UAEXPBEH@Z) ... and so on Release\PSGLicensing.dll : fatal error LNK1120: 16 unresolved externals @