1

I want to buy license for QR codes read and generating from Leadtools but first I want to try their demo tools. I'm using MSVC 2013 x64 compiler. I think I did everything as follows in documentation:

  1. Copied all dll's to my project directory (where build and release folder are located)
  2. Copied Include and Lib folders to my project directory and add this lines to .pro file.

LIBS += -L$$PWD/Lib/CDLLVC12/x64/ -lLtkrn_x INCLUDEPATH += $$PWD/Include PRE_TARGETDEPS += $$PWD/Bin/CDLLVC12/x64/Ltkrnx.dll

  1. include and #define LTV19_CONFIG, here is my code:

    #define LTV19_CONFIG
    #include <iostream>
    #include <Ltkrn.h>
    #include <ClassLib/LtWrappr.h>
    using namespace std;
    
    int main( ){
    if( LT_KRN == LBase::LoadLibraries( LT_KRN, LT_DLGKRN))
        cout << "success" << endl;
    
    L_TCHAR licenseFile[] = L"d:\\temp\\TestLic.lic";
    L_TCHAR key[] = L"xyz123abc";
    LSettings::SetLicenseFile( licenseFile, key);
    
    return 0;
    }
    
  2. Ask leadtools support, but they don't have much experience with working with QT...

When I tries to build application I get following errors:

    LNK2019: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl LBase::LoadLibraries(unsigned int,unsigned int)" (__imp_?LoadLibraries@LBase@@SAIII@Z) referenced in function main
    LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl LSettings::SetLicenseFile(wchar_t *,wchar_t *)" (__imp_?SetLicenseFile@LSettings@@SAHPEA_W0@Z) referenced in function main

For following methods documentation says that I only need one dll/lib package (ltkrn). How to fix it? Still I don't get differences between static and dynamic linkage and this could be the problem.

4

1 回答 1

0

如果您的链接器接受 64 位 Ltkrn_x.lib,这表明问题与您使用 LEADTOOLS 的方式有关,而不是与 QT 有关。这就是为什么我将其发布为建议的回复而不是注释。
在 C++ 中使用 LEADTOOLS 进行编程时,通常使用 2 组标头和 LIB 之一:

  1. 要么包含 L_Bitmap.H(或包含 LtKrn.H 的一堆头文件)并使用 Ltkrn_x、Ltfil_x 等 LIB 文件集。

  2. 或者包括 ClassLib\LtWrappr.h 并仅使用一个 LIB 文件,在您的情况下是 Ltwvc_x.lib

尽管在这两种情况下您都将使用许多相同的 DLL 文件,例如 Ltfilx.dll 和 Ltkrnx.dll,但在使用 LtWrapper 时您不需要它们的 LIB 文件的原因是 ClassLibrary 会延迟(按需)加载这些文件DLL 在运行时而不是在链接时引用它们的 LIB 文件。

这也是为什么您需要在代码使用这些 DLL 之前调用 LBase::LoadLibraries() 并指定所需的 DLL。
所以总结一下,请试试这个:

  • 删除#include "Ltkrn.h"

  • 删除对 Ltkrn_x.lib 的链接器引用(尽管您需要 DLL)

  • 保留#include "ClassLib/LtWrappr.h"

  • 添加对 Ltwvc_x.lib 的链接器引用

于 2015-05-07T22:28:58.537 回答