I am trying to use LZF C++. However, when I compile it, it give me this error:
g++ -o dist/Debug/GNU-MacOSX/cppapplication_2 build/Debug/GNU-MacOSX/lzf_c.o build/Debug/GNU-MacOSX/lzf_d.o build/Debug/GNU-MacOSX/main.o
Undefined symbols for architecture x86_64:
"lzf_compress(void const*, unsigned int, void*, unsigned int)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1
I already included lzf.h.
A quick look at lzf.h shows that it doesn't account for C++. Normally you would see something like
So that the C++ compiler knows to look for C symbols. I'm guessing what is happening with your code is that the C++ compiler is requesting whatever it mangles the C++ symbol
lzf_compress
to instead of just the C symbollzf_compress
. However, since the actual code is in a C file your build system probably uses the C compiler (not the C++ compiler) to compile it.If I were you I would fix the header, and file a bug (with a patch) to get the fix upstream.
If you don't want to fix
lzf.h
I think you could just do something likeThe other "solution" would be to just compile everything with the C++ compiler. I'm not certain liblzf is valid C++, though, so that may or may not work.