undefined reference to `clang_createIndex'

Hi. This will be very short note. I'm trying to build clang and llvm and I have encountered linker error:
undefined reference to `clang_createIndex'
 
I'm using this command to build:
g++ -I. -I./clang+llvm-5.0.0-x86_64-linux-gnu-debian8/include -L./clang+llvm-5.0.0-x86_64-linux-gnu-debian8/lib -g -std=c++11 -lclang main.cpp -o acs
 
So, what's wrong ? Well it turned out that link option (-lclang) should be AFTER the source code file (main.cpp).
So correct form is:
g++ -I. -I./clang+llvm-5.0.0-x86_64-linux-gnu-debian8/include -L./clang+llvm-5.0.0-x86_64-linux-gnu-debian8/lib -g -std=c++11 main.cpp -lclang -o acs
 
So simple, so annoying!