compiling the tutorial

Hi,
I'm investigating adding LLVM JIT support to a project of mine, but I'm having issues when trying to compile the Kaleidoscope tutorial* under MSVC 2008.
In particular, the problem is that in main() when this line is executed

  // Create the JIT.
  TheExecutionEngine = ExecutionEngine::create(TheModule);

create returns null, because both JITCtor and InterpCtor are null.
I found this comment in ExecutionEngine.h

  // To avoid having libexecutionengine depend on the JIT and interpreter
  // libraries, the JIT and Interpreter set these functions to ctor pointers
  // at startup time if they are linked in.
  typedef ExecutionEngine *(*EECtorFn)(ModuleProvider*, std::string*,
                                       bool Fast);
  static EECtorFn JITCtor, InterpCtor;

so I suppose that somehow I'm missing a library, but in my project settings I added "<path_to_project>\llvm\*.lib" in the

additional dependencies (proof it works is that the

tutorial compiles and links just fine), and the contents of that directory are

Analysis.lib
analysis.pdb
Archive.lib
archive.pdb
AsmParser.lib
asmparser.pdb
Bitcode.lib
bitcode.pdb
CBackend.lib
cbackend.pdb
CodeGen.lib
codegen.pdb
ExecutionEngine.lib
executionengine.pdb
Linker.lib
linker.pdb
support.lib
support.pdb
System.lib
system.pdb
Target.lib
target.pdb
Transforms.lib
transforms.pdb
VMCore.lib
vmcore.pdb
x86.lib
x86.pdb

i.e. all the libraries created by the bundled llvm msvs solution, except for the CLI programs.
so I'm stuck, because it looks like the libraries are being linked (otherwise the tutorial wouldn't even link) but somehow something goes wrong and those static variables are not set. I also tried to place a breakpoint on JIT::Register() but it is never reached. any clue why?
my environment is Vista x86 SP1, MSVS 2008.
thank you very much for your attention,
Carlo Alberto Ferraris

* great tutorial, btw!

Carlo Alberto Ferraris <cafxx@strayorange.com> writes:

Hi,
I'm investigating adding LLVM JIT support to a project of mine, but I'm
having issues when trying to compile the Kaleidoscope tutorial* under
MSVC 2008.
In particular, the problem is that in main() when this line is executed

  // Create the JIT.
  TheExecutionEngine = ExecutionEngine::create(TheModule);

create returns null, because both JITCtor and InterpCtor are null.
I found this comment in ExecutionEngine.h

Does it work if you add to the link command
/INCLUDE:_X86TargetMachineModule

?

[snip]

Óscar Fuentes ha scritto:

Carlo Alberto Ferraris  writes:
  
Hi,
I'm investigating adding LLVM JIT support to a project of mine, but I'm 
having issues when trying to compile the Kaleidoscope tutorial* under 
MSVC 2008.
In particular, the problem is that in main() when this line is executed
    
  // Create the JIT.
  TheExecutionEngine = ExecutionEngine::create(TheModule);
      
create returns null, because both JITCtor and InterpCtor are null.
I found this comment in ExecutionEngine.h
    

Does it work if you add to the link command
/INCLUDE:_X86TargetMachineModule

?

[snip]

I tried linking the tutorial adding that command but JITCtor and InterpCtor are still null, both in debug and release builds.
Was by any chance that command meant to be used when building the llvm solution?

Carlo Alberto Ferraris <cafxx@strayorange.com> writes:

I'm investigating adding LLVM JIT support to a project of mine, but
I'm having issues when trying to compile the Kaleidoscope tutorial*
under MSVC 2008.
In particular, the problem is that in main() when this line is executed
    

  // Create the JIT.
  TheExecutionEngine = ExecutionEngine::create(TheModule);
      

create returns null, because both JITCtor and InterpCtor are null.
I found this comment in ExecutionEngine.h
    
Does it work if you add to the link command
/INCLUDE:_X86TargetMachineModule

?

[snip]

I tried linking the tutorial adding that command but JITCtor and
InterpCtor are still null, both in debug and release builds.
Was by any chance that command meant to be used when building the llvm
solution?

No, that directive is not needed for building the libraries, it is
used for forcing the linker to include into the executable some global
objects that register themselves. The _X86TargetMachineModule is for the
x86 target.

Does the Fibonacci example works? (look into examples/Fibonacci). It
uses the JIT too. Look at its project settings and try using the same
ones on your project.