Crosscompiling my Linux QT Project with MXE fails. Library not found - c++

I have a QT5 Project on Linux using taglib. It compiles fine inside QtCreator and runs flawless under Linux.
Now I want to Crosscompile the code using MXE. I've downloaded and "installed" MXE according the docs. I did a "make" for making all libraries crosscompiled. I also set my PATH as described in the docs.
the qmake run makes no errors, but when i "make" the project, the compiler complains:
./tagprocessortaglib.h:12:21: fatal error: fileref.h: No such file or directory
#include <fileref.h>
^
compilation terminated.
fileref.h is one of the library headers used by taglib, its furthermore the first of 3 includes of that lib.
In my .pro file, this two lines were added by QtCreator as i included the library for linux:
unix: CONFIG += link_pkgconfig
unix: PKGCONFIG += taglib
Are there any configurations to do for the library that I've missed? Any help is welcome! Thanks in advance!
Solved the issue:
I applied the Solution posted here: Compiling QT project for win32 target on Linux PC with larmadillo
and added the path to the library, this works for the MXR compiler run, but i have to remove it before native compiler runs.

Related

Qwt version conflict QTCREATOR

I'm having trouble deploying .exe generated with QtCreator on Ubuntu 14.04. I got several versions of qwt installed (and i need those, one compiled with qt4 the other with qt5).
Problem is, i don't know why but Qt seems to link the wrong version of qwt to my .exe whatever i do .. When i use LDD on my .exe, it always show /usr/lib/libqwt.so.6. Thing is i'm linking the version i need in my .pro like this :
LIBS += -L/usr/local/qwt-6.1.2/lib/ -lqwt
And in project configuration i set LD_LIBRARY_PATH with /usr/local/qwt-6.1.2/lib
Still my .exe doesn't link to the right library.
Any idea why and how to fix this ? It causes segmentation fault on launch of course as my program is compiled with qt5 and not qt4..
Thanks in advance
You can try adding a runtime path to the linker flags. In your .pro file you can add the following line (Its probably worth printing your QMAKE_LFLAGS in your pro file as well):
QMAKE_LFLAGS += "-Wl,-rpath,/usr/local/qwt-6.1.2/lib/"
message ("QMAKE_LFLAGS = $$QMAKE_LFLAGS")
Re-compile and then run ldd again. During runtime also ldd) your program should now point to this location first.
Note
This is assuming that you are using a gnu compiler!
I sorted out my problem, seems like settings the environment variables in QtCreator is not enough. You have to do it in the terminal aswell before launching the .exe, that was my bad.
Just had to set LD_LIBRARY_PATH correctly.

Including ffmpeg in qt project on windows causes the program to unexpectedly finish

I am trying to include ffmpeg in my qt project on windows. I am running QT4 and compiling with microsoft visual compiler 2010 on 32 bit windows 7. I am trying to include ffmpeg 2.8 which I got the dev and shared downloads from zeranoe. When I run it I get the following output:
Starting (executable path)...
The program has unexpectedly finished.
(executable path) exited with code -1073741819
I am able to produce this output with the following:
ffmpeg_test.pro:
QT += core
TARGET = ffmpeg_test
INCLUDEPATH += (ffmpeg dev path)/include
LIBS += -L(ffmpeg dev path)/lib
LIBS += -lavformat
SOURCES += main.cpp
main.cpp:
extern "C"
{
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
#include <libavformat/avformat.h>
}
int main(int argc, char *argv[])
{
av_register_all();
return 0;
}
I have put the .dll files from the ffmpeg share bin into the same folder that QT builds ffmpeg_test.exe into. I have also confirmed that they are found using dependency walker which shows a question mark when they are not in that directory and the avformat-56.dll file path when they are (the fact that the .dll files are found does not effect the output of the program).
Dependency walker does reveal that something weird is going on as there are no expected functions, but the functions found in avformat-56.dll look correct. I also have ran Dumpbin.exe /EXPORTS on avformat.lib and it also looks fine (I can post output if it would be helpful). It is worth noting that I have included this version of ffmpeg in a different application on this machine, it was not a qt project however. That project generated its make file with CMake rather than QMake and was built with Microsoft Visual C++ 2010 rather than QT Creator.
I have also included other .lib/.dll pairs in qt and they have no problems. I am noticing two differences from those pairs. First in the ffmpeg-dev lib folder instead of having only .lib files (as is the case for all my other .lib/.dll pairs) I also have a .def and a .dll.a file for each library. Second ffmpeg is a c library whereas all my other included libraries are c++.
update 3/29:
I have tried replacing the LIBS lines in my .pro with both of the following:
LIBS += (ffmpeg dev path)/lib/avformat.lib
LIBS += (ffmpeg dev path)/lib/libavformat.dll.a
Both give the same error message. I have also tried adding the following to my .pro file also with no effect.
DEFINES += __STDC_CONSTANT_MACROS
QMAKE_CXX_FLAGS += -D_STDC_CONSTANT_MACROS
Additionally I tried adding #define inline __inline to main.cpp as suggested on the ffmpeg website. Any ideas of things to try would be hugely appreciated!
update 3/31:
I have tried to start over with a new Windows build environment but the result remains unchanged with the test code above. (The new environment was able to run a hello world program).
My process for setting up this environment was to install a fresh version of 32 bit windows 7. Install Visual C++ 2010 Express from the Visual Studio 2010 Express All-in-one ISO. Install Qt 4.8.6 for 32 bit windows and Visual Studio 2010. And finally install Qt Creator 2.5.2. To set up Qt creator I went under tools->options and told it where to find the Qt 4.8.6 qmake. I downloaded the dev and shared builds for ffmpeg 2.8 from Zeranoe. I was missing stdint.h and inttypes so I downloaded them and put the files in /include/libavutil. Then I corrected any of the header files that complained from to "stdint.h" ect. I then put the dll files from ffmpeg-2.8-win32-shared/bin into the folder where qt was building ffmpeg_test ffmpeg_test-build-desktop-Qt_4_8_6__4_8_6__Release/release.
The problem is that ffmpeg was compiled with the MinGW compiler and sometimes libraries compiled with different compilers may not always be compatible. I was able to make my test program run correctly by getting the MinGW compiler and setting up Qt for MinGW. Also my version of ffmpeg did not require the changes involving stdint.h or inttypes.h. How this version of ffmpeg was able to compile using MSVC and cmake is still a mystery to me. For a path forward the question is if switching to the MinGW compiler is a option or if I need to compile ffmpeg for MSVC.

Qt-GStreamer: PKGCONFIG not found

I am pretty new to setting the Qt Creator environment in Linux.
I will cross compile this demo program to the Yocto Project i.MX6. This demo program needs to use Qt-GStreamer
in demo.pro
There is these 2 lines
CONFIG += link_pkgconfig
PKGCONFIG += Qt5GLib-2.0 Qt5GStreamer-1.0 Qt5GStreamerUi-1.0 Qt5GStreamerUtils-1.0 Qt5GStreamerQuick-1.0
at compile in the Desktop, it shows
error: Qt5GLib-2.0 development package not found
This applies to all the other packages as well.
I know that it tells me that I am missing the package for the Qt Gstreamer.
However, when I look at this thread, the answer is
export PKG_CONFIG_LIBDIR=/home/anisha/Desktop/newGSTr/qt-gstreamer-0.10.3/lib/x86_64-linux-gnu/pkgconfig
But, from what I have downloaded in Qt Binding-GStreamer qt-gstreamer-0.10.3 Does not have the lib folder inside.
I have also used cmake to work with the CMakeList.txt inside the folder but encounter Qt missing packages error.
Could someone help me on setting up those packages?

Qt iOS build does not find headers with path

I am building a working application (Mac and Linux) for iOS emulator in Qt 5.4 but when compiling the sources, compiler shows issues about header files not found. These files definitely are where they should be and the same code/pro builds without issues for desktop versions.
For example, in my code I have included:
#include <sndfile.h>
and in my .pro file I have:
LIBS += -L/usr/local/lib/ -lsndfile.1
INCLUDEPATH += /usr/local/include/
and the header file for libsndfile is definitely in /usr/local/include
I have tried adding this to .pro file
INCLUDEPATH+= $PWD
But no use, still all headers that are not directly in the same folder
as the .pro file cannot be found when compiling... What am I missing?
Is there some different way to define paths to iOS build sources?
I am able to build Qt iOS tutorial projects and run them on the emulator.
Perhaps your Makefile is outdated.
Run qmake again, after changing something in .pro file.

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.