0

I'm struggling to link my program on Linux. I've given up and hacked the Makefile I'm using to use an archive group. However, I've still got a bunch of undefined references to things I know I export- the build succeeds on Windows and if I build LLVM from source.

The full command is

g++ -o ../Build/x64/Release/SemanticTest -s -m64 -L/usr/lib64 -L/usr/lib/llvm-3.6/lib -L/opt/wide/boost_1_59_0/stage/lib -L../Build/x64/Release   -Wl,--start-group ../Obj/SemanticTest/x64/Release/test.o ../Obj/SemanticTest/x64/Release/main.o  -lUtil -lSemantic -lParser -lLexer -lm -lstdc++ -lclangFrontend -lclangSerialization -lclangDriver -lclangTooling -lclangCodeGen -lclangParse -lclangSema -lclangAnalysis -lclangRewriteFrontend -lclangRewrite -lclangEdit -lclangAST -lclangLex -lclangBasic -lLLVMLTO -lLLVMObjCARCOpts -lLLVMLinker -lLLVMBitWriter -lLLVMIRReader -lLLVMAsmParser -lLLVMR600CodeGen -lLLVMipo -lLLVMVectorize -lLLVMR600AsmParser -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMAArch64Disassembler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMAArch64Utils -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMSparcAsmPrinter -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 -ldl -lpthread -lncurses -lboost_program_options -larchive -lz -Wl,--end-group

How can I convince ld to actually find the stuff I export?

Puppy
  • 144,682
  • 38
  • 256
  • 465
  • Well, this highly depends on what errors you've got *exactly*. Linker groups are used to deal with circular references and there's no need to include there libraries like pthread, dl, ncurses - they are definitely don't have any references to each other. Where, in what library or libraries do the unresolved symbols reside? – user3159253 Nov 13 '15 at 22:57
  • Maybe [**Why does the order in which libraries are linked sometimes cause errors in GCC?**](http://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc) ?? – David C. Rankin Nov 13 '15 at 23:48
  • Well, unlikely. those "linker groups" are used to deal with circular references between libraries and thus should eliminate this problem, at least in theory. I would bet on wrong name mangling. – user3159253 Nov 13 '15 at 23:55
  • The libraries involved are the first four- Util, Semantic, Parser, Lexer. e.g. the Parser fails to find token definitions in the Lexer. They are all compiled as part of this same project so uncertain how name mangling could be the cause. – Puppy Nov 14 '15 at 17:30
  • I could post the exact error but I doubt it'll be useful, it's mostly just the exact full templated type of the things it can't find. – Puppy Nov 14 '15 at 17:31
  • I am however loading up my VM now to post it shortly. – Puppy Nov 14 '15 at 17:44
  • This has got to be something to do with ABI. If I rebuild my own stuff with clang-3.6, they can find each other but then not the LLVM package. So you were probably right w.r.t. the name mangling. – Puppy Nov 14 '15 at 18:00

1 Answers1

0

This has something to do with incompatible ABIs. I had old cached binaries lying around that I needed to clear out. I rebuilt my own work with Clang 3.6 and now I can mostly link. There's just functions that use std::string left between my code and my used libraries, namely LLVM&Clang and Boost.

Ultimately, I think this is probably due to all the stuff I did to try to work with both Precise and Willy with the same build scripts, like install Clang 3.6 and try to use that as the compiler. A clean install of Willy doing the obvious thing works just fine.

Puppy
  • 144,682
  • 38
  • 256
  • 465