Hi all,<br><br>I haven't found this trick anywhere (including llvm/docs/MakefileGuide.html)<br>so it maybe useful.<br>This occurs only in 64 bit version of linux, linker of 32 bit system <span><span style="background-color: rgb(230, 236, 249); color: rgb(0, 0, 0);" title="">understands everything
 correctly</span></span>.<br><br>Situation:<br>While building, at link stage, a 64bit version of some executable, with several archive libraries, say, A.a, B.a, C.a<br>build fails with some "undefined reference to symbol" errors, <br>

Error occurs in try to link-in some symbol defined in B, which is undefined symbol in A library.<br>Linker somehow looks for that symbol only in A library, where it is undefined, U-symbol, in terms of nm(1).<br><br>Solution is to add in USEDLIBS line name of B library immediately after name of A,  for every such A for which linker gets so confused.<br>

<br>***<br><br>Example for VMkit:<br>USEDLIBS = J3.a Classpath.a J3Compiler.a Allocator.a \<br>                    Mvm.a MvmCompiler.a $(GCLIB).a CommonThread.a<br><br>make output:<br><<<<br>make[1]: Leaving directory `/home/mn/tests/VMkit/vmkit/lib'<br>

<div>make[1]:
 Entering directory `/home/mn/tests/VMkit/vmkit/tools/vmjc'<br>

llvm[1]: Compiling vmjc.cpp for Debug build<br>llvm[1]: Linking Debug 
executable vmjc<br>/home/mn/tests/VMkit/vmkit/Debug/lib/libGCMmap2.a(gcinit.o):
 In function `mvm::Collector::initialise()':<br>/home/mn/tests/VMkit/vmkit/lib/Mvm/GCMmap2/gcinit.cpp:22:
 undefined reference to `GCAllocator::operator new(unsigned long)'<br>

/home/mn/tests/VMkit/vmkit/lib/Mvm/GCMmap2/gcinit.cpp:22: undefined
 reference to `GCAllocator::GCAllocator()'<br>/home/mn/tests/VMkit/vmkit/Debug/lib/libGCMmap2.a(gcinit.o):
 In function `mvm::Collector::destroy()':<br>

/home/mn/tests/VMkit/vmkit/lib/Mvm/GCMmap2/gcinit.cpp:42: undefined
 reference to `GCAllocator::~GCAllocator()'<br>/home/mn/tests/VMkit/vmkit/lib/Mvm/GCMmap2/gcinit.cpp:42:
 undefined reference to `GCAllocator::operator delete(void*)'<br>

collect2: ld returned 1 exit status<br>make[1]: *** 
[/home/mn/tests/VMkit/vmkit/Debug/bin/vmjc] Error 1<br>make[1]: 
Leaving directory `/home/mn/tests/VMkit/vmkit/tools/vmjc'<br>make: 
*** [all] Error 1<br>>>></div><br>Solution:<br>change USEDLIBS to:<br>USEDLIBS = J3.a Classpath.a J3.a J3Compiler.a Allocator.a \<br>
                    Mvm.a MvmCompiler.a $(GCLIB).a Allocator.a 
CommonThread.a<br><br>Here J3.a and Allocator.a were repeated.<br>After change it builds OK.<br><br><br>Regards,<br>Minas Abrahamyan<br>
<br>