I am trying to bind C ++ in Haskell and throw "undefined reference" errors when calling a binding.
I did a small project ( http://github.com/deech/CPlusPlusBindings ) to illustrate the problem. It includes a small C ++ class, a C shell, a C test script and a Haskell binding and test script. The C script test works, Haskell gives me:
[1 of 1] Compiling Binding ( dist/build/Binding.hs, dist/build/Binding.o ) src/Binding.chs:6:26: Warning: Defined but not used: `res' In-place registering CPlusPlusBinding-0.1.0.0... Preprocessing executable 'binding_test' for CPlusPlusBinding-0.1.0.0... [1 of 1] Compiling Main ( src/BindingTest.hs, dist/build/binding_ /binding_test-tmp/Main.o ) src/BindingTest.hs:3:1: Warning: Top-level binding with no type signature: main :: IO () Linking dist/build/binding_test/binding_test ... ../CPlusPlusBinding/c-src/libA_C.a(A_C.o): In function `A_static_function': ../CPlusPlusBinding/c-src/A_C.cpp:4:0: undefined reference to `A::static_function()' ../CPlusPlusBinding/c-src/libA_C.a(A_C.o): In function `A_member_function': ../CPlusPlusBinding/c-src/A_C.cpp:7:0: undefined reference to `A::member_function()' ../CPlusPlusBinding/c-src/libA_C.a(A_C.o): In function `A_new': ../CPlusPlusBinding/c-src/A_C.cpp:10:0: undefined reference to `operator new(unsigned long)' collect2: error: ld returned 1 exit status
Running cabal configure
and cabal build
will compile the C ++ and C bindings and reproduce the error.
Update
I solved the problem outlined in the comment below. I can't seem to answer my question.
Deech source share