c++ - std::terminate() linker error on a small clang project -
i'm getting following error on project links clang (verbose output):
clang++ `/usr/local/cellar/llvm/3.6.2/bin/llvm-config --cxxflags --ldflags --libs --system-libs` -lc++ -fno-rtti -o gen -lclangfrontendtool -lclangfrontend -lclangdriver -lclangserialization -lclangcodegen -lclangparse -lclangsema -lclangstaticanalyzerfrontend -lclangstaticanalyzercheckers -lclangstaticanalyzercore -lclanganalysis -lclangarcmigrate -lclangrewritefrontend -lclangedit -lclangast -lclanglex -lclangbasic -i /usr/local/cellar/llvm/3.6.2/include src/main.cpp -v apple llvm version 7.0.2 (clang-700.1.81) target: x86_64-apple-darwin14.5.0 thread model: posix "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -wdeprecated-objc-isa-usage -werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.9 -v -dwarf-column-info -resource-dir /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../lib/clang/7.0.2 -d __stdc_constant_macros -d __stdc_format_macros -d __stdc_limit_macros -i /usr/local/cellar/llvm/3.6.2/include -i /usr/local/cellar/llvm/3.6.2/include -stdlib=libc++ -wall -w -wno-unused-parameter -wwrite-strings -wcast-qual -wmissing-field-initializers -wno-long-long -wcovered-switch-default -wnon-virtual-dtor -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /users/samvv/projects/ffi-enhanced/xfi-gen -ferror-limit 19 -fmessage-length 142 -fvisibility-inlines-hidden -stack-protector 1 -mstackrealign -fblocks -fno-rtti -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/9g/8c11l8090p524v5r7873yghc0000gn/t/main-918e82.o -x c++ src/main.cpp clang -cc1 version 7.0.2 based upon llvm 3.7.0svn default target x86_64-apple-darwin14.5.0 ignoring nonexistent directory "/usr/include/c++/v1" ignoring duplicate directory "/usr/local/cellar/llvm/3.6.2/include" > #include "..." search starts here: > #include <...> search starts here: /usr/local/cellar/llvm/3.6.2/include /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../include/c++/v1 /usr/local/include /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../lib/clang/7.0.2/include /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/include /usr/include /system/library/frameworks (framework directory) /library/frameworks (framework directory) end of search list. "/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o gen -l/usr/local/cellar/llvm/3.6.2/lib -search_paths_first -headerpad_max_install_names -lllvmlto -lllvmobjcarcopts -lllvmlinker -lllvmbitwriter -lllvmirreader -lllvmasmparser -lllvmxcoredisassembler -lllvmxcorecodegen -lllvmxcoredesc -lllvmxcoreinfo -lllvmxcoreasmprinter -lllvmsystemzdisassembler -lllvmsystemzcodegen -lllvmsystemzasmparser -lllvmsystemzdesc -lllvmsystemzinfo -lllvmsystemzasmprinter -lllvmsparcdisassembler -lllvmsparccodegen -lllvmsparcasmparser -lllvmsparcdesc -lllvmsparcinfo -lllvmsparcasmprinter -lllvmr600codegen -lllvmipo -lllvmvectorize -lllvmr600asmparser -lllvmr600desc -lllvmr600info -lllvmr600asmprinter -lllvmpowerpcdisassembler -lllvmpowerpccodegen -lllvmpowerpcasmparser -lllvmpowerpcdesc -lllvmpowerpcinfo -lllvmpowerpcasmprinter -lllvmnvptxcodegen -lllvmnvptxdesc -lllvmnvptxinfo -lllvmnvptxasmprinter -lllvmmsp430codegen -lllvmmsp430desc -lllvmmsp430info -lllvmmsp430asmprinter -lllvmmipsdisassembler -lllvmmipscodegen -lllvmmipsasmparser -lllvmmipsdesc -lllvmmipsinfo -lllvmmipsasmprinter -lllvmhexagondisassembler -lllvmhexagoncodegen -lllvmhexagondesc -lllvmhexagoninfo -lllvmcppbackendcodegen -lllvmcppbackendinfo -lllvmarmdisassembler -lllvmarmcodegen -lllvmarmasmparser -lllvmarmdesc -lllvmarminfo -lllvmarmasmprinter -lllvmaarch64disassembler -lllvmaarch64codegen -lllvmaarch64asmparser -lllvmaarch64desc -lllvmaarch64info -lllvmaarch64asmprinter -lllvmaarch64utils -lllvmtablegen -lllvmdebuginfo -lllvmoption -lllvmx86disassembler -lllvmx86asmparser -lllvmx86codegen -lllvmselectiondag -lllvmasmprinter -lllvmx86desc -lllvmmcdisassembler -lllvmx86info -lllvmx86asmprinter -lllvmx86utils -lllvmmcjit -lllvmlineeditor -lllvminstrumentation -lllvminterpreter -lllvmexecutionengine -lllvmruntimedyld -lllvmcodegen -lllvmscalaropts -lllvmprofiledata -lllvmobject -lllvmmcparser -lllvmbitreader -lllvminstcombine -lllvmtransformutils -lllvmipa -lllvmanalysis -lllvmtarget -lllvmmc -lllvmcore -lllvmsupport -lcurses -lpthread -lz -lm -lc++ -lclangfrontendtool -lclangfrontend -lclangdriver -lclangserialization -lclangcodegen -lclangparse -lclangsema -lclangstaticanalyzerfrontend -lclangstaticanalyzercheckers -lclangstaticanalyzercore -lclanganalysis -lclangarcmigrate -lclangrewritefrontend -lclangedit -lclangast -lclanglex -lclangbasic /var/folders/9g/8c11l8090p524v5r7873yghc0000gn/t/main-918e82.o -lc++ -lsystem /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/../lib/clang/7.0.2/lib/darwin/libclang_rt.osx.a undefined symbols architecture x86_64: "std::terminate()", referenced from: ___clang_call_terminate in main-918e82.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) make: *** [all] error 1
according this question, linking -lc++
should fix issue, in case doesn't. i've managed reduce issue down flag, added llvm-config --ldflags
:
-l/usr/local/cellar/llvm/3.6.2/lib
any idea why flag causing error , how fix it?
i found problem: linking non-default stdlibs using -l/usr/local/opt/llvm/lib/
. prepending -l/usr/lib
, made sure os x's default stdlib goes above homebrewn version.
Comments
Post a Comment