Am Dienstag, 14. Mai 2013, 19:05:13 schrieb Vojtěch Novák:

> hello,

> I'm working on a C++ package for ROS (robot operating system) that uses a C
> library libccv.a. ROS uses CMake which is why I am asking here. Asking at
> ROS answers did not help and I am totally stuck.

[...]

From a quick look at your pastes and your cmake lists, i can't see anything 
that should cause the problem you're facing here.

However, from the error message that gcc gives, it can be assumed that there 
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:

        struct bar;
        void foo(bar*);

        int main() {
                bar* b;
                foo(b);
        }

will give the error:
        x.cpp:(.text+0x10): undefined reference to `foo(bar*)'
when compiled as c++.

Contrary this program:

        extern "C" {
                struct bar;
                void foo(struct bar*);
        }

        int main() {
                bar* b;
                foo(b);
        }


will result in the error:
        x.cpp:(.text+0x10): undefined reference to `foo'

Note that the former refers to a mangled c++ symbol while the latter refers to 
an unmangled C symbol.

Usually, a C header file should include the following lines:

        #ifdef __cplusplus
        extern "c" {
        #endif

                // normal C-Code here

        #ifdef __cplusplus
        }
        #endif

As a workaround, you could write a file named ccv.hpp and put this content 
into it:

        extern "C" {
        #include "ccv.h"
        }

Then go through your C++ sources and change every include of "ccv.h" to 
"ccv.hpp".

Hope this helps,
Sascha

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to