Ok, so calling lle_X_FUNCTIONNAME instead of FUNCTIONNAME works (is there any reason the post used the lle_X_ prefix other than convention? was it once possible to call external functions as I was originally trying, or, why did the blog post think it was possible?)<div>

<br></div><div>I'm now running into trouble when trying to access arguments however. printing args.size() from the function yields 12105250188025543488. The generated call to it looks like:</div><div><br></div><div>%object_tmp = call %object_structure* @lle_X_create_number_object(double 5.000000e+00) ; <%object_structure*> [#uses=1]</div>

<div><div><br></div><br><div class="gmail_quote">On Thu, Aug 19, 2010 at 6:56 PM, Alec Benzer <span dir="ltr"><<a href="mailto:alecbenzer@gmail.com">alecbenzer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

The blog post I linked to implied that adding a symbol in the form lle_X_FUNCTIONNAME would allow you to call a function called FUNCTIONNAME. Is this not the case?<div><div></div><div class="h5"><br><br><div class="gmail_quote">

On Thu, Aug 19, 2010 at 6:46 PM,  <span dir="ltr"><<a href="mailto:o.j.sivart@gmail.com" target="_blank">o.j.sivart@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>You are adding the symbol as "lle_X_create_number_object" yet your error message implies you have tried to lookup and use "create_number_object". Can you provide the code for the lookup?</div>


<br><div><div><div></div><div><div>On 20/08/2010, at 8:07 AM, Alec Benzer wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div>Is there documentation somewhere on how to call external functions from llvm? The only guide I found was this: <a href="http://www.gearleaf.com/blog/post/44" target="_blank">http://www.gearleaf.com/blog/post/44</a>, and it doesn't seem to be working for me.<div>




<br></div><div>I have a function:</div><div><br></div><div><div>llvm::GenericValue lle_X_create_number_object(llvm::FunctionType* ft, const std::vector<llvm::GenericValue>& args)</div><div>{</div><div>  llvm_object_structure* result = new llvm_object_structure;</div>




<div>  result->typeIdx = TypeSystem::number;</div><div>  result->data = reinterpret_cast<unsigned char*>(new double(args[0].DoubleVal));</div><div>  llvm::GenericValue gv;</div><div>  gv.PointerVal = reinterpret_cast<void*>(result);</div>




<div>  return gv;</div><div>}</div></div><div><br></div><div>defined in an extern "C" block. I add it as a symbol with: </div><div><br></div><div><div>llvm::sys::DynamicLibrary::AddSymbol("lle_X_create_number_object",(void*)lle_X_create_number_object);</div>




</div><div><br></div><div>yet when attempting to call it I still get: "LLVM ERROR: Program used external function 'create_number_object' which could not be resolved!"</div></div></div><div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>


<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></div><br></div></blockquote></div><br>
</div></div></blockquote></div><br></div>