[cfe-dev] can't link with libstdc++

Anton Smirnov dev at antonsmirnov.name
Fri Jan 24 23:19:38 PST 2014


Hey, folks!

HelloWorld is compiled but can't be linked with libstdc++ with clang 3.3.
libstdc++ headers are found and the file is compiled. Though i'm using
`clang++` to link and passed `-Lpath` where `libstdc++.a` is located it
can't find `std`.

I've tried GCC with the same paths and LD_LIBRARY_PATH and it's able to
compile and link.

Clang's compile and link output:

    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 is on the -L path:

    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

I've also tried to pass `-stdlib=libstdc++` but still getting the same
error. Since i've copied the libs myself i can be wrong in paths or smth
(but GCC works with the same paths). Any thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140125/2e7e8bc0/attachment.html>


More information about the cfe-dev mailing list