0

I know about android-cmake, but first I'm starting simple to understand how everything fits together.

I make sure <ndk>\prebuilt\windows-x86_64\bin is in my path (this is where make lives), and I make sure <ndk>\toolchains\x86-4.9\prebuilt\windows-x86_64\bin is in my path (this is where g++ lives). Then I set CC=i686-linux-android-gcc and CXX=i686-linux-android-g++. Everything seems so far so good; cmake can identify both make and the compilers, but it fails when it checks that the C compiler is working, and I can't make sense of the error message to understand what went wrong.

Here's the cmake output:

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>

And here's the error 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/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

Thoughts?

EDIT: Tsyvarev's comment fixed this problem, and cmake can find ar now. But sadly that only revealed the next error, which seems to be a bad option to the linker? I'm not sure why it happens or the best way to fix it.

Cmake output:

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".

Error 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
Jeff M
  • 2,492
  • 3
  • 22
  • 38
  • 1
    `CMAKE_AR-NOTFOUND` tells that archive tool, used e.g. for linking static libraries, is not found. You need to set path to this tool in CMake toolchain file: `set(CMAKE_AR i686-linux-android-ar CACHE FILEPATH "Archiver")`. – Tsyvarev Sep 24 '15 at 09:30
  • @Tsyvarev Thanks. That fixed this problem, and cmake can find ar now. But sadly that only revealed the next error, which seems to be a bad option to the linker? I'm not sure why it happens or the best way to fix it. I edit my original question with the new error and log. – Jeff M Sep 25 '15 at 01:40
  • 1
    Linker's option `--out-implib` corresponds to dll-library, which, of course, has no meaning for android. You need toolchain file, which not only sets compiler, but also sets `CMAKE_SYSTEM_NAME`. See, e.g., this answer: http://stackoverflow.com/a/19375221/3440745. – Tsyvarev Sep 25 '15 at 08:49

0 Answers0