Help! Linking to external functions.

Hi. I've had moderate success so far with LLVM. I've got an OS X app in Xcode that is able to parse my DSL, generate code into an LLVM Module, and pass it to an ExecutionEngine to execute.

But now I'm stuck.

That code needs to reference an external function I define in my app. If I define that function in the same source file as the file that invokes the ExecutionEngine, everything is fine. But if I define that function in a separate file, it does not work correctly (LLVM says "LLVM ERROR: Program used external function 'foo' which could not be resolved!").

I've verified that the function is in fact linked in, by calling it once from the same code that invokes the ExecutionEngine. This works. But for some reason, LLVM can't see it. It is 'extern "C"'.

What am I missing? Thanks!

Solved my own problem.

I had declared my function inside an 'extern "C"' block like this:

#ifndef __cplusplus
extern "C" {

Notice my error? Should be "#ifdef", not "@ifndef".