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

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.

Related

error: LNK1104: cannot open file 'libumfpack.dlld.lib' in QT Creator

I having been struggling with an error for several days now but with no luck to find the correct solution. I'm trying to use the UMFPack library installed with cygwin on windows in a c++ application I'm developing on QT Creator.
I added the library by going to my project-> right click -> Add Library... Library Adding Forum
In the Library File I pointed to : /cygwin/lib/libumfpack.dll.a
In Include Path I pointed to : /cygwin/usr/include/suitesparse
Linkage type : Dynamic
The QTCreator added the link automatically as follows :
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../cygwin64/lib/ -llibumfpack.dll
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../cygwin64/lib/ -llibumfpack.dlld
else:unix: LIBS += -L$$PWD/../../../../cygwin64/lib/ -llibumfpack.dll
INCLUDEPATH += $$PWD/../../../../cygwin64/usr/include/suitesparse
DEPENDPATH += $$PWD/../../../../cygwin64/usr/include/suitesparse
However, when I build the project the following error is displayed:
**:-1: error: LNK1104: cannot open file 'libumfpack.dlld.lib'**
Can anyone point me to the correct direction?
You are mixing MSVC and gcc.
You are using MSVC which expects import libraries to end in ".lib". While the library was generated by gcc (MinGW or Cygwin) which expects import libraries to end in ".a".
But just renaming will not solve your problem as the format is not the same. At least you need to generate a ".lib" from your the ".dll". However this will only work if the library API is in pure C, as C++ name mangling will prevent you to use C++ symbols across 2 binaries built with different compilers.
If the API is C++ you need to either find a library built with MSVC or change your compiler to use the same the library was built with.

How make Qt app not append D when trying to linking to my library

I have a Qt app & a few libraries built using .pro file in each. When building for windows, I want to build my app in debug mode & hence link to debug versions of my libraries. All if this here is static linking. I build the debug versions of my libraries. All fine. pdb files also generated in the build folder.
But when I build my app it complains of the following error appending a D to my library name !!!
error: LNK1104: cannot open file 'MyLibD.lib'
It should be looking for MyLib.lib not MyLibD.lib as I specifying below in MyApp.pro. Following is how I link to my library in MyApp.pro
LIBS += -L$$MyLib_build_location -lMyLib
Release:win32: LIBS += -L$$MyLib_build_location -lMyLib
Debug:win32: LIBS += -L$$MyLib_build_location -lMyLib
INCLUDEPATH += $$MyLib_include_location/
DEPENDPATH += $$MyLib_include_location/
unix:PRE_TARGETDEPS += $$MyLib_build_location/MyLib.a
Release:win32:PRE_TARGETDEPS += $$MyLib_build_location/MyLib.lib
Debug:win32:PRE_TARGETDEPS += $$MyLib_build_location/MyLib.lib
Why is windows OS expecting my library to be appended with D when in debug mode ? How can make Qt look for the same name as TARGET specified in library´s .pro ?
Note that, I am using Visual Studio 2015 Community edition along Qt Creator for the C++ compiler
You're building a debug build of your application: it needs to link with debug libraries! You need to fix the project files for the libraries so that the debug build is available, with the correct prefix.
Also note that the manual tweaking of build locations is usually counterproductive.

Using SFML with Qt creator?

I've recently began learning the SFML API for learning purposes but it seems to me like it only supports Codeblocks IDE and Visual Studio. I dislike both IDEs for my own ideas and I like the IDE that comes with Qt instead.
Is it possible to basically use SFML within the Qt creator?
EDIT:
I know some of you may some day find this on google, after struggling for 8 days to set up sfml to work with qt creator I've found the sollution:
step 1: Download the VS version of SFML from the website (NOT codeblocks version)
step 2: copy the DLLs from C:\SFML-1.6\lib to your system32 directory
step 3: open qt creator, make a plain C++ project, open your .pro file and add these lines:
INCLUDEPATH += C:\SFML-1.6\include
LIBS += C:\SFML-1.6\lib\sfml-system.lib \
C:\SFML-1.6\lib\sfml-window.lib \
C:\SFML-1.6\lib\sfml-graphics.lib \
C:\SFML-1.6\lib\sfml-audio.lib \
C:\SFML-1.6\lib\sfml-network.lib
And you're done!
Short answer: Yes.
The IDE doesn't really matter all that much. The compiler does. Depending on the compiler used by Qt Creator, you download the appropriate SFML package. Most likely the MinGW based version will work just fine with your default install of Qt Creator. (I believe that relies on MinGW?)
All that then remains to be done is place SFML in its own directory and making sure that you set up the correct paths in your Qt Creator project. There's not much to it really.
I know i'm a little bit late to the party but:
SFML library is 100% compatible with qtcreator especially qmake.
Download SFML from https://www.sfml-dev.org/download/sfml/2.5.1/ . Bottom right minGW (You most likely have mingw on qt)
Place it somewhere you will know where it is. I usually put it in "C:/SFML-2.5.1"
There's a simple copy pasta you can add to your qmake '.pro' file:
INCLUDEPATH += "C:/SFML-2.5.1/include"
LIBS += -L"C:/SFML-2.5.1/lib"
CONFIG(debug, debug|release){
LIBS += -lsfml-audio-d -lsfml-graphics-d -lsfml-network-d -lsfml-system-d -lsfml-window-d
} else {
LIBS += -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-system -lsfml-window
}
The 'INCLUDEPATH' includes the headers into your project where as the 'LIBS' adds the library file path. The 'CONFIG()' tells qt if you're running DEBUG mode or RELEASE mode.
This copy pasta is fun because you can also configure a custom wizard and make qt dropdown show you a 'create new sfml c++' project by just editing its profile with this.
Last but not least are the needed .dll files from 'C:\SFML-2.5.1\bin' You can add only the ones you need or all of them if you're lazy. You can do this by copying them into the BUILD folder of your project. (to find the build folder by default its a folder in the same path as your project folder with the name of your project prefixed by 'build-' or 'release-')
Make simple c++ project
Choose QMake build system
in project.pro add 2 lines:
CONFIG += link_pkgconfig
PKGCONFIG += sfml-all

How to Link Imagemagick library to Qt(windows)

I have developed an application with mac and for one month now, Im trying to link Qt with ImageMagick on windows.
I just cant find the files and the version of Imagemagick library that need to be linked to Qt in order to make my application work on windows.
I have tried most of the libraries from here
Thats the only thing I added to the .pro file while I was developing on a mac
INCLUDEPATH += . /opt/local/include/ImageMagick
LIBS += -L/opt/local/lib -lMagick++
When I add this to my .pro
INCLUDEPATH += C:/im6/include/ImageMagick
LIBS += C:/im6/lib/libMagickWand.a
LIBS += C:/im6/lib/libMagick++.a
LIBS += C:/im6/lib/libMagickCore.a
C:/im6/lib/libMagick++.a
I get 10.000 + simmilar errors to that:
(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.6-0/Magick++/lib/Image.cpp:4157: undefined reference to `__gxx_personality_sj0'
C:/im6/lib/libMagick++.a(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.6-0/Magick++/lib/Image.cpp:4157: undefined reference to `_Unwind_SjLj_Register'
C:/im6/lib/libMagick++.a(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.6-0/Magick++/lib/Image.cpp:4178: undefined reference to `_Unwind_SjLj_Unregister'
For more errors check this
Has anyone tried to build and deploy an ImageMagick application using qt on windows ?
Which files do I need to link while building and which files while deploying ?
The error message tells me that you
use mingw (with qtcreator). Your
library might not work with this
compiler. You need a mingw version
of the library, probably named
libmagick.a.
LIBS += -L$$quote(c:/Program Files/ImageMagick-6.6.5-Q16/lib) -lmagick
(see the documentation about qmake Project Files
I have found that the minGW tool set is very much treated as a "stepchild" in the Windows world. I know it doesn't help your particular situation, but we had numerous problems with third-party libs while trying to use Qt with minGW. There were always extra steps, or non-existent build instructions that we had to figure out or tweak.
Once we switched to the MSVC version, all of those problems went away. Note that this doesn't mean you have to use Visual Studio (you can still use Qt creator), it just means that the Visual Studio compiler is being used. You can get the compiler for free using the Platform SDK. If this is an option, you might save yourself a lot of pain by switching now. It's unfortunate, but that is just the current status quo, at least as we discovered.
Please go get ImageMagick source package.
I can’t give direct instructions how to work with MinGW of Qt Creator, but basically following. I prefer to use qtvars.bat that comes with binary distributions of Qt to set environment.
Open Windows cmd
Set PATH to have /path/to/mingw/bin and /path/to/qt/bin before other paths
Go to directory where you have extracted ImageMagick source
read README, INSTALL and such to compile the ImageMagick (most likely just ./configure ; mingw32-make, but never be sure)
Edit your .pro file with something like LIBS += -L$$quote(/path/to/imagemagick/lib/dir) -lmagick . The lib may be in bin dir or in lib dir. See hmuelner’s answer for more information.
At this point, the configuration should be ready. Compilation at Qt Creator should work, but you can as well use this cmd windows to compile your program: go to program directory, run “qmake” and “mingw32-make”.
You cannot link against a ImageMagick++ library built with MSVC, as mingw and MSVC DLLs are incompatible for C++ libraries. You can't link a MSVC-built C++ library into a mingw project, nor vice versa. C-only libraries work fine. Also, according to this fortum thread, using builds against old mingw-versions with current mingw versions doesn't work as the exception handling changed (as you get more errors than that, I wouldn't expect that to be the only problem though). If there is no binary package for your mingw version (and I don't see any on the imagemagick website), your only option is to use a source package, as Smar suggests.
Another option of course is to install Visual Studio, download Qt for MSVC and build your project with MSVC.

linking mac framework to qt creator

I have a project that uses SystemConfiguration.Framework.
I've been using xcode, where adding the framework is quite easy, just add it to xcode project's framework. But now, I need my project to be cross platform, so I'm using QT Creator as a single IDE, for Windows and Mac. The problem is that I don't know how to tell QT Creator how to link to the systemConfiguration.framework. The header from the framework are correctly included, no problem there... just when is ending the compilation it complains that some symbols where not found, i.e, the symbols that are exported from the systemconfiguration.framework...
Does anyone knows or can help me to set up the Qt creator project to link agains that framework, please?
I assume the project itself is using Qt i.e. it is using .pro files to configure things like include paths and library/framework paths? If so then you just need to update the relevant .pro file to add the framework.
See the qmake docs for more detail. The gist of it is to add
QMAKE_LFLAGS += -F/path/to/framework/directory/
and
LIBS += -framework TheFramework
I found a solution which works with Qt 5.6 here:
https://doc.qt.io/qt-5/qmake-platform-notes.html#creating-frameworks
Using Frameworks
qmake is able to automatically generate build rules for linking
against frameworks in the standard framework directory on macOS,
located at /Library/Frameworks/.
Directories other than the standard framework directory need to be
specified to the build system, and this is achieved by appending
linker options to the LIBS variable, as shown in the following
example:
LIBS += -F/path/to/framework/directory/
The framework itself is linked in by appending the -framework options and the > name of the framework to the LIBS variable:
LIBS += -framework TheFramework