login about faq

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

asked Nov 09 '12 at 13:28

concord's gravatar image

concord
16225


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.

link

answered Nov 12 '12 at 08:30

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Thanks, I assumed that it was coming from your lib and not a Windows lib.

The ANSI version works fine when I added -ladvapi32. However, I need to use the Unicode version of tar. When I change the include header from CkTar.h to CkTarw.h and Cktar to CktarW tar; I get an unresolved when I call any of the functions, as shown below. Any ideas? Thanks.

tar.UnlockComponent(L"XXXXXXXXXXXXX");

main.obj:-1: error: LNK2019: unresolved external symbol "public: bool __thiscall CkTarW::UnlockComponent(unsigned short const *)" (?UnlockComponent@CkTarW@@QAE_NPBG@Z) referenced in function _main

(Nov 13 '12 at 10:13) concord

This unresolved probably has to do with how "wchar_t" is handled. In Visual Studio, there is a Project Property under C/C++ --> Language for "Treat wchar_t as a built-in type". The Chilkat C++ libs are compiled with this setting as "Yes". If your app is not treating wchar_t as a built-in type, then it's assuming "unsigned short", and there's a type mismatch. I suspect this is the problem.

(Nov 13 '12 at 10:23) chilkat ♦♦

Ah, yes, I did a google search and found other people complaining that Qt is compiled with it turned off. I tried adding to the .pro file (/Zc:wchar_t), but still had the same issue. I'll contact Qt to see if there's anything that can be done. Thanks.

(Nov 13 '12 at 11:11) concord

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

link

answered Nov 14 '12 at 17:37

concord's gravatar image

concord
16225

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×32
×2

Asked: Nov 09 '12 at 13:28

Seen: 6,199 times

Last updated: Nov 14 '12 at 17:39

powered by OSQA