llvm-config error

Hi

I’m having a few problems building the kaleidoscope example (chapter 3) under MinGW. To build the example I use as recommended

g++ -g -O3 toy.cpp llvm-config --cppflags --ldflags --libs core -o toy

but get the following error

sh: llvm-config: command not found

Indeed in my “\llvm-2.7\tools\llvm-config\” build directory there is no “Release” subdirectory as I would expect (only llvm-config.in among other files) and in \llvm-2.7\Release\bin no llvm-config executable (only a llvm-config text file). This was a little unexpected because otherwise llvm appears to have been built fine and llvm object directory tree also looks OK.

What I am doing wrong? Any help would be much appreciated!

***** Error Messages

sh: llvm-config: command not found

In file included from /mingw/lib/gcc/mingw32/…/…/…/include/llvm/Type.h:15,

from /mingw/lib/gcc/mingw32/…/…/…/include/llvm/DerivedTypes.h:21,

from main.cpp:10:

/mingw/lib/gcc/mingw32/…/…/…/include/llvm/System/DataTypes.h:45:3: error: #error “Must #define __STDC_LIMIT_MACROS before #including System/DataTypes.h”

/mingw/lib/gcc/mingw32/…/…/…/include/llvm/System/DataTypes.h:49:3: error: #error "Must #define __STDC_CONSTANT_MACROS before " “#including System/DataTypes.h”

In file included from /mingw/lib/gcc/mingw32/…/…/…/include/llvm/Attributes.h:18,

from /mingw/lib/gcc/mingw32/…/…/…/include/llvm/Argument.h:18,

from /mingw/lib/gcc/mingw32/…/…/…/include/llvm/Function.h:24,

from /mingw/lib/gcc/mingw32/…/…/…/include/llvm/Module.h:18,

from main.cpp:12:

/mingw/lib/gcc/mingw32/…/…/…/include/llvm/Support/MathExtras.h: In function ‘bool llvm::isInt(int64_t)’:

/mingw/lib/gcc/mingw32/…/…/…/include/llvm/Support/MathExtras.h:57: error: there are no arguments to ‘INT64_C’ that depend on a template parameter, so a declaration of ‘INT64_C’ must be available

/mingw/lib/gcc/mingw32/…/…/…/include/llvm/Support/MathExtras.h:57: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)

/mingw/lib/gcc/mingw32/…/…/…/include/llvm/Support/MathExtras.h:57: error: there are no arguments to ‘INT64_C’ that depend on a template parameter, so a declaration of ‘INT64_C’ must be available

/mingw/lib/gcc/mingw32/…/…/…/include/llvm/Support/MathExtras.h: In function ‘bool llvm::isUint(uint64_t)’:

/mingw/lib/gcc/mingw32/…/…/…/include/llvm/Support/MathExtras.h:62: error: there are no arguments to ‘UINT64_C’ that depend on a template parameter, so a declaration of ‘UINT64_C’ must be available

Hello, António.

I’m having a few problems building the kaleidoscope example (chapter 3)
under MinGW. To build the example I use as recommended

g++ -g -O3 toy.cpp `llvm-config --cppflags --ldflags --libs core` -o toy
sh: llvm-config: command not found

You need MSYS's perl to use llvm-config on mingw.

Does this below work?
-D_DEBUG (might be -DNDEBUG)
-D__NO_CTYPE_INLINE
-D_GNU_SOURCE
-D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS
-lLLVMCore -lLLVMSupport -lLLVMSystem
-lpsapi -limagehlp -lm

...Takumi

Hello,

Takumi, you are absolutely right! It was a problem with Perl. Many thanks!
That problem solved, tried to compile again the kaleidoscope example but unfortunatelly now I get the link errors found bellow:

$g++ -g –O3 toy.cpp llvm-config –cppflags –ldflags –libs core-o toy

c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x4d4): undefined reference to _imp__SymSetOptions@4' c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x463): undefined reference to _imp__SymInitialize@12’
c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x46c): undefined reference to _imp__SymGetModuleBase@8' c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x47a): undefined reference to _imp__SymFunctionTableAccess@8’
c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x4b2): undefined reference to _imp__StackWalk@36' c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x567): undefined reference to _imp__SymGetModuleBase@8’
c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x611): undefined reference to _imp__SymGetSymFromAddr@16' c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x6ae): undefined reference to _imp__SymGetLineFromAddr@16’

c:/llvm-2.7/Release/lib/libLLVMSystem.a(Process.o):Process.cpp:(.text+0x8d):

undefined reference to `GetProcessMemoryInfo@12’
collect2: ld returned 1 exit status

I built again LLVM now with perl working properly.
Any help would be great
Antonio

2010/9/7 NAKAMURA Takumi <geek4civic@gmail.com>

Good afternoon, António.

$g++ -g –O3 toy.cpp `llvm-config –cppflags –ldflags –libs core`-o toy

c:/llvm-2.7/Release/lib/libLLVMSystem.a(Signals.o):Signals.cpp:(.text+0x4d4):
undefined reference to `_imp__SymSetOptions@4'

I guess it might be a known issue;
http://llvm.org/bugs/show_bug.cgi?id=3347

Would you like me to show the result of "llvm-config –cppflags
–ldflags –libs core"?
And please try specifying libs (-lLLVMCore -lLLVMSupport -lLLVMSystem
-lpsapi -limagehlp -lm) manually.

...Takumi

Hi, Takumi!

Running llvm-config --cppflags –-ldflags –-libs core gives:

-Ic:/llvm-source-2.7/include –I/c/llvm-2.7/include –D_DEBUG –D__NO_CTYPE_INLINE –D_GNU_SOURCE –D__STDC_LIMIT_MACROS –D__STDC_CONSTANT_MACROS -L/c/llvm-2.7/Release/lib –lpsapi –limagehlp –lm –lLLVMCore –lLLVMSupport –lLLVMSystem

I followed your suggestion and changed libs order manualy to:

–lLLVMCore –lLLVMSupport –lLLVMSystem –lpsapi –limagehlp –lm

and it worked like a charm !!! Everything compiled fine!

Many many thanks!!
Antonio

2010/9/7 NAKAMURA Takumi <geek4civic@gmail.com>