[cfe-dev] C++ compilation error

Grégory Ruch gregory.ruch at heig-vd.ch
Tue Mar 15 02:00:37 PDT 2011


Hi,

I'm new in the clang world and I don't understood my mistake.
I've downloaded the source of LLVM 2.8 and clang. I've compiled it and
install it in a directory of my choice.

This is my simple code !
***************************************************
#include <iostream>

#include <clang/Frontend/CompilerInstance.h>

using namespace std;
using namespace clang;

int main(int argc, char **argv) {

        cout <<"Hello world!" << endl;

        CompilerInstance MyCI;

        return 0;
}
***************************************************

I compile with :

g++ `/home/[...]/install/bin/llvm-config --cxxflags`
`/home/[...]/install/bin/llvm-config --ldflags` -lclangFrontend 
test.cpp -o test

/tmp/cccJ7SSH.o: In function `main':
test.cpp:(.text+0xc6): undefined reference to
`clang::CompilerInstance::CompilerInstance()'
test.cpp:(.text+0xce): undefined reference to
`clang::CompilerInstance::~CompilerInstance()'
collect2: ld returned 1 exit status

I've tried many way to find were is the include problem but nothing
work. I'm new with the subject and I need some hints to solve it !

Thank you for your help !

Grégory



More information about the cfe-dev mailing list