简体   繁体   中英

QT build errors with plugin / sdk library (autodesk fbx sdk)

I have just learned to configure my VS console app to use the Autodesk fbx plugin (vs2017). I am trying now to embed it in QT creator but it does not seem to work: the project does not build because of undefined references. obviously it is no able to attach one of the sdk's components but I don't know why this is happening.

in my.pro file, I have added the following:

LIBS += "E:/misc/fbx sdk/2020.0.1/lib/vs2017/x86/release/libfbxsdk.lib"
LIBS += "E:/misc/fbx sdk/2020.0.1/lib/vx2017/x86/release/libfbxsdk.dll"

INCLUDEPATH += "E:/misc/fbx sdk/2020.0.1/include"

DEPENDPATH += "E:/misc/fbx sdk/2020.0.1/lib/vs2017/x86"

This should have added the libfbxsdk.lib runtime lib to the project, and I also referenced the.dll there but that couldn't be the issue because the error would fire at run time.. Includes should be fine because the headers are included properly as well. Do you have any idea why this might be happening?

Here are the errors: 在此处输入图像描述

Do I understand correctly that these must have been declared in the.lib? But QT still does not see them?

I finally got this working. First, my attempt at a logical explanation...

The fbx sdk package that I have downloaded is specifically for Visual Studio 2017. Additionally, I aim at 32 bit. Now, Visual Studio's native compiler is MSVC, and this is what defines the toolchain including linking, compilation etc. QT's default compiler (at least for me) is g++. I cannot give you any good explanation but that was the reason why the linker in QT has been failing: you have to compile and link the sdk with the toolchain it was designed for. That is, with MSVC compiler and, for me, 32 bit architecture.

The steps: 1. You have to install a version of QT compiled with MSVC. I installed Qt 5.12.2 MSVC 2017 32-bit (2017 because I have downloaded the SDK for VS 2017) 2. Having installed this, you have to select the appropriate toolchain in the QT creator: this can be done in kits. Go to kits and directly select there the MSVC kit. It should be available after you have installed everything from (1.). Note that other kits previously active have to be deactivated by right-clicking on them and choosing the option. The kits can be managed in the 'Projects' tab. 3. After that, you can include your paths to the project AND link the libs - statically or dynamically. If you link dynamically, you have to manage the.dll as well (I placed it in the folder with the build of the project. If you link statically, you have to link all relevant.libs - for example, I first skipped the xml.lib which has lead to linker errors again.

See my.pro includes / adds below:

INCLUDEPATH += "E:/misc/fbx sdk/2020.0.1/include"



win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../misc/fbx sdk/2020.0.1/lib/vs2017/x86/release/' -llibfbxsdk
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../../misc/fbx sdk/2020.0.1/lib/vs2017/x86/debug/' -llibfbxsdk

INCLUDEPATH += $$PWD/'../../../misc/fbx sdk/2020.0.1/lib/vs2017/x86/release'
DEPENDPATH += $$PWD/'../../../misc/fbx sdk/2020.0.1/lib/vs2017/x86/release'

I have achieved the library includes with the QT wizard: right-click on the project for that, and choose 'Add libraries'. Then choose 'External library', specify the path, and choose to link it dynamically or statically.

If you happen to have run into the same problem and have questions re/ this, feel free to drop a line in comments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM