I've followed all the LLVM+clang build-from-source instructions for Windows
using MSVC++ 2008. It all builds fine. I initially had troubling getting any
linking to work at all until I made sure to have the right environment variables
set using a wrapper batch script. Now C programs compile, link, and execute
fine, but C++ programs don't link, not even a simple "hello,
world" program. Error messages (with clang++ verbose output) below.
How can I get C++ programs to link?
- Paul
clang version 3.0 (tags/RELEASE_30/final)
Target: i686-pc-win32
Thread model: posix
"C:/cygwin/usr/local/packages/llvm-3.0/bin/clang++.exe" -cc1 -triple
i686-pc-win32 -emit-obj -mrelax-all -disable-free -main-file-name hello.cpp
-mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases
-target-cpu pentium4 -momit-leaf-frame-pointer -v -resource-dir
"C:/cygwin/usr/local/packages/llvm-3.0/bin\\..\\lib\\clang\\3.0"
-fmodule-cache-path "C:\\cygwin\\tmp\\clang-module-cache"
-internal-isystem
C:/cygwin/usr/local/packages/llvm-3.0/bin/../lib/clang/3.0/include
-internal-isystem "C:\\Program Files\\Microsoft Visual Studio
9.0\\VC\\include" -internal-isystem "C:\\Program Files\\Microsoft
SDKs\\Windows\\v7.0\\\\include" -fdeprecated-macro -ferror-limit 19
-fmessage-length 0 -fms-extensions -fms-compatibility -fmsc-version=1300
-fdelayed-template-parsing -fgnu-runtime -fobjc-runtime-has-arc
-fobjc-runtime-has-weak -fobjc-fragile-abi -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -o C:/cygwin/tmp/hello-066049.o -x c++ hello.cpp
clang -cc1 version 3.0 based upon llvm 3.0 hosted on i686-pc-win32
#include "..." search starts here:
#include <...> search starts here:
C:/cygwin/usr/local/packages/llvm-3.0/bin/../lib/clang/3.0/include
C:\Program Files\Microsoft Visual Studio 9.0\VC\include
C:\Program Files\Microsoft SDKs\Windows\v7.0\\include
End of search list.
"C:/Program Files/Microsoft Visual Studio 9.0/VC/BIN/link.exe"
-out:a.out -defaultlib:libcmt -nologo C:/cygwin/tmp/hello-066049.o
hello-066049.o : error LNK2019: unresolved external symbol __ZSt4cout referenced
in function _main
hello-066049.o : error LNK2019: unresolved external symbol
__ZSt18uncaught_exceptionv referenced in function __ZNSo6sentryD2Ev
hello-066049.o : error LNK2019: unresolved external symbol
__ZNSt6_Mutex7_UnlockEv referenced in function
__ZNSt15basic_streambufIcSt11char_traitsIcEE7_UnlockEv
hello-066049.o : error LNK2019: unresolved external symbol ___cxa_rethrow
referenced in function __ZNSt8ios_base5clearEib
hello-066049.o : error LNK2019: unresolved external symbol
___cxa_allocate_exception referenced in function __ZNSt8ios_base5clearEib
hello-066049.o : error LNK2019: unresolved external symbol ___cxa_throw
referenced in function __ZNSt8ios_base5clearEib
hello-066049.o : error LNK2019: unresolved external symbol __ZdlPv referenced in
function __ZNSaIcE10deallocateEPcj
hello-066049.o : error LNK2019: unresolved external symbol __ZNSt9exceptionD2Ev
referenced in function __ZNSt13runtime_errorD2Ev
hello-066049.o : error LNK2019: unresolved external symbol
__ZNSt12_String_base5_XranEv referenced in function __ZNSs6assignERKSsjj
hello-066049.o : error LNK2019: unresolved external symbol
__ZNSt12_String_base5_XlenEv referenced in function __ZNSs5_GrowEjb
hello-066049.o : error LNK2019: unresolved external symbol __Znwj referenced in
function __ZSt9_AllocateIcEPT_jS1_
hello-066049.o : error LNK2019: unresolved external symbol
__ZNSt9exceptionC2ERKPKc referenced in function __ZNSt9bad_allocC2EPKc
hello-066049.o : error LNK2019: unresolved external symbol __ZNSt9exceptionC2Ev
referenced in function __ZNSt13runtime_errorC2ERKSs
hello-066049.o : error LNK2019: unresolved external symbol __ZNSt6_Mutex5_LockEv
referenced in function __ZNSt15basic_streambufIcSt11char_traitsIcEE5_LockEv
hello-066049.o : error LNK2001: unresolved external symbol
__ZTVN10__cxxabiv120__si_class_type_infoE
hello-066049.o : error LNK2001: unresolved external symbol __ZTISt9exception
hello-066049.o : error LNK2001: unresolved external symbol
__ZNKSt9exception4whatEv
a.out : fatal error LNK1120: 17 unresolved externals