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

asmwarrior asmwarrior at gmail.com
Fri Jan 14 20:01:52 PST 2011



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






More information about the cfe-dev mailing list