which libs do I need to link to build the c-index-test?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

which libs do I need to link to build the c-index-test?

asmwarrior
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@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@4'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x3ae):
undefined reference to `_imp__SymInitialize@12'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x3c1):
undefined reference to `_imp__SymGetModuleBase@8'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x3da):
undefined reference to `_imp__SymFunctionTableAccess@8'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x409):
undefined reference to `_imp__StackWalk@36'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x487):
undefined reference to `_imp__SymGetModuleBase@8'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x4fc):
undefined reference to `_imp__SymGetSymFromAddr@16'
E:\svn_llvm\build\Release\lib/libLLVMSupport.a(Signals.o):Signals.cpp:(.text+0x594):
undefined reference to `_imp__SymGetLineFromAddr@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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: which libs do I need to link to build the c-index-test?

Douglas Gregor

On Jan 14, 2011, at 12:47 AM, Asm warrior wrote:

> 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.

c-index-test should only need to link against libclang, since it uses the C interface to Clang.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: which libs do I need to link to build the c-index-test?

asmwarrior


On 2011-1-14 23:26, Douglas Gregor wrote:

>
> On Jan 14, 2011, at 12:47 AM, Asm warrior wrote:
>
>> 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.
>
> c-index-test should only need to link against libclang, since it uses the C interface to Clang.
>
> - Doug

Thanks for your reply!!
Now, I have successfully build my c++ project.

I just follow these these way:
I go to the folder:
/f/llvm_build/build/tools/clang/tools/c-index-test
and run the command:

make VERBOSE=1 ENABLE_OPTIMIZED=1 DISABLE_ASSERTIONS=1

This way, I get the verbose of the build log, then all the libraries I
need to build my project(c++ project), they are listed here:

-lclang
-lclangIndex
-lclangFrontend
-lclangDriver
-lclangSerialization
-lclangParse
-lclangSema
-lclangAnalysis
-lclangAST
-lclangLex
-lclangBasic
-lLLVMMC
-lLLVMBitReader
-lLLVMCore
-lLLVMSupport
-lpthread
-lpsapi
-limagehlp
-lm


Also, some extra Macros:
__NO_CTYPE_INLINE
_GNU_SOURCE
__STDC_LIMIT_MACROS
_STDC_CONSTANT_MACROS

Then, I need to change the source code a little to build it as a c++ source.
-------------------------------------------------------------------
The first one is:
change the code:
extern char *basename(const char *);
to
extern "C" char *basename(const char *);

since the basename function is in a gnu c library
-------------------------------------------------------------------
The second one is:
change the code:
thread_info *client_data = client_data_v;
to
thread_info *client_data = (thread_info*)client_data_v;

since the c++ compiler has more type check.
-------------------------------------------------------------------
Hope this information can help others to use the code to their c++
project under MinGW.


asmwarrior
ollydgb from Codeblocks' forum



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev