HelloWorld已编译但无法与libngdc ++与clang 3.3链接。
找到libstdc ++头文件并编译该文件。虽然我正在使用clang++
链接并传递-Lpath
libstdc++.a
所在的位置,却无法找到std
。
我尝试使用相同路径和LD_LIBRARY_PATH的GCC,并且能够编译和链接。
Clang的编译和链接输出:
01-25 12:15:55.611: INFO/System.out(5848): clang++ -c -g -v -DIDE=ArduinoDroid -B/system/lib -B/data/data/name.antonsmirnov.android.arduinodroid/sdk/binutils-compact#2.23#1/lib -B/data/data/name.antonsmirnov.android.arduinodroid/sdk/ndk-sysroot-armel-16#r9c#1/arm-linux-androideabi/lib -I/data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/include/c++/4.8 -I/data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/include/c++/4.8/arm-linux-androideabi -I/data/data/name.antonsmirnov.android.arduinodroid/sdk/ndk-sysroot-armel-16#r9c#1/arm-linux-androideabi/include /data/data/name.antonsmirnov.android.arduinodroid/buildSources/HelloWorld#cpp#1.cpp -o/data/data/name.antonsmirnov.android.arduinodroid/build/HelloWorld#cpp#1.cpp.o
01-25 12:15:55.681: WARN/System.err(5848): clang version 3.3
01-25 12:15:55.681: WARN/System.err(5848): Target: arm-unknown-linux-androideabi
01-25 12:15:55.691: WARN/System.err(5848): Thread model: posix
01-25 12:15:55.711: WARN/System.err(5848): "/data/data/name.antonsmirnov.android.arduinodroid/sdk/clang#3.3#1/bin/clang" -cc1 -triple armv4t-unknown-linux-androideabi -S -disable-free -disable-llvm-verifier -main-file-name HelloWorld#cpp#1.cpp -mrelocation-model pic -pic-level 1 -mdisable-fp-elim -fmath-errno -mconstructor-aliases -fuse-init-array -target-abi aapcs-linux -target-cpu arm7tdmi -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -backend-option -arm-enable-ehabi -backend-option -arm-enable-ehabi-descriptors -target-linker-version 2.23.52.20130913 -v -g -coverage-file /storage/sdcard0/ArduinoDroid/temp/HelloWorld#cpp#1-Vk7376.s -resource-dir /data/data/name.antonsmirnov.android.arduinodroid/sdk/clang#3.3#1/bin/../lib/clang/3.3 -D IDE=ArduinoDroid -I /data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/include/c++/4.8 -I /data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/include/c++/4.8/arm-linux-androideabi -I /data/data/name.antonsmirnov.android.arduinodroid/sdk/ndk-sysroot-armel-16#r9c#1/arm-linux-androideabi/include -internal-isystem /..//usr/local/include -internal-isystem /data/data/name.antonsmirnov.android.arduinodroid/sdk/clang#3.3#1/bin/../lib/clang/3.3/include -internal-externc-isystem /..//include -internal-externc-isystem /..//usr/include -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /data/data/name.antonsmirnov.android.arduinodroid/sdk/libclang#3.3#1 -ferror-limit 19 -fmessage-length 0 -mstackrealign -mllvm -disable-global-ctor-const-promotion -fno-signed-char -fobjc-runtime=gcc -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -backend-option -vectorize-loops -fno-cxx-missing-return-semantics -o /storage/sdcard0/ArduinoDroid/temp/HelloWorld#cpp#1-Vk7376.s -x c++ /data/data/name.antonsmirnov.android.arduinodroid/buildSources/HelloWorld#cpp#1.cpp
01-25 12:15:55.751: WARN/System.err(5848): clang -cc1 version 3.3 based upon LLVM 3.3 default target arm-unknown-linux-androideabi
01-25 12:15:55.751: WARN/System.err(5848): ignoring nonexistent directory "/..//usr/local/include"
01-25 12:15:55.751: WARN/System.err(5848): ignoring nonexistent directory "/..//include"
01-25 12:15:55.751: WARN/System.err(5848): ignoring nonexistent directory "/..//usr/include"
01-25 12:15:55.761: WARN/System.err(5848): #include "..." search starts here:
01-25 12:15:55.761: WARN/System.err(5848): #include <...> search starts here:
01-25 12:15:55.761: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/include/c++/4.8
01-25 12:15:55.761: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/include/c++/4.8/arm-linux-androideabi
01-25 12:15:55.761: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/sdk/ndk-sysroot-armel-16#r9c#1/arm-linux-androideabi/include
01-25 12:15:55.761: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/sdk/clang#3.3#1/bin/../lib/clang/3.3/include
01-25 12:15:55.761: WARN/System.err(5848): End of search list.
01-25 12:15:56.662: WARN/System.err(5848): "/data/data/name.antonsmirnov.android.arduinodroid/sdk/binutils-compact#2.23#1/bin/as" -mfloat-abi=soft -o /data/data/name.antonsmirnov.android.arduinodroid/build/HelloWorld#cpp#1.cpp.o /storage/sdcard0/ArduinoDroid/temp/HelloWorld#cpp#1-Vk7376.s
01-25 12:15:56.752: INFO/System.out(5848): clang++ -v -DIDE=ArduinoDroid -L/system/lib -L/data/data/name.antonsmirnov.android.arduinodroid/sdk/binutils-compact#2.23#1/lib -L/data/data/name.antonsmirnov.android.arduinodroid/sdk/libgcc-compact-dev#4.8#1/lib/gcc/arm-linux-androideabi/4.8 -L/data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/lib -L/data/data/name.antonsmirnov.android.arduinodroid/sdk/clang#3.3#1/lib -B/system/lib -B/data/data/name.antonsmirnov.android.arduinodroid/sdk/binutils-compact#2.23#1/lib -B/data/data/name.antonsmirnov.android.arduinodroid/sdk/ndk-sysroot-armel-16#r9c#1/arm-linux-androideabi/lib -o /data/data/name.antonsmirnov.android.arduinodroid/build/HelloWorld#cpp#1.cpp.elf /data/data/name.antonsmirnov.android.arduinodroid/build/HelloWorld#cpp#1.cpp.o
01-25 12:15:56.802: WARN/System.err(5848): clang version 3.3
01-25 12:15:56.802: WARN/System.err(5848): Target: arm-unknown-linux-androideabi
01-25 12:15:56.802: WARN/System.err(5848): Thread model: posix
01-25 12:15:56.802: WARN/System.err(5848): "/data/data/name.antonsmirnov.android.arduinodroid/sdk/binutils-compact#2.23#1/bin/ld" -X --eh-frame-hdr -m armelf_linux_eabi -dynamic-linker /system/bin/linker -o /data/data/name.antonsmirnov.android.arduinodroid/build/HelloWorld#cpp#1.cpp.elf /data/data/name.antonsmirnov.android.arduinodroid/sdk/ndk-sysroot-armel-16#r9c#1/arm-linux-androideabi/lib/crtbegin_dynamic.o -L/system/lib -L/data/data/name.antonsmirnov.android.arduinodroid/sdk/binutils-compact#2.23#1/lib -L/data/data/name.antonsmirnov.android.arduinodroid/sdk/libgcc-compact-dev#4.8#1/lib/gcc/arm-linux-androideabi/4.8 -L/data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/lib -L/data/data/name.antonsmirnov.android.arduinodroid/sdk/clang#3.3#1/lib /data/data/name.antonsmirnov.android.arduinodroid/build/HelloWorld#cpp#1.cpp.o -lstdc++ -lm -lgcc -ldl -lc -lgcc -ldl /data/data/name.antonsmirnov.android.arduinodroid/sdk/ndk-sysroot-armel-16#r9c#1/arm-linux-androideabi/lib/crtend_android.o
01-25 12:15:56.842: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/build/HelloWorld#cpp#1.cpp.o: In function `main':
01-25 12:15:56.842: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/buildSources/HelloWorld#cpp#1.cpp:5: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
01-25 12:15:56.842: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/buildSources/HelloWorld#cpp#1.cpp:6: undefined reference to `std::cout'
01-25 12:15:56.842: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/build/HelloWorld#cpp#1.cpp.o: In function `__cxx_global_var_init':
01-25 12:15:56.842: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
01-25 12:15:56.842: WARN/System.err(5848): /data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
01-25 12:15:56.852: WARN/System.err(5848): clang: error: linker command failed with exit code 1 (use -v to see invocation)
libstdc ++。a位于-L路径:
MBA-Anton:platform-tools asmirnov$ ./adb shell ls -l /data/data/name.antonsmirnov.android.arduinodroid/sdk/libstdc++-compact-dev#4.8#1/arm-linux-androideabi/lib
-rwxr-xr-x u0_a122 u0_a122 7707492 2014-01-24 18:36 libstdc++.a
-rwxr-xr-x u0_a122 u0_a122 674120 2014-01-24 18:36 libsupc++.a
我也尝试过-stdlib=libstdc++
但仍然遇到同样的错误。由于我自己复制了libs,我在路径或smth中可能是错的(但是GCC使用相同的路径)。有什么想法吗?