我知道android-cmake
,但首先我开始简单地理解所有内容是如何组合在一起的。
我确保<ndk>\prebuilt\windows-x86_64\bin
在我的路径中(这就是生活的地方),我确保<ndk>\toolchains\x86-4.9\prebuilt\windows-x86_64\bin
在我的路径中(这是g ++所在的地方)。然后我set CC=i686-linux-android-gcc
和CXX=i686-linux-android-g++
。一切似乎都那么好; cmake可以识别make和编译器,但是当它检查C编译器是否正常工作时它会失败,而我无法理解错误信息以了解出错的地方。
这是cmake输出:
C:\test_project\build>cmake -G "Unix Makefiles" ..
-- The C compiler identification is GNU 4.9.0
-- The CXX compiler identification is GNU 4.9.0
-- Check for working C compiler: C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/i686-linux-android-gcc.exe
-- Check for working C compiler: C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/i686-linux-android-gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/i686-linux-android-gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/test_project/build/CMakeFiles/CMakeTmp
Run Build
Command:"C:/android-ndk-r10d-windows-x86_64/prebuilt/windows-x86_64/bin/make.exe"
"cmTryCompileExec924087958/fast"
C:/android-ndk-r10d-windows-x86_64/prebuilt/windows-x86_64/bin/make.exe
-f CMakeFiles/cmTryCompileExec924087958.dir/build.make
CMakeFiles/cmTryCompileExec924087958.dir/build
make.exe[1]: Entering directory
`C:/test_project/build/CMakeFiles/CMakeTmp'
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_report
C:/test_project/build/CMakeFiles/CMakeTmp/CMakeFiles
1
"Building C object
CMakeFiles/cmTryCompileExec924087958.dir/testCCompiler.c.obj"
C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/i686-linux-android-gcc.exe
-o CMakeFiles/cmTryCompileExec924087958.dir/testCCompiler.c.obj -c
C:/test_project/build/CMakeFiles/CMakeTmp/testCCompiler.c
"Linking C executable cmTryCompileExec924087958.exe"
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E remove -f
CMakeFiles/cmTryCompileExec924087958.dir/objects.a
CMAKE_AR-NOTFOUND cr CMakeFiles/cmTryCompileExec924087958.dir/objects.a
@CMakeFiles/cmTryCompileExec924087958.dir/objects1.rsp
process_begin: CreateProcess(NULL, CMAKE_AR-NOTFOUND cr
CMakeFiles/cmTryCompileExec924087958.dir/objects.a
@CMakeFiles/cmTryCompileExec924087958.dir/objects1.rsp, ...) failed.
make (e=2): The system cannot find the file specified.
make.exe[1]: *** [cmTryCompileExec924087958.exe] Error 2
make.exe[1]: Leaving directory
`C:/test_project/build/CMakeFiles/CMakeTmp'
make.exe: *** [cmTryCompileExec924087958/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "C:/test_project/build/CMakeFiles/CMakeOutput.log".
See also "C:/test_project/build/CMakeFiles/CMakeError.log".
C:\test_project\build>
这是错误日志:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/i686-linux-android-gcc.exe
Build flags:
Id flags:
The output was:
1
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot open crtbegin_dynamic.o: No such file or directory
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot open crtend_android.o: No such file or directory
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lc
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -ldl
collect2.exe: error: ld returned 1 exit status
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/i686-linux-android-g++.exe
Build flags:
Id flags:
The output was:
1
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot open crtbegin_dynamic.o: No such file or directory
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot open crtend_android.o: No such file or directory
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lstdc++
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lm
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lc
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -ldl
collect2.exe: error: ld returned 1 exit status
Determining if the C compiler works failed with the following output:
Change Dir: C:/test_project/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/android-ndk-r10d-windows-x86_64/prebuilt/windows-x86_64/bin/make.exe" "cmTryCompileExec924087958/fast"
C:/android-ndk-r10d-windows-x86_64/prebuilt/windows-x86_64/bin/make.exe -f CMakeFiles/cmTryCompileExec924087958.dir/build.make CMakeFiles/cmTryCompileExec924087958.dir/build
make.exe[1]: Entering directory `C:/test_project/build/CMakeFiles/CMakeTmp'
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_report C:/test_project/build/CMakeFiles/CMakeTmp/CMakeFiles 1
"Building C object CMakeFiles/cmTryCompileExec924087958.dir/testCCompiler.c.obj"
C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/i686-linux-android-gcc.exe -o CMakeFiles/cmTryCompileExec924087958.dir/testCCompiler.c.obj -c C:/test_project/build/CMakeFiles/CMakeTmp/testCCompiler.c
"Linking C executable cmTryCompileExec924087958.exe"
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E remove -f CMakeFiles/cmTryCompileExec924087958.dir/objects.a
CMAKE_AR-NOTFOUND cr CMakeFiles/cmTryCompileExec924087958.dir/objects.a @CMakeFiles/cmTryCompileExec924087958.dir/objects1.rsp
process_begin: CreateProcess(NULL, CMAKE_AR-NOTFOUND cr CMakeFiles/cmTryCompileExec924087958.dir/objects.a @CMakeFiles/cmTryCompileExec924087958.dir/objects1.rsp, ...) failed.
make (e=2): The system cannot find the file specified.
make.exe[1]: *** [cmTryCompileExec924087958.exe] Error 2
make.exe[1]: Leaving directory `C:/test_project/build/CMakeFiles/CMakeTmp'
make.exe: *** [cmTryCompileExec924087958/fast] Error 2
思想?
编辑:Tsyvarev的评论解决了这个问题,cmake现在可以找到ar
。但遗憾的是,只发现了下一个错误,这对链接器来说似乎是一个糟糕的选择?我不确定它为什么会发生或解决它的最佳方法。
Cmake输出:
C:\test_project\build>cmake -G "Unix Makefiles" ..
-- The C compiler identification is GNU 4.9.0
-- The CXX compiler identification is GNU 4.9.0
-- Check for working C compiler: C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/gcc.exe
-- Check for working C compiler: C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler
"C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/test_project/build/CMakeFiles/CMakeTmp
Run Build
Command:"C:/android-ndk-r10d-windows-x86_64/prebuilt/windows-x86_64/bin/make.exe"
"cmTryCompileExec2113787949/fast"
C:/android-ndk-r10d-windows-x86_64/prebuilt/windows-x86_64/bin/make.exe
-f CMakeFiles/cmTryCompileExec2113787949.dir/build.make
CMakeFiles/cmTryCompileExec2113787949.dir/build
make.exe[1]: Entering directory
`C:/test_project/build/CMakeFiles/CMakeTmp'
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_report
C:/test_project/build/CMakeFiles/CMakeTmp/CMakeFiles
1
"Building C object
CMakeFiles/cmTryCompileExec2113787949.dir/testCCompiler.c.obj"
C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/gcc.exe
-o CMakeFiles/cmTryCompileExec2113787949.dir/testCCompiler.c.obj -c
C:/test_project/build/CMakeFiles/CMakeTmp/testCCompiler.c
"Linking C executable cmTryCompileExec2113787949.exe"
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E remove -f
CMakeFiles/cmTryCompileExec2113787949.dir/objects.a
C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/ar.exe
cr CMakeFiles/cmTryCompileExec2113787949.dir/objects.a
@CMakeFiles/cmTryCompileExec2113787949.dir/objects1.rsp
C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/gcc.exe
-Wl,--whole-archive CMakeFiles/cmTryCompileExec2113787949.dir/objects.a
-Wl,--no-whole-archive -o cmTryCompileExec2113787949.exe
-Wl,--out-implib,libcmTryCompileExec2113787949.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe:
--out-implib: unknown option
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe:
use the --help option for usage information
collect2.exe: error: ld returned 1 exit status
make.exe[1]: *** [cmTryCompileExec2113787949.exe] Error 1
make.exe[1]: Leaving directory
`C:/test_project/build/CMakeFiles/CMakeTmp'
make.exe: *** [cmTryCompileExec2113787949/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
See also "C:/test_project/build/CMakeFiles/CMakeOutput.log".
See also "C:/test_project/build/CMakeFiles/CMakeError.log".
错误日志:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/gcc.exe
Build flags:
Id flags:
The output was:
1
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot open crtbegin_dynamic.o: No such file or directory
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot open crtend_android.o: No such file or directory
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lc
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -ldl
collect2.exe: error: ld returned 1 exit status
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
Compiler: C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/c++.exe
Build flags:
Id flags:
The output was:
1
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot open crtbegin_dynamic.o: No such file or directory
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot open crtend_android.o: No such file or directory
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lstdc++
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lm
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -lc
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: error: cannot find -ldl
collect2.exe: error: ld returned 1 exit status
Determining if the C compiler works failed with the following output:
Change Dir: C:/test_project/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/android-ndk-r10d-windows-x86_64/prebuilt/windows-x86_64/bin/make.exe" "cmTryCompileExec3892407508/fast"
C:/android-ndk-r10d-windows-x86_64/prebuilt/windows-x86_64/bin/make.exe -f CMakeFiles/cmTryCompileExec3892407508.dir/build.make CMakeFiles/cmTryCompileExec3892407508.dir/build
make.exe[1]: Entering directory `C:/test_project/build/CMakeFiles/CMakeTmp'
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_report C:/test_project/build/CMakeFiles/CMakeTmp/CMakeFiles 1
"Building C object CMakeFiles/cmTryCompileExec3892407508.dir/testCCompiler.c.obj"
C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/gcc.exe -o CMakeFiles/cmTryCompileExec3892407508.dir/testCCompiler.c.obj -c C:/test_project/build/CMakeFiles/CMakeTmp/testCCompiler.c
"Linking C executable cmTryCompileExec3892407508.exe"
"C:/Program Files (x86)/CMake/bin/cmake.exe" -E remove -f CMakeFiles/cmTryCompileExec3892407508.dir/objects.a
C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/ar.exe cr CMakeFiles/cmTryCompileExec3892407508.dir/objects.a @CMakeFiles/cmTryCompileExec3892407508.dir/objects1.rsp
C:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/gcc.exe -Wl,--whole-archive CMakeFiles/cmTryCompileExec3892407508.dir/objects.a -Wl,--no-whole-archive -o cmTryCompileExec3892407508.exe -Wl,--out-implib,libcmTryCompileExec3892407508.dll.a -Wl,--major-image-version,0,--minor-image-version,0
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: --out-implib: unknown option
c:/android-ndk-r10d-windows-x86_64/toolchains/x86-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld.exe: use the --help option for usage information
collect2.exe: error: ld returned 1 exit status
make.exe[1]: *** [cmTryCompileExec3892407508.exe] Error 1
make.exe[1]: Leaving directory `C:/test_project/build/CMakeFiles/CMakeTmp'
make.exe: *** [cmTryCompileExec3892407508/fast] Error 2