No subject
Wed Apr 10 07:51:04 EDT 2013
hing=20
that should cause the problem you're facing here.
However, from the error message that gcc gives, it can be assumed that =
there=20
is a problem in the library you're trying to use:
When using C code from a C++ library, the C code must be wrapped with a=
extern "C"
declaration.
This program:
=09struct bar;
=09void foo(bar*);
=09int main() {
=09=09bar* b;
=09=09foo(b);
=09}
will give the error:
=09x.cpp:(.text+0x10): undefined reference to `foo(bar*)'
when compiled as c++.
Contrary this program:
=09extern "C" {
=09=09struct bar;
=09=09void foo(struct bar*);
=09}
=09int main() {
=09=09bar* b;
=09=09foo(b);
=09}
will result in the error:
=09x.cpp:(.text+0x10): undefined reference to `foo'
Note that the former refers to a mangled c++ symbol while the latter re=
fers to=20
an unmangled C symbol.
Usually, a C header file should include the following lines:
=09#ifdef __cplusplus
=09extern "c" {
=09#endif
=09=09// normal C-Code here
=09#ifdef __cplusplus
=09}
=09#endif
As a workaround, you could write a file named ccv.hpp and put this cont=
ent=20
into it:
=09extern "C" {
=09#include "ccv.h"
=09}
Then go through your C++ sources and change every include of "ccv.h" to=
=20
"ccv.hpp".
Hope this helps,
Sascha
More information about the CMake
mailing list