I've installed clang 3.2 on my Ubuntu 13.04 machine, and have compiled and built libc++, and everything is in place. However, when I try to link my (really simple) code, the linker reports that references to std::cout etc. are undefined.
If anyone could advise me what I could do to solve this, I'd be very grateful -- I've tried everything I can think of.
The commands and output are here:
$ clang++ -v -stdlib=libc++ -lpthread -ldl sqlite3/sqlite3.o src/world.o -o bin/world
Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2)
Target: x86_64-pc-linux-gnu
Thread model: posix
"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o bin/world /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../.. -L/lib -L/usr/lib -lpthread -ldl sqlite3/sqlite3.o src/world.o -lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crtn.o
src/world.o: In function `main':
/home/douglivesey/work/home/cpp/clang/biots/src/world.cpp:17: undefined reference to `std::cout'
/home/douglivesey/work/home/cpp/clang/biots/src/world.cpp:17: 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*)'
/home/douglivesey/work/home/cpp/clang/biots/src/world.cpp:17: 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*)'
/home/douglivesey/work/home/cpp/clang/biots/src/world.cpp:17: 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*)'
src/world.o: In function `__cxx_global_var_init':
/usr/include/c++/4.7.3/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.7.3/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bin/world] Error 1
clang++ -v -stdlib=libc++ -lpthread -ldl sqlite3/sqlite3.o src/world.o -o bin/world
However the file sqlite3.o that it gets linked against is compiled withclang -c -o sqlite3/sqlite3.o sqlite3/sqlite3.c
, because it is a C file. Could this be related to the issue? – Affiant