title: How to call function in LLVM
body: <p>I would like to ask you on the proper way to call/bind own c++ function into LLVM.</p>
  
  <p>I have coded simple function:</p>
  
  <pre><code>void writeSomething() {
      std::cout &lt;&lt; "Awesome" &lt;&lt; std::endl;
  } 
  </code></pre>
  
  <p>In LLVM I am trying to register the function. I have created the external linkage to it.</p>
  
  <pre><code>      // Void type
  llvm::FunctionType* fccType =
          llvm::FunctionType::get(
              llvm::Type::getVoidTy(getGlobalContext()), false
          );
  
  // External - c++
  Function *fcc = (Function*) module-&gt;getOrInsertFunction("writeSomething",
          fccType
          );
  
  // Call
  std::vector&lt;Value*&gt; emptyArgs;
  CallInst::Create(fcc, makeArrayRef(emptyArgs));
  </code></pre>
  
  <p>LLVM Output for just calling this function is 
  ( // comments are mine input how do I understand the output )</p>
  
  <pre><code>// External linkage
  declare void @writeSomething()
  
  define internal void @main() {
  entry:
    // Call my function
    call void @writeSomething()
    ret void
  }
  </code></pre>
  
  <p>The program ends with message: <em>LLVM ERROR: Program used external function 'writeSomething' which could not be resolved!</em></p>