views:

1392

answers:

2

Hi all!

I have implemented a shared library in Linux and try to test it, but I get an error "undefined reference to `CEDD(char*)'".

I use Eclipse with following parameters:

  • Path to include files (here is everything ok)
  • Path to the library and its name. Path is correct and the name is WISE_C (full name: libWISE_C.so)

My Code:

Test programm I use for tests:

#include <iostream>
#include <Descriptor.h>

int main() {
    char* path = "/export/home/pdmazubi3/workspace/proj1/src/pic.jpg";
    double * cedd = CEDD(path); /////   <-ERROR!

    std::cout << "!!!Hello World!!!" << cedd[1];
    return 0;

}

Header Descriptor.h:

double* CEDD(char* path);

A part of Descriptor.c with desirable function:

#include "Descriptor.h"
#include "highgui.h"
#include "cv.h"

double* CEDD(char* path)
{
    IplImage* srcImg;
    IplImage* ImageGrid;
...
}

What I am doing wrog? I have raed a lot of articles in the Internet but I didn't found a solution.

undefined reference to `CEDD(char*)' is a compiler or linker error?

+1  A: 

Are you sure that you linked the object code generated for descriptor.c when building?

Cătălin Pitiș
No, i am not sure about that. Do I need to do that? I thought that I just need a *.so file and a header *.h.
Look inside so that CEDD symbol is defined there. Then, make sure that the .so file is linked (unfortunately I am not an expert on Eclipse to provide details about the configuration of the environment...)
Cătălin Pitiș
+2  A: 

It's a linker error (although I don't think it usually includes the 'char*' bit), so it seems that it either cannot find your library or the library does not contain the function. The latter might also mean that it does contain the actual function, but with a different name; make sure both projects a compiled as C and not C++.

Edit: I missed that you program is C++ (which also explains the more detailed linker message). In this case you should add extern "C" (conditionally, so it is only used when using C++) to the declaration of CEDD if the library is in C.

mweerden
Great! You are right! Now I use C program to test C library =) BUT when the library is connected (Paths) I don't get any binary file compiled (I also don't get any error). When I delet all paths th the lib, I get an executable at the output! How can i be?
I've got no experience with eclipse and without an error message I'm clueless. Perhaps you can you can get a log of the commands it executes somehow.
mweerden