<div dir="ltr"><div>Hi all,<br><br>I am trying to compile with a minimal TestAsmParser class, but I get the following error.<br><br>----------------<br><br>[43/780] Linking CXX executable bin/llvm-mc<br>FAILED: : && /usr/bin/c++   -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -g  -Wl,-allow-shlib-undefined    -Wl,-O3 -Wl,--gc-sections tools/llvm-mc/CMakeFiles/llvm-mc.dir/llvm-mc.cpp.o tools/llvm-mc/CMakeFiles/llvm-mc.dir/Disassembler.cpp.o  -o bin/llvm-mc lib/libLLVMTestCodeGen.a lib/libLLVMTestAsmPrinter.a lib/libLLVMTestAsmParser.a lib/libLLVMTestDesc.a lib/libLLVMTestInfo.a lib/libLLVMMC.a lib/libLLVMMCParser.a lib/libLLVMSupport.a lib/libLLVMAsmPrinter.a lib/libLLVMSelectionDAG.a lib/libLLVMCodeGen.a lib/libLLVMScalarOpts.a lib/libLLVMInstCombine.a lib/libLLVMProfileData.a lib/libLLVMObject.a lib/libLLVMBitReader.a lib/libLLVMTransformUtils.a lib/libLLVMipa.a lib/libLLVMAnalysis.a lib/libLLVMTarget.a lib/libLLVMCore.a lib/libLLVMTestAsmPrinter.a lib/libLLVMMCParser.a lib/libLLVMMC.a lib/libLLVMSupport.a -lrt -ldl -ltinfo -lpthread -lz -lm -Wl,-rpath,"\$ORIGIN/../lib" && :<br>lib/libLLVMTestAsmParser.a(TestAsmParser.cpp.o): In function `TestAsmParser':<br>/llvm/lib/Target/Test/AsmParser/TestAsmParser.cpp:96: <b>undefined reference to `vtable for (anonymous namespace)::TestAsmParser'</b><br>/llvm/lib/Target/Test/AsmParser/TestAsmParser.cpp:99: <b>undefined reference to `(anonymous namespace)::TestAsmParser::ComputeAvailableFeatures(unsigned long) const'</b><br>collect2: error: ld returned 1 exit status<br><br><br>----------------<br></div><div>and here is the code that it refers to:<br><br>  TestAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,<br>               const MCInstrInfo &MII, const MCTargetOptions &Options)<br>    : MCTargetAsmParser(), STI(sti), Parser(parser) {<br><br>    // Initialize the set of available features.<br>    setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));<br>  }<br></div><div><br><br><br>Destructors for both TestAsmParser and MCTargetAsmParser class are available.<br>I am using CMake.<br><br>I added the following lines to AsmParser/CMakeLists.txt (From the Assembler Guide by Simon Cook from Embecosm <a href="http://www.embecosm.com/appnotes/ean10/ean10-howto-llvmas-1.0.pdf">Link</a>)<br><br><i>add_llvm_library(LLVMTestAsmParser<br>  TestAsmParser.cpp<br>  )</i><br><br>and the followings to main CMakeLists.txt<br><br><i>tablegen(LLVM TestGenAsmMatcher.inc -gen-asm-matcher)<br>add_subdirectory(AsmParser)</i><br><br>Any help is appreciated.<br><br></div><div>Cheers,<br></div><div>ES<br></div></div>