I'm using a x86 toolchain to build the binary in Qt Creator 3.4.0 (opensource) . There is a /usr/bin/gcc and a <path-to-toolchain>/i686-atom-linux-gnu-gcc and I want to use i686-atom-linux-gnu-gcc.
The Compiler path in Build&Run->Compilers->Compiler path correctly set to point to i686-atom-linux-gnu-gcc.
When I try to observe what commands from the Makefile are being executed, it always shows that the compiler is gcc, while it should have a compiler prefix (i686-atom-linux-gnu-gcc).
Update:
The qmake call is called with a parameter -spec linux-g++. However, on the working version, this value corresponds to mkspec in Build&Run->Qt versions->Details.
The correct kit is selected in the project options. Am I missunderstanding something or could it be a bug in Qt Creator?
The issue was doe to the wrong default -spec linux-g++ parameter. Doe to it the generated Makefiles had the default PC toolchain instead of the one selected in the Kit.
After manually adding -spec qws/linux-ptx-g++ in Projects->Additional arguments:, the generated makefile uses the correct compiler.
I got the parameter qws/linux-ptx-g++ from Options->Build&Run->Qt Versions->"your Qt version"->Details->mkspec
This is a trial and error discovered answer, I'll gladly accept another that could explain this behaviour.
Related
I have built clang 3.6 from source and followed the rather straightforward instruction on the page and installed ninja, which I confirmed can build clang-format.
My question is quite simply how to pass some flags so I can get debug symbols because I do not want to do my work (modifying clang-format) using disassembly throughout.
This can be through the standard build (which uses CMake) or ninja.
I've faced similar issue recently (I wanted to debug clang's code itself). Turned out that you need to explicitly specify -DCMAKE_BUILD_TYPE=Debug when you run CMake to generate Ninja or standard makefiles.
BTW, be careful: with this Debug option ld "ate" about 4G of my RAM to link clang binary...
The android ndk supplied by google is unable to compile call to c++11 functions such as std::to_string() and std::stoul etc. {I had tried it in r10b one from the official site}. So the suggestion in SO was to try crystax NDK. I have downloaded and placed the root folder next to the google's NDK. All I changed in my root CMakeLists.txt file was:
from:
set(PLATFORM_PREFIX "/some-path/android-ndk-r10b/platforms/android-19/arch-arm")
set(PLATFORM_FLAGS "-fPIC -Wno-psabi --sysroot=${PLATFORM_PREFIX}")
set(CMAKE_CXX_FLAGS "${PLATFORM_FLAGS} -march=armv7-a -mfloat-abi=softfp -mfpu=neon" CACHE STRING "")
To:
set(PLATFORM_PREFIX "/some-path/android-ndk-r8-crystax-1/platforms/android-14/arch-arm")
set(PLATFORM_FLAGS "-fPIC -Wno-psabi --sysroot=${PLATFORM_PREFIX}")
set(CMAKE_CXX_FLAGS "${PLATFORM_FLAGS} -march=armv7-a -mfloat-abi=softfp -mfpu=neon" CACHE STRING "")
and cmake command-line from:
cmake .. -DCMAKE_CXX_COMPILER=/some-path/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -DCMAKE_C_COMPILER=/some-path/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -DANDROID_BUILD=ON -DANDROID_NDK_ROOT=/some-path/android-ndk-r10b
To:
cmake .. -DCMAKE_CXX_COMPILER=/some-path/android-ndk-r8-crystax-1/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -DCMAKE_C_COMPILER=/some-path/android-ndk-r8-crystax-1/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -DANDROID_BUILD=ON -DANDROID_NDK_ROOT=/some-path/android-ndk-r8-crystax-1
ie., changed from normal ndk to crystax-ndk. The program was compiling fine previously till it tried to compile a file with call to std::to_string() etc. But after the change Cmake gives an error that it is unable to compile a simple test program because:
/some-path/android-ndk-r8-crystax-1/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.7/../../../../arm-linux-androideabi/bin/ld:
error: cannot find -lcrystax
I can see libcrystax.a and .so in directorie:
/some-path/android-ndk-r8-crystax-1/sources/crystax/libs/armeabi-v7a
I tried adding link_directories("path-to-above") right at the beginning of the CMakeLists.txt file too, but that didn't solve it either.
It should find it there (after i supply the --sysroot etc above) just like the normal ndk. So how should this be solved ? Any other cmake variable to be set or something ?
I don't know how your cmake-based build system works, but actually if you properly add path /some-path/android-ndk-r8-crystax-1/sources/crystax/libs/armeabi-v7a to linker search paths, it should find libcrystax and link with it successfully.
Please note that NDK have several parts separated each from other - i.e. sysroot, libcrystax, C++ library - all are separated. It is done to work with NDK build system which offer some flexibility choosing C++ standard library implementation, and NDK build system know where to find all of them. In your case this approach is not so good so I suggest you first make standalone toolchain, which contains all things assembled together. In other words, it would be classic cross-compile toolchain which contains sysroot, libcrystax and GNU C++ standard library in places known to compiler/linker without passing of any additional options.
To create such toolchain, cd to NDK root directory and run the following command:
./build/tools/make-standalone-toolchain.sh --system=linux-x86_64 --toolchain=arm-linux-androideabi-4.7 --platform=android-14 --install-dir=$HOME/arm-linux-androideabi
Then use $HOME/arm-linux-androideabi as full standalone toolchain for your cmake-based build system.
Please note, however, that application built with CrystaX NDK r8 will not run on newest Android 5.0 due to changes in Bionic (libc). Previous Android versions (<=4.4) are all fine. We fixed that issue (and many others) in upcoming r10 release which is on final testing stage. In the meantime you could adopt your project to our r8 release and quickly switch to r10 when it done - the same approach will work with r10 as well as with r8.
I had installed arm toolchain to build some projects. The issue is, that during my installation I had modified the 'make' from the command line tools to use the arm-gcc compiler instead of gcc.
I now want it to use gcc again. Does anyone know how I can accomplish this? Where exactly is the place where make is defined on Mac OSX?
You can always overwrite it in the Makefile of the project you are building:
CC=gcc
you may need the fully qualified name.
I know how to build gcc from source, what I still have to figure out is what are the exact environmental variables used by gcc when configure and building gcc itself, I'm actually trying to build the compiler from source using another version of gcc with different ABI.
Any idea on how to get this kind of information beside "try to grep all the variable that starts with $ inside all makefiles and configuration files" ?
You can see a list of Environment Variables Affecting GCC.
To create a completly independent gcc with a new toolset, have a look at LFS, they explain how to build gcc from an existing OS for a future OS.
There is also a page about building gcc, which talks about BOOT_CFLAGS='-O' and CFLAGS_FOR_TARGET and STAGE1_TFLAGS and BUILD_CONFIG. There is also some additional variables for cross-compiling and ada compiler.
I would like to set g++4.8 as the c++ compiler with qt creator.
I am in a OSX 10.8, QtCreator 2.8.0, and I have installed g++4.8 via homebrew.
I have setted the g++4.8 as the compiler: if I go in Projects > Manage Kits I have the GCC kit as default, and manually inserted a compiler called GCC 4.8, with compiler path /usr/local/Cellar/gcc48/4.8.1/bin/g++-4.8.
You can see it in the screenshots below. I also have /usr/local/Cellar/gcc48/4.8.1/bin in the Build Enviroment > PATH.
But, if I add QMAKE_CXXFLAGS = --version (I know it is dumb and it doesn't compile but it is just for testing) I receive in the "compiler window"
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1
(that is the same output i receive if I launch g++ from the shell) and not
g++-4.8 (GCC) 4.8.1
(that is what i receive if I launch /usr/local/Cellar/gcc48/4.8.1/bin/g++-4.8 from the shell) (and it is what I want too)
I remember that I had this problem in the past, I tried to resolved it hardlinking the g++4.8 to /usr/bin/g++ but it was not resolved (and just messed up everything).
What can I do?
I had the same problem and landed on your question...
Your question is how to make Qt Creator to use g++-4.8 for compilation.
The solution I devised is the following:
Solution
Add the following line somewhere in your project.pro file
QMAKE_CXX = g++-4.8
for instance just above the HEADERS list
Rationale:
The makefile synthesized by qmake uses the variable CXX to determine the C++ compiler.
You can set the value of the variable CXX at the level of the project configuration file by manually editing it.
Pros:
It solves your problem, you will compile your project using g++-4.8 without having to change the g++ compiler for the rest of your environment.
Cons:
You have to manually set that for each project.
Question for Qt developers:
is there a more natural way to set the g++ compiler at the Kit level? If there is not way, that might be a useful functionality to add.