[LLVMdev] LLVM ERROR: Program used external function 'printd' which could not be resolved!

Olivier Meurant meurant.olivier at gmail.com
Sat Oct 9 10:36:11 PDT 2010


With updateGlobalMapping<http://llvm.org/doxygen/classllvm_1_1ExecutionEngine.html#a78c977f1f7c8dab32c31782b2d55c6d4>from
you execution engine ?

Olivier.


2010/10/9 António Saragga Seabra <antseabra at gmail.com>

> Hi,
>
> That seems really simple... just changing the function pointer. But how to
> do it for the 'printd' function in the Kaleidoscope example?
> An example how to do this would be super-great.
>
> Any help will be much appreciated. Thanks!
>
>
>
> On Sat, Oct 9, 2010 at 3:55 PM, OvermindDL1 <overminddl1 at gmail.com> wrote:
>
>> 2010/10/9 António Saragga Seabra <antseabra at gmail.com>:
>>  > I'm on Windows using MinGW...
>> >
>> > 2010/10/9 OvermindDL1 <overminddl1 at gmail.com>
>> >>
>> >> 2010/10/5 António Saragga Seabra <antseabra at gmail.com>:
>> >> > Hi
>> >> >
>> >> > Thank you for your help! Followed your suggestion closely and changed
>> >> > the
>> >> > tutorial library function
>> >> >
>> >> > extern "C"
>> >> > double printd(double X) {
>> >> >   printf("%f\n", X);
>> >> >   return 0;
>> >> > }
>> >> > into
>> >> >
>> >> >
>> >> > export "C" {
>> >> >
>> >> >  void printd(double X) { printf("%f\n", X);return 0;}
>> >> >
>> >> >  typedef void(*pfunc)(double);
>> >> >
>> >> > }
>> >> >
>> >> > adding in main()
>> >> >
>> >> > //typedef void(*pfunc)(double);
>> >> >
>> >> > pfunc printd;
>> >> >
>> >> > HMODULE self = GetModuleHandle(0);
>> >> >
>> >> > printd = (pfunc)GetProcAddress(self, "printd");
>> >> >
>> >> >
>> >> >
>> >> > However I'm getting the same error message. It would be really great
>> if
>> >> > you
>> >> > could point me to what I'm doing wrong
>> >>
>> >> None of that is necessary.
>> >>
>> >> First of all, are you on Windows, or *nix?
>>
>> Then the easiest thing to do is just stuff the function pointer in the
>> global pointer table in your module's JIT, single line of code (which
>> I do not recall off hand, hence you should be asking the list, I will
>> forward this to the list as well).
>>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101009/79df37e0/attachment.html>


More information about the llvm-dev mailing list