title: Create LLVM bytecode from C++ classes
body: <p>I'm writing a compiler for a special purpose language in LLVM. I want to add bindings for a library that is already written in C++. My idea is to compile the library to LLVM bytecode (using <code>clang -emit-llvm -S abc.c</code>) and link it during compilation. This works well for code like</p>
  
  <pre><code>// lib.c
  int f() {
      return 123;
  }
  </code></pre>
  
  <p>But parts of the library are written like</p>
  
  <pre><code>// A.cc
  class A {
      public:
          int f() { return 123; }
  };
  </code></pre>
  
  <p>Which results in empty bytecode files. I know that I can fix this by separating the implementation:</p>
  
  <pre><code>// A.cc
  class A {
      public:
          int f();
  };
  
  int A::f() {
      return 123;
  }
  </code></pre>
  
  <p>But that would be a lot of tedious work. Is there any way to create useful bytecode from my library sources as they are? Or any other way to make the library available in my compiler?</p>