Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake can't compile test on android ndk r23b using ollvm 12 #26

Open
maxerz opened this issue May 2, 2022 · 5 comments
Open

cmake can't compile test on android ndk r23b using ollvm 12 #26

maxerz opened this issue May 2, 2022 · 5 comments

Comments

@maxerz
Copy link

maxerz commented May 2, 2022

i've compiled ollvm on windows with Visual Studio 16 2019 with following cmds:
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=ARM -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;compiler-rt;lld" -Thost=x64 ../llvm (i've also tried with only clang)
cmake --build . --target ALL_BUILD --config Release -- /nologo /maxcpucount
then i copied build outputs to <toolchain_dir>/bin and <toolchain_dir>/lib64, when i try to compile simple android cmake project i get this error:

[main] Configuring folder: src 
[proc] Executing command: D:\CMake\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -Sd:/bmbr/src -Bd:/bmbr/src/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Android: Targeting API '19' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
[cmake] -- Android: Selected unified Clang toolchain
[cmake] -- The C compiler identification is Clang 12.0.1
[cmake] -- The CXX compiler identification is Clang 12.0.1
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - failed
[cmake] -- Check for working C compiler: D:/ndk23b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
[cmake] -- Check for working C compiler: D:/ndk23b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - broken
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "D:/bmbr/src/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "D:/bmbr/src/build/CMakeFiles/CMakeError.log".
[cmake] CMake Error at D:/CMake/share/cmake-3.21/Modules/CMakeTestCCompiler.cmake:69 (message):
[cmake]   The C compiler
[cmake] 
[cmake]     "D:/ndk23b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
[cmake] 
[cmake]   is not able to compile a simple test program.
[cmake] 
[cmake]   It fails with the following output:
[cmake] 
[cmake]     Change Dir: D:/bmbr/src/build/CMakeFiles/CMakeTmp
[cmake]     
[cmake]     Run Build Command(s):C:/MinGW/bin/mingw32-make.exe -f Makefile cmTC_b0a71/fast && C:/MinGW/bin/mingw32-make.exe  -f CMakeFiles\cmTC_b0a71.dir\build.make CMakeFiles/cmTC_b0a71.dir/build
[cmake]     mingw32-make.exe[1]: Entering directory 'D:/bmbr/src/build/CMakeFiles/CMakeTmp'
[cmake]     Building C object CMakeFiles/cmTC_b0a71.dir/testCCompiler.c.o
[cmake]     D:\ndk23b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=armv7-none-linux-androideabi19 --sysroot=D:/ndk23b/toolchains/llvm/prebuilt/windows-x86_64/sysroot   -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fexceptions  -O2 -g -DNDEBUG -fPIE -MD -MT CMakeFiles/cmTC_b0a71.dir/testCCompiler.c.o -MF CMakeFiles\cmTC_b0a71.dir\testCCompiler.c.o.d -o CMakeFiles\cmTC_b0a71.dir\testCCompiler.c.o -c D:\bmbr\src\build\CMakeFiles\CMakeTmp\testCCompiler.c
[cmake]     Linking C executable cmTC_b0a71
[cmake]     D:\CMake\bin\cmake.exe -E cmake_link_script CMakeFiles\cmTC_b0a71.dir\link.txt --verbose=1
[cmake]     D:\ndk23b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=armv7-none-linux-androideabi19 --sysroot=D:/ndk23b/toolchains/llvm/prebuilt/windows-x86_64/sysroot -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fexceptions  -O2 -g -DNDEBUG -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Qunused-arguments -Wl,--no-undefined  -Wl,--gc-sections  CMakeFiles/cmTC_b0a71.dir/testCCompiler.c.o -o cmTC_b0a71   -latomic -lm 
[cmake]     ld: error: unable to find library -latomic
[cmake]     ld: error: unable to find library -lgcc
[cmake]     ld: error: unable to find library -lgcc
[cmake]     clang: error: linker command failed with exit code 1 (use -v to see invocation)
[cmake]     mingw32-make.exe[1]: *** [CMakeFiles\cmTC_b0a71.dir\build.make:99: cmTC_b0a71] Error 1
[cmake]     mingw32-make.exe[1]: Leaving directory 'D:/bmbr/src/build/CMakeFiles/CMakeTmp'
[cmake]     mingw32-make.exe: *** [Makefile:126: cmTC_b0a71/fast] Error 2
[cmake]     
[cmake]     
[cmake] 
[cmake]   
[cmake] 
[cmake]   CMake will not be able to correctly generate this project.
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:9 (project)
[cmake] 
[cmake] 

(i'm using android toolchain that is bundled with ndk with following settings: platform = android-19, stl = c++_static, abi = armeabi-v7a, i've tried using legacy toolchain, same results)

@AndroidMaster24
Copy link

I got similar issue with ld library too

Can you try ollvm 14 for windows? https://github.com/sr-tream/obfuscator/#integrate-to-android-ndk . I can't compile with mingw

You're lucky to be able to compile with VS2019 because I always failed with it, and I had to use mingw-w64 8.1.0.

@heroims
Copy link
Owner

heroims commented May 13, 2022

You may have no problem executing your instructions on Linux, but use VS2019 on windows. I suggest cmake adding -G "Visual Studio 16 2019" and open .sln compiling with VS2019

@AndroidMaster24
Copy link

You may have no problem executing your instructions on Linux, but use VS2019 on windows. I suggest cmake adding -G "Visual Studio 16 2019" and open .sln compiling with VS2019

I tried that, i'm always getting strange errors

Severity	Code	Description	Project	File	Line	Suppression State
Error		unable to create target: 'No available targets are compatible with triple "x86_64-pc-windows-msvc19.29.30145"'	TAsan-x86_64-calls-Noinst-Test	E:\ollvm14\obfuscator\llvm-project\build\projects\compiler-rt\lib\asan\tests\CUSTOMBUILD	1	

image

@AndroidMaster24
Copy link

Nvm, i used cmake --build as mentioned above. Works like a charm with ollvm 14

@CFZxa
Copy link

CFZxa commented Dec 28, 2022

How to solve ld: error: unable to find library -latomic
[cmake] ld: error: unable to find library -lgcc
[cmake] ld: error: unable to find library -lgcc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants