QT 5.8 - Cross compiling from Mac target Linux - c++

I have a QT project that was originally developed for Mac and now we are porting it on Linux.
What I would like to do is to build (and Deploy) the project across both platform (Mac and Linux) using the Mac, possibly from QT Creator.
For this reason I need to configure QT Creator (creating a new Kit) adding a Linux Toolchain. I found the appropriate toolchain here:
Linux tool chain for Mac
Unfortunately that toolchain not contains the QT Framework. So I need to cross compile QT from the Mac using the Linux toolchain above.
To cross compile QT I tried this configure parameters (~/gcc-4.8.1-for-linux64/x86_64-pc-linux/ is the Linux toolchain path):
./configure -prefix ~/gcc-4.8.1-for-linux64/qt5.5.0 -xplatform linux-g++ -device-option CROSS_COMPILE=~/gcc-4.8.1-for-linux64/x86_64-pc-linux/ -opensource -confirm-license -no-opengl -make libs -make tools -nomake examples -nomake tests -sysroot ~/gcc-4.8.1-for-linux64/
Unfortunately the command miserably fails with this error
Note: QtSerialBus: Cannot find linux/can.h and linux/can/raw.h Linux headers for socketCAN support.
Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.
WARNING: No QPA platform plugin enabled! This will
produce a Qt that cannot run GUI applications.
The dependencies needed for xcb to build are listed in
src/plugins/platforms/xcb/README
ERROR: detected a std::atomic implementation that fails for function pointers.
Please apply the patch corresponding to your Standard Library vendor, found in
qtbase/config.tests/common/atomicfptr
Any thought?
Cheers

Related

Cross-compile Qt for specific arm target from 64bits Linux

I'm currently trying to compile a project and port it to a 32bit target deploying a Linux based system.
My host machine runs x86_64 Debian Stretch and my target is an Atmel SAMA5d2 running a custom Linux.
My cross toolchain is generated from buildroot.
At the moment I'm able to cross compile applications for the target using the buildroot generated toolchain. However, I would like to integrate Qt and build Qt apps for the target.
To be able to build my applications for the targetted platform I need to compile Qt for my target.
To do so I have to tell Qt to use the buildroot toolchain instead of the native one.
From what I found I either have to provide -device <device> --device-option CROSS_COMPILE=$TOOLCHAIN_PATH or -xplatform <mkspec> to configure Qt with the expected toolchain.
Obviously my target is not in the device list under qtbase/mkspecs/devices so I think the best solution is to create a mkspec for my target.
My command should look like this :
./configure -xplatform <my_mkspec> -embedded arm -prefix <customQtPath>
However I'm kinda lost and I don't know how to do it only from documentation and what I found by googling my problem.
Also do I need to specify the target is 32bit as armv7 is only 32bits?
I would be glad to have some help on this.
Thanks.
Your assumptions are correct. You can read similar specs and create your own, those are pretty simple. For instance Pi2 is an armv7 device, you can start from this qmake.conf. Then, pass to configure:
-device <given_name> -device-option CROSS_COMPILE=<path_and_prefix> -sysroot <your_sysroot>
just change paths, tune cflags if needed etc... Then follow build tutorials.

Unable to build qt from the source (for the OpenCV)

I am trying to install OpenCV on my Windows 10 following this guide. In order to install it with my own-build libraries, I need to build qt from the source. I downloaded the latest sources from the qt page (5.6.0, I didn't find any other sources availible), but after typing
configure -release -no-webkit -no-phonon -no-phonon-backend -no-script - no-scripttools
-no-qt3support -no-multimedia -no-ltcg
In VS2013/VS2015 command promt, I got an error:
Unknown option -no-webkit
Unable to detect the platform from environment. Use -platform command line
argument or set the QMAKESPEC environment variable and run configure again.
I have an option just to make everything. But I have to specify the platform. I didn't find how to do it.
Can anyone give me a hint, how to install qt correctly? I have VS 2013 and 2015. I am going to use VS2013, since VS2015 is not supported by CUDA toolkit 7.5.
Thanks,
Mikhail
Update: I was able to begin the installation process by typing configure -platform win32-msvc2013 -mp -release (although I have win64), but after accepting the licence, I got an error: execute: File or path was not found(nmake). Screenshot is attached
have you tried with the MSVC2013 command prompt:
configure -platform win32-msvc2013 -mp -release -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-qt3support -no-multimedia -no-ltcg
then type:
nmake
Update:
Also, before that, try adding the path to your Qt source code, with the bin folder, to the PATH variable of windows.
For instance, if your PATH variable is currently set to %SystemRoot%\system32;%SystemRoot%; and your Qt source code is at C:\dev\Qt-5.6\
then set your PATH variable to %SystemRoot%\system32;%SystemRoot%;C:\dev\Qt-5.6;C:\dev\Qt-5.6\bin
This website explains how to change the PATH variable on Windows, in case you're not familiar with it: http://www.computerhope.com/issues/ch000549.htm
Then restart the MSVC2013 Command Prompt, or Windows. I believe that should help the compilation. Let me know if it solves your problem.
What about this:
-skip qtwebkit
Excluding a Qt Submodule
Configure's -skip option allows certain Qt submodules to be excluded from the Qt build. These submodules correspond to the Git submodules in the standard Qt 5 repository. Note that many packages contain multiple Qt modules. For example, to exclude Qt NFC and Qt Bluetooth from the Qt build, provide -skip qtconnectivity as the argument to configure.

Qt5WebKit module library is not built, when most others are built

I am building the Qt opensource on Ubuntu Linux. The target platform is the BeagleBone Black. Build process itself runs successfully, but I do not find the libQt5Webkit.so in the /lib/ directory.
Build and target platform details:
Host: Ubuntu Linux 15.04 x64
Target Hardware: BeagleBone Black
Target OS: Angstrom Linux
Toolchain: arm-linux-gnueabi
Qt Version: 5.4.2
Build Command: ./configure -v -opensource -confirm-license -prefix
/home/developer/projects/dependencies/qt/qt-5.4.2_Angstrom_BBB
-device linux-beagleboard_angstrom-g++
I am not disabling any modules as evident from the ./configure command options.
I have the following questions:
Is the building of the QtWebKit module disabled / removed?
How do I enable building the QtWebKit module project?
How can I cross-compile only the QtWebKit project?
If more information is required, I will provide.
Thanks.

configure:file not found while static linking Qt 5.4 project in linux

I have an application which i want to deploy using static linking.I am using Qt 5.4 and ubuntu.I learnt that to deploy my application i have to bulid qt statically using the following code
cd /path/to/Qt
./configure -static -prefix /path/to/Qt <other parameters>
make sub-src
i have Qt installed in home/Qt5.4.0
When i run the above code it says that
configure:no such file
When i check the Qt directory there is indeed no configure file.I could only find
configure.prf
in Qt5.4.0/5.4/gcc_64/mkspecs/features/
this may be novice but how should i deploy my application now?
I can describe steps I did for Windows.
Configure Qt static build. For this download source code and in e.g. d:\Qt\5.4\Src\qtbase\mkspecs\win32-g++\qmake.conf change line QMAKE_LFLAGS = to QMAKE_LFLAGS = -static -static-libgcc. Then save and exit.
Make Qt. In console (preferably one from Qt folder like Qt 5.4 for Desktop (MinGW 4.9 32 bit) go to d:\Qt\5.4\Src\qtbase, change environment variables
set LIB=
set INCLUDE=
SET QTDIR=D:\Qt\5.4\Src\qtbase
SET QMAKESPEC=win32-g++
SET PATH=C:\Python34;c:\Strawberry\perl\bin;d:\Qt\Tools\mingw491_32\bin;d:\Qt\5.4\Src\qtbase\bin;%PATH%
Start configuration (accept license) and make.
configure.exe -debug-and-release -opensource -c++11 -static -opengl desktop -no-angle -no-vcproj -nomake examples -nomake demos
mingw32-make.exe (This can take time)
Add kit in Qt Options (Build & Run tab)
Chose new kit for the project. Should work.

Qt 4.8.2 With GCC 4.7.0.1 Keeps Crashing

I've downloaded Qt 4.8.2 library, Qt Creator 2.5.2, and manually installed MingW with w32api version 3.13 and GCC/g++ version 4.7.0.1. My OS is Windows 7 Ultimate x64.
I can create a sample "Plain C++ project" in Qt Creator; compile and run that console application using g++ without any issue.
But I cannot run a Qt application. I used Qt Creator, created a dummy Qt Application using Creator's "Qt Gui Application" template. The project can be compiled successfully, without any error or warning. But the binary keeps crashing when I try to run (both from Qt Creator and Windows Explorer) it. Both debug and release builds crash. It crashes even before showing main window.
MingW is installed in C:\MingW and C:\MingW\bin is in PATH. Qt is installed in C:\Qt\4.8.2 and C:\Qt\4.8.2\bin is in PATH.
I analyzed generated exe of the Qt Gui Application output with Dependency Walker and found that it found all required DLLs:
c:\windows\system32\KERNEL32.DLL
c:\windows\system32\MSVCRT.DLL
c:\mingw\bin\LIBGCC_S_DW2-1.DLL
c:\mingw\bin\LIBSTDC++-6.DLL
c:\qt\4.8.2\bin\QTCORE4.DLL
c:\qt\4.8.2\bin\QTGUI4.DLL
So, what's causing the runtime crash?
EDIT
I also tried Qt's example projects: 2dpainting and addressbook - both crashed when they were launched.
You should build Qt with the MinGW compiler you're using to build your application. GCC is generally less sensitive to binary compatibility issues than MSVC is, but Qt is a big, complex framework library. If anything would expose those kinds of issues, Qt would probably be on the short list.
Building Qt is pretty straightforward, but it takes a lot of time and there always seems to be two or three patches I need to make to get things to build successfully.
The last time I built Qt (4.7.3) with MinGW, I had to make the following patches - I'm not sure whether they will still apply to Qt 4.8:
make sure not to enable C++11 mode in the compiler - there are several macros with concatenated string literals that break under the new C++11 extended literal syntax
there is a problem with how some distributions of MinGW incorporate the Microsoft extensions to float.h - I had to sometimes had to add the line:
#include_next <float.h>
to the end of the MinGW-specific float.h so the generic GCC float.h would get processed properly. I had to do this for nuwen 4.7.0 lib/gcc/i686-pc-mingw32/4.7.0/include/float.h and TDM 4.6.1 32-bit distro lib/gcc/mingw32/4.6.1/include/float.h (the 64-bit distro of TDM didn't need this patch).
patch qmake\Makefile.win32-g++ and qmake\Makefile.win32-g++-sh to remove the -static-libstdc++ option that GCC doesn't recognize (and now errors out on instead of ignores)
patch mkspecs/win32-g++/qmake.conf to move the -Wl, in the QMAKE_LFLAGS_EXCEPTIONS_ON macro to its proper place in QMAKE_FLAGS:
QMAKE_LFLAGS = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
copy make.exe to mingw32-make.exe in MinGW's bin directory if there's not already a mingw32-make.exe
Then building Qt consists of:
set QTDIR=<location of Qt source directory> # where configure.exe is
set PATH=%QTDIR%\bin;c:\MinGW\bin;%PATH%
set INCLUDE=
set LIB=
cd %QTDIR%
mingw32-make confclean # (this should fail the first time, since there's nothing to clean)
configure.exe -opensource -debug-and-release -nomake examples -nomake demos -nomake tests -platform win32-g++ # and accept the GPL license
mingw32-make
This takes a while... hopefully nothing else will need patching.
I also got this problem. I'm a Qt n00b and tought, when installing Qt-libraries, that "well I already have Mingw installed so I skip installing the Mingw that comes with Qt". That gave me prolems. When installing mingw that came with Qt everything worked ok.
So my advice to anyone googling to this question (like I did) is to instead of using your already installed Mingw, install the one with Qt and use that (otherwise you have to build the Qt libraries within your Mingw, like the answer from Michael Burr)