[cmake-developers] Building with Qt for the Raspberry Pi with CMake
Stephen Kelly
steveire at gmail.com
Wed Apr 24 08:38:04 EDT 2013
Alexander Neundorf wrote:
> On Tuesday 16 April 2013, Stephen Kelly wrote:
>> Alexander Neundorf wrote:
>> > On Friday 12 April 2013, Stephen Kelly wrote:
>> >> I found out what the problem is. CMake doesn't add the sysroot to the
>> >> link line, so that's why the linker is not finding the library. It was
>> >> searching in my native root and not finding them.
>> >>
>> >> set(CMAKE_CXX_LINK_FLAGS
>> >>
>> >> "${CMAKE_CXX_LINK_FLAGS} --sysroot=${CMAKE_FIND_ROOT_PATH}")
>> >>
>> >> Is there a reason CMake does not do something like the above already?
>> >
>> > I don't think there's a reason that this is not done, except that
>> > nobody has done it yet ;-)
>> > So this should be somewhere inside a if(CMAKE_CROSSCOMPILING) in Linux-
>> > GNU.cmake maybe ?
>>
>> It needs special handling in c++ actually. I'll work on it. If
>> CMAKE_FIND_ROOT_PATH can be a list, then we'll need a new variable like
>> CMAKE_SYSROOT (which is also relevant to find_* commands) which is not a
>> list.
>
> That was the intention of CMAKE_FIND_ROOT_PATH, really.
> When we added this in 2007, I think CMAKE_PREFIX_PATH did not exist yet
> (this was still 2.4.x on the way to 2.6.0).
> So CMAKE_FIND_ROOT_PATH had to be a list, the list of directories where
> stuff for the target can be found.
> Maybe today this could be done differently.
> Let's say CMAKE_FIND_ROOT_PATH would be only one directory (sysroot),
> which is set so that it points to the target file system hierarchy.
That raises backward compatibility questions. I'd rather not.
> The additional directories which need to be searched could today maybe
> also be listed in CMAKE_PREFIX_PATH.
I have my rootfs at /home/stephen/rpi/rasp-pi-rootfs. That's what I use for
my syroot.
I might also want to put KArchive in /opt/kf5/ on the target fs. So I'd
additionally add /home/stephen/rpi/rasp-pi-rootfs/opt/kf5/ to the
CMAKE_FIND_ROOT_PATHS.
I pushed a set-sysroot branch implementing this to my clone. This actually
also makes it possible to cross-compile for android without forcing the
compiler.
Without this patch:
-- Check for working C compiler: /home/stephen/android/android-ndk-
r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-
linux-androideabi-gcc
-- Check for working C compiler: /home/stephen/android/android-ndk-
r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-
linux-androideabi-gcc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61
(message):
The C compiler
"/home/stephen/android/android-ndk-r8e/toolchains/arm-linux-
androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/stephen/dev/src/qtbase-
stable/tests/auto/cmake/build/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec3042013940/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec3042013940.dir/build.make
CMakeFiles/cmTryCompileExec3042013940.dir/build
make[1]: Entering directory
`/home/stephen/dev/src/qtbase-
stable/tests/auto/cmake/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/stephen/dev/src/qtbase-
stable/tests/auto/cmake/build/CMakeFiles/CMakeTmp/CMakeFiles
1
Building C object
CMakeFiles/cmTryCompileExec3042013940.dir/testCCompiler.c.o
/home/stephen/android/android-ndk-r8e/toolchains/arm-linux-
androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
-o CMakeFiles/cmTryCompileExec3042013940.dir/testCCompiler.c.o -c
/home/stephen/dev/src/qtbase-
stable/tests/auto/cmake/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTryCompileExec3042013940
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec3042013940.dir/link.txt --verbose=1
/home/stephen/android/android-ndk-r8e/toolchains/arm-linux-
androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
CMakeFiles/cmTryCompileExec3042013940.dir/testCCompiler.c.o -o
cmTryCompileExec3042013940 -rdynamic
/home/stephen/android/android-ndk-r8e/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 open crtbegin_dynamic.o: No such file or directory
/home/stephen/android/android-ndk-r8e/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 open crtend_android.o: No such file or directory
/home/stephen/android/android-ndk-r8e/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 -lc
/home/stephen/android/android-ndk-r8e/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 -ldl
collect2: error: ld returned 1 exit status
make[1]: Leaving directory
`/home/stephen/dev/src/qtbase-
stable/tests/auto/cmake/build/CMakeFiles/CMakeTmp'
make[1]: *** [cmTryCompileExec3042013940] Error 1
make: *** [cmTryCompileExec3042013940/fast] Error 2
To work around that, the Android toolchain in the wild forces the compiler
currently:
http://code.opencv.org/projects/opencv/repository/revisions/master/entry/android/android.toolchain.cmake
Thanks,
Steve.
More information about the cmake-developers
mailing list