[cfe-dev] which libs do I need to link to build the c-index-test?

Asm warrior asmwarrior at gmail.com
Fri Jan 14 00:47:43 PST 2011


Hi, I'm a mingw user, and I have succefully build llvm+clang under 
msys+mingw. (yes, c-index-test build Ok under MSYS).

Now, I just copy the source code: (renamed it as main.cpp to my 
codeblocks project)
E:\svn_llvm\llvm\tools\clang\tools\c-index-test\c-index-test.c

then, I try to add some include search path and lib search path.

the compiling stage works OK, but the link stage has some problems like:

-----------------------------------------------------------------------------------------------------
-------------- Build: Debug in test_clang ---------------

[100.0%] g++.exe -LE:\svn_llvm\build\Release\lib  -o 
bin\Debug\test_clang.exe obj\Debug\main.o   -clang -clangIndex 
-clangFrontend -clangDriver -clangSerialization -clangParse -clangSema 
-clangAnalysis -clangAST -clangLex -clangBasic -lclangParse -lclangSema 
-lclangAnalysis -lclangAST -lclangFrontend -lclangLex -lclangBasic 
-lLLVMSupport -clang -clangIndex -clangFrontend -clangDriver 
-clangSerialization -clangParse -clangSema -clangAnalysis -clangAST 
-clangLex -clangBasic -lclangParse -lclangSema -lclangAnalysis 
-lclangAST -lclangFrontend -lclangLex -lclangBasic -lLLVMSupport -clang 
-clangIndex -clangFrontend -clangDriver -clangSerialization -clangParse 
-clangSema -clangAnalysis -clangAST -clangLex -clangBasic -lclangParse 
-lclangSema -lclangAnalysis -lclangAST  -lclang -lLLVMSupport -lclangAST
obj\Debug\main.o: In function `GetCursorSource':
F:/cb/test_code/test_clang/main.cpp:295: undefined reference to 
`basename(char const*)'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Process.o):Process.cpp:(.text+0x3ec): 
undefined reference to `GetProcessMemoryInfo at 12'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(ThreadLocal.o):ThreadLocal.cpp:(.text+0x11): 
undefined reference to `_imp__pthread_getspecific'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(ThreadLocal.o):ThreadLocal.cpp:(.text+0x31): 
undefined reference to `_imp__pthread_setspecific'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(ThreadLocal.o):ThreadLocal.cpp:(.text+0x59): 
undefined reference to `_imp__pthread_setspecific'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(ThreadLocal.o):ThreadLocal.cpp:(.text+0x8f): 
undefined reference to `_imp__pthread_key_delete'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(ThreadLocal.o):ThreadLocal.cpp:(.text+0xc8): 
undefined reference to `_imp__pthread_key_delete'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(ThreadLocal.o):ThreadLocal.cpp:(.text+0xf8): 
undefined reference to `_imp__pthread_key_delete'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(ThreadLocal.o):ThreadLocal.cpp:(.text+0x147): 
undefined reference to `_imp__pthread_key_create'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(ThreadLocal.o):ThreadLocal.cpp:(.text+0x197): 
undefined reference to `_imp__pthread_key_create'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x392): 
undefined reference to `_imp__SymSetOptions at 4'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x3ae): 
undefined reference to `_imp__SymInitialize at 12'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x3c1): 
undefined reference to `_imp__SymGetModuleBase at 8'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x3da): 
undefined reference to `_imp__SymFunctionTableAccess at 8'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x409): 
undefined reference to `_imp__StackWalk at 36'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x487): 
undefined reference to `_imp__SymGetModuleBase at 8'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x4fc): 
undefined reference to `_imp__SymGetSymFromAddr at 16'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x594): 
undefined reference to `_imp__SymGetLineFromAddr at 16'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0xe): 
undefined reference to `_imp__pthread_mutex_trylock'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x2e): 
undefined reference to `_imp__pthread_mutex_unlock'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x4e): 
undefined reference to `_imp__pthread_mutex_lock'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x6f): 
undefined reference to `_imp__pthread_mutex_destroy'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x8f): 
undefined reference to `_imp__pthread_mutex_destroy'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0xdf): 
undefined reference to `_imp__pthread_mutexattr_init'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0xec): 
undefined reference to `_imp__pthread_mutexattr_settype'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0xfd): 
undefined reference to `_imp__pthread_mutexattr_setpshared'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x10a): 
undefined reference to `_imp__pthread_mutex_init'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x113): 
undefined reference to `_imp__pthread_mutexattr_destroy'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x16f): 
undefined reference to `_imp__pthread_mutexattr_init'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x17c): 
undefined reference to `_imp__pthread_mutexattr_settype'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x18d): 
undefined reference to `_imp__pthread_mutexattr_setpshared'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x19a): 
undefined reference to `_imp__pthread_mutex_init'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Mutex.o):Mutex.cpp:(.text+0x1a3): 
undefined reference to `_imp__pthread_mutexattr_destroy'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Threading.o):Threading.cpp:(.text+0x52): 
undefined reference to `_imp__pthread_attr_init'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Threading.o):Threading.cpp:(.text+0x7b): 
undefined reference to `_imp__pthread_create'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Threading.o):Threading.cpp:(.text+0x88): 
undefined reference to `_imp__pthread_attr_destroy'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Threading.o):Threading.cpp:(.text+0x9b): 
undefined reference to `_imp__pthread_attr_setstacksize'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Threading.o):Threading.cpp:(.text+0xbe): 
undefined reference to `_imp__pthread_join'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0x38a1): 
undefined reference to `clang::ASTUnit::getOriginalSourceFileName()'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0x3902): 
undefined reference to `clang::ASTUnit::~ASTUnit()'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0x3972): 
undefined reference to `clang::ASTUnit::Save(llvm::StringRef)'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0x3f2d): 
undefined reference to `clang::ASTUnit::Reparse(std::pair<std::string, 
llvm::MemoryBuffer const*>*, unsigned int)'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0x4837): 
undefined reference to `clang::getClangFullVersion()'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0x4ba8): 
undefined reference to 
`clang::CompilerInstance::createDiagnostics(clang::DiagnosticOptions 
const&, int, char const* const*, clang::DiagnosticClient*)'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0x4f53): 
undefined reference to `clang::ASTUnit::LoadFromCommandLine(char 
const**, char const**, llvm::IntrusiveRefCntPtr<clang::Diagnostic>, 
llvm::StringRef, bool, bool, std::pair<std::string, llvm::MemoryBuffer 
const*>*, unsigned int, bool, bool, bool, bool, bool)'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0x549a): 
undefined reference to `clang::ASTUnit::LoadFromASTFile(std::string 
const&, llvm::IntrusiveRefCntPtr<clang::Diagnostic>, 
clang::FileSystemOptions const&, bool, std::pair<std::string, 
llvm::MemoryBuffer const*>*, unsigned int, bool)'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0xabda): 
undefined reference to `clang::ASTUnit::RealizeTopLevelDeclsFromPreamble()'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0xabf3): 
undefined reference to `clang::ASTUnit::RealizeTopLevelDeclsFromPreamble()'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0xace1): 
undefined reference to `clang::ASTUnit::pp_entity_begin()'
E:\svn_llvm\build\Release\lib/libclang.a(CIndex.o):CIndex.cpp:(.text+0xacf0): 
undefined reference to `clang::ASTUnit::pp_entity_end()'
Process terminated with status 1 (0 minutes, 1 seconds)
50 errors, 0 warnings (0 minutes, 1 seconds)

------------------------------------------------------------------------------------------------------------

from the makefile, I know there I need to add some libraries.
E:\svn_llvm\llvm\tools\clang\tools\c-index-test\Makefile:

-------------------------------------------------------------------------------------------

##===- tools/index-test/Makefile ---------------------------*- Makefile 
-*-===##
#
#                     The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
CLANG_LEVEL := ../..

TOOLNAME = c-index-test

# No plugins, optimize startup time.
TOOL_NO_EXPORTS = 1

LINK_COMPONENTS := bitreader mc core
USEDLIBS = clang.a clangIndex.a clangFrontend.a clangDriver.a \
	   clangSerialization.a clangParse.a clangSema.a clangAnalysis.a \
	   clangAST.a clangLex.a clangBasic.a

include $(CLANG_LEVEL)/Makefile
---------------------------------------------------------------------------------------------

But what does this statement means?

LINK_COMPONENTS := bitreader mc core

Can I need to add some extra libraries???



thanks.

asmwarrior



More information about the cfe-dev mailing list