Archived Forum Post

Index of archived forum posts

Question:

Problem with Chilkat with Qt, unresolved external symbols

Nov 14 '12 at 17:39

I'm developing a program on Windows using the Qt cross-platform tool, with Qt Creator and VS as the compiler/linker. I have the CC++ Chilkat libraries and I created a test program to see if I can use Chilkat within a Qt program.

In my Qt .pro file, I'm using the dll version of the libraries, as shown below, however I'm getting 12 unresolved external symbol errors, for example:

ChilkatDbgDll.lib(Psdk.obj):-1: error: LNK2019: unresolved external symbol impGetUserNameA@8 referenced in function "public: static void __cdecl Psdk::getUsername(class chilkat::StringBuffer &)" (?getUsername@Psdk@@SAXAAVStringBuffer@chilkat@@@Z)

Has anyone been able to integrate Chilkat with Qt?

Thanks.

testTar.pro:

SOURCES += main.cpp win32:CONFIG(release, debug|release): LIBS += -L$$PWD/Chilkat/libs/release/ -lChilkatRelDll else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/Chilkat/libs/debug/ -lChilkatDbgDll INCLUDEPATH += $$PWD/Chilkat/include DEPENDPATH += $$PWD/Chilkat/include


Answer

The Chilkat internal code is calling the Windows "GetUserName" Platform SDK function. (see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724432%28v=vs.85%29.aspx )

Platform SDK functions having string arguments usually have an ANSI version ending in "A" (GetUserNameA) and a Unicode version ending in "W" (GetUsernameW). In the case above, the unresolved external is "GetUserNameA". The question now becomes: "How do I link a C++ program against the Microsoft VC++ runtime libs?" Unfortunately, I don't have the experience with Qt to know the answer.


Answer

For those looking to use Chilkat DLL libraries in a Qt program with the standard ANSI components, it can be done by adding the following to the project file (.pro); note that I separated the release and debug versions in their own folders. Also, I placed the include and lib files under my project ($$PWD).

Note however the UNICODE components will not work with the pre-compiled versions of Qt for Windows. This is due to the fact that Digia does not set the wchar_t as a built-in type (i.e. /Zc:wchar_t-). Since I'm almost done with my project, I didn't want to recompile Qt, therefore I created a couple command line programs (for tarGZing and untarGZing files) and called them with a QProcess instead.

I hope this will help others.

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/Chilkat/libs/release/ -lChilkatRelDll

else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/Chilkat/libs/debug/ -lChilkatDbgDll

win32:LIBS += -L"C:/Program Files/Microsoft SDKs/Windows/v6.1/Lib/" -lAdvapi32 -lws2_32 -lcrypt32 -lrpcrt4 -ldnsapi -lwininet

win32:INCLUDEPATH += $$PWD/Chilkat/include

win32:DEPENDPATH += $$PWD/Chilkat/include