I'm currently having problem with simple project(or llvm-example for that matter). My assignment requires me to use llvm libraries, however this isn't as easy as I had hoped.
I've build LLVM using MinGW GCC and CMake. After build I can compile with clang fine. However if I create simple hello world type of program
#include "llvm-c/Core.h"
int main(int argc, char**argv)
{
return 0;
}
and try to compile it with
clang++ main.cpp
I get
In file included from main.cpp:1:
./llvm-c/Core.h:18:10: fatal error: 'llvm-c/ErrorHandling.h' file not found
#include "llvm-c/ErrorHandling.h"
For this example I have copied contents of include directory into directory with main.cpp. After getting this issue I tried to inspect those headers and all of them have position llvm/ or llvm-c/, instead of pure relative address. I figured these libs were used to build/make llvm and libs for me to use are actually in build directory, which is where I have built llvm, but include directory in build has only about 1/2 *.h files.
I can't seem to find anything in documentation related to this and even basic llvm examples are expecting to include libs in format like llvm/Core.h
EDIT
After solving inclusion problem, now I get several other problems which seems to be linked to mingw.
This is how new program looks.
#define __STDC_LIMIT_MACROS
#define __STDC_CONSTANT_MACROS
#include <llvm-c/Core.h>
using namespace std;
int main()
{
LLVMModuleRef rff = LLVMModuleCreateWithName("testname");
return 0;
}
this generates
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(CommandLine.cpp.obj):CommandLine.cpp|| undefined reference to `__mingw_strtod'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(regerror.c.obj):regerror.c|| undefined reference to `__ms_vsnprintf'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `SHGetKnownFolderPath@16'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `_imp__CoTaskMemFree@4'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `_imp___chsize_s'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_LocalAppData'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_LocalAppData'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_LocalAppData'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_LocalAppData'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_Profile'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_Profile'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_Profile'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_Profile'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_LocalAppData'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_LocalAppData'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_LocalAppData'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(Path.cpp.obj):Path.cpp|| undefined reference to `FOLDERID_LocalAppData'|
d:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\libLLVMSupport.a(TimeValue.cpp.obj):TimeValue.cpp|| undefined reference to `_localtime32'|
I used llvm-config --libs core for linker additions.
Tried commands:
g++ main.cpp -lLLVMCore -lLLVMSupport
clang++ main.cpp -lLLVMCore -lLLVMSupport
llvm-c/llvm-c/Core.hI figured that maybe removing folder from each instance of#includewould help, but its too much files and I dont think this is right approach.PATHso there shouldn't be this problem, and static link problem would pop different error. I did try to add include path to compilation-I"path/to/include", but this case builds first*.hand fails at the second one (one inside that header)