Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QtCreator on Windows to Cross Compile for Linux ARM with CodeSourcery Toolchain
I have Qt Creator installed on my Windows 7 machine and my target is an OMAP3 Embedded Linux board. I downloaded the target toolchain, Sourcery-G++ Lite for Windows, and also installed MinGW ( http://www.mingw.org/ ) on my Windows Machine. In QT Creator I added the CodeSourcery toolchain as a 'Manual' toolchain. Then, I tried to build the demo Qt App 'analogclock' using this toolchain by editing 'Build Settings' under 'Projects' for the 'analogclock' demo app. But the toolchain is not available here under Build Settings.
How can I achieve building this demo app, or any Qt app, from Qt Creator using the Code Sourcery Toolchain in the Build Options? I absolutely must use Windows to accomplish this ( cannot use Linux VM... ).
I believe it may have to do with building the Qt library for the target but am not sure if that is true or how to do that on Windows. I greatly appreciate your help and insight.
You've got to setup the toolchain manually. Have a look at "this":http://doc.qt.nokia.com/qtcreator-2.4/creator-tool-chains.html.
Additionally you have to provide your own mkspec. Have a look at the mkpecs folder in the Qt installation, copy an appropriate folder and try to adapt the lines until they fit your needs.
If you do not have cross-built Qt libs already available you have to build Qt using the new Toolchain. I do not know, if the libs currently support the building with this kind of cross-toolchain. But give it a try. Most possbile way I've figured out is to go via Windows cmd.exe. Once cd'ed into the sourcefolder of Qt you'd like to "configure":http://doc.qt.nokia.com/4.7-snapshot/configure-options.html the tree and build it with the toolchain (use a separate build folder so you can sweep faulty builds away easily).
When configuring Qt you have to provide -platform win32-g++ and -xplatform win32-g++-cs. The last argument is the name of your provided mkspec for the cross CodeSourcery. The name of this mkspec has to start with "win32-g++", otherwise the build stop somewhere in the forest because of makefile issues. Building a "real" cross Qt has some issues, i.e. how the host qmake will be built so be prepared for a nice and occupying learning curve...
Hmm, who the hell forces you to absolutely stick to W? ;-)
Thanks for the reply. I am trying to build Qt 4.8 with the codesourcery toolchain.
I'm following these steps:
When I get to step 5 which is:
Open a Qt Command Prompt from the Windows Start menu, and navigate to the Qt 4.8 checkout, then do:
C:\Dev\qt-4.8-src\tools\configure>qmake && nmake
(replace nmake with mingw32-make if Qt was built for MinGW)
I get multiple errors complaining that it can't find certain '/src/corelib/'*.h files and various other files. I've tried setting the QT_DIR, PATH, and QT_BUILD_TREE but to no avail...
With my own directory of the Qt source cloned, how can I set the environment so I can just do a qmake && mingw32-make to rebuild qmake and configure?
Ahh, ok. There is a patched version of configure.exe. Well, in this case, you should install the Qt SDK, you only need the C++ libs and the QtCreator. Since you have to build the configure.exe for your windows host, you have to have a Qt installed to be able to build this application. The opensource SDK currently comes with MinGW (32Bit) that runs on x64 as well.
In QtCreator you can open the .pro file of the configure tool as it is mentioned here (this is easier than to setup your own build environment).
bq. This will rebuild configure.exe and automatically replace the one in the top-level directory. Note that you can even use Qt Creator to rebuild configure.exe: just open C:\Dev\qt-4.8-src\tools\configure\configure.pro, then click the "Build" button and that's it.
There's an other option if you want to setup the qmake in the source tree appropriate by hand with adding the Qt/bin/qt.conf file, set the PATH environment to the mingw and the Qt/bin where the qmake is located. Choose the option that is easier for you to handle.
I recomment the SDK because there is everything set-up right after the installation. The only thing you have to do is manually setup the CodeSourcery Toolset, after you've build the libs starting with step 5.
Once you have built the new configure.exe you want to make the next steps as decribed in your link.
Nevermind - I was able to build Qt 4.8 with the CodeSourcery toolchain. Now I need to figure out how to get it in the Qt Creator IDE.
Here are my notes if it helps anyone:
Run from the top level >> configure
Then go to \tools\configure and run >> qmake && mingw32-make
Modify the makespec in mkspecs\linux-arm-gnueabi-g++ via the blog post http://c2143.blogspot.com/?view=classic
Then go to back to top level and run:
configure.exe -debug -embedded -arch arm -neon -platform win32-win32-g++ -xplatform linux-arm-gnueabi-g++
Now there is a Makefile in the top level , invoke mingw32-make
Go to movie and dinner and come back...
Woops just saw your reply - thanks for the info!
You may need a newer QtCreator like 2.5.0. There you go to "Tools" menu, "Options", "Qt4". There you'll find a Toolchain tab (afaik - don't have one here), in this tab you can set the toolchain options, including the makespec.
Would you have any insight on this problem? I've used the CodeSourcery toolchain to build the Qt 4.8 library with no error and I have the .so files in the /lib directory. Now I am trying to hook in the CodeSourcery compiler and built Qt 4.8 to Qt Creator so I can build an example app for the target board.
I read the articles you sent describing how to add a Qt version new toolchain to Qt Creator. Please see the images attached for how I've configured Qt Creator. I am using Qt Creator 2.4.1.
I could only post images here --> http://stackoverflow.com/questions/11420984/qtcreator-on-windows-to-cross-compile-for-linux-arm-with-codesourcery-toolchain
I'm getting an error without much information pasted below... Any thoughts on this or my configuration?
09:51:07: Running build steps for project analogclock...
09:51:07: Configuration unchanged, skipping qmake step.
09:51:07: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
arm-none-linux-gnueabi-g++ -c -pipe -march=armv7-a -mtune=cortex-a8 -mthumb -mfpu=neon -mfloat-abi=softfp -Wa,-mimplicit-it=thumb -O2 -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I"..\qt-4.8-src\include\QtCore" -I"..\qt-4.8-src\include\QtNetwork" -I"..\qt-4.8-src\include\QtGui" -I"..\qt-4.8-src\include" -I"." -I"c:\QtSDK\Examples\4.7\widgets\analogclock" -I"." -I"..\qt-4.8-src\mkspecs\default" -o analogclock.obj c:\QtSDK\Examples\4.7\widgets\analogclock\analogclock.cpp
arm-none-linux-gnueabi-g++ -c -pipe -march=armv7-a -mtune=cortex-a8 -mthumb -mfpu=neon -mfloat-abi=softfp -Wa,-mimplicit-it=thumb -O2 -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I"..\qt-4.8-src\include\QtCore" -I"..\qt-4.8-src\include\QtNetwork" -I"..\qt-4.8-src\include\QtGui" -I"..\qt-4.8-src\include" -I"." -I"c:\QtSDK\Examples\4.7\widgets\analogclock" -I"." -I"..\qt-4.8-src\mkspecs\default" -o main.obj c:\QtSDK\Examples\4.7\widgets\analogclock\main.cpp
C:\Users\pclass\Desktop\qt_creator_toolchain\qt-4.8-src\bin\moc.exe -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I"..\qt-4.8-src\include\QtCore" -I"..\qt-4.8-src\include\QtNetwork" -I"..\qt-4.8-src\include\QtGui" -I"..\qt-4.8-src\include" -I"." -I"c:\QtSDK\Examples\4.7\widgets\analogclock" -I"." -I"..\qt-4.8-src\mkspecs\default" c:\QtSDK\Examples\4.7\widgets\analogclock\analogclock.h -o moc_analogclock.cpp
mingw32-make.exe: *** [moc_analogclock.cpp] Error -1073741515
09:51:09: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project analogclock (target: Desktop)
When executing build step 'Make'*
- Apply the right mkspec to the toolchain now it seems to be ”..\qt-4.8-src\mkspecs\default”
- Right-click on the project and select "run qmake" or similar, so qmake will create the appropriate makefiles with the right makespec in.
- Did you add the path to mingw/bin and qt/bin to your PATH environment? moc.exe depends on two or three dlls out of that folders.
Thank you.. I added mingw to the path and then did a build and it succeeded. If I do a 'file' command on the example it gives me the following, which looks promising. Now to try it on the board.
$ file analogclock
analogclock: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
I've tried to run the executable on the board after copying it and the CodeSourcery sysroot to the board. I get the following error:
@Inconsistency detected by ld.so: dl-deps.c: 622: _dl_map_object_deps: Assertion `nlist > 1' failed!@
On an Ubuntu VM I can see the following information about the executables:
@user@ubuntu:~/exported/test_build$ readelf -l analogclock| grep "program interpreter"
[Requesting program interpreter: /CodeSourcery-sysroot/lib/ld-linux.so.3]
user@ubuntu:~/exported/test_build$ ldd analogclock
not a dynamic executable@
I've tried to investigate but am not sure what dependencies are missing. Do you have any insight here? Thanks alot.
Maybe a "bug":http://sourceware.org/bugzilla/show_bug.cgi?id=12454 in the toolchain (glibc)?
I.e. search on "Google":http://www.google.com for '_dl_map_object_deps'.
Yep, I think you are correct:
Why are you using CodeSourcery? Are there specific feratures you use? As I know there are several other IDE/embedded tools providers.
D.DeVOE last edited by
I also thought I was experiencing an issue with the glibc toolchain, but our resident toolchain guru set me straight. We quickly built up the "strace" tool and added that to our embedded system. It immediately told us there was a library dependency that was not being met (libQtOpenGL in our case). This may not be your issue, but I wanted to share how we dissected the error to identify the root cause.