views:

1726

answers:

2

When I connect a library to my program, Eclipse doesn't generate any executable file, I get only an object file. When I disconnect the library from my program (delete all paths and library functions), I get an executable.

However, I don't get any error in the first case.

What is going wrong?

I work with: Linux, C, Eclipse.

Log:

** Build of configuration Debug for project Wise_test_C **

make all 
Building target: Wise_test_C
Invoking: GCC C Linker
gcc -L"/export/home/pdmazubi3/workspace/WISE_C/Debug" -o"Wise_test_C"  ./src/Wise_test_C.o   -lWISE_C
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvGetRawData'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvPow'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCreateGraphScanner'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `sqrt'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvColorToScalar'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `Fuzzy10'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvExp'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvTransform'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvReleaseMat'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvAddS'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvHoughLines2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvSetAdd'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvAvgSdv'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvError'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvSeqSlice'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `floor'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCircle'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvGetCols'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvLoadImage'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvAlloc'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvRead'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvFitLine'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvUndistort2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvLog'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvFree_'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCreateImage'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCalcEMD2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvGetElemType'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvPolyLine'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvFitEllipse2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvBoundingRect'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvPerspectiveTransform'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCalcArrHist'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCalibrateCamera2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `Fuzzy24'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvInvert'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvAvg'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvSum'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvProjectPoints2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvSet'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvFindExtrinsicCameraParams2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvRandArr'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvReshape'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvGetSeqElem'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvBoxPoints'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvSetImageROI'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvMinAreaRect2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvInitSubdivDelaunay2D'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvFindFundamentalMat'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvSet2D'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCvtColor'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvLine'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvReleaseGraphScanner'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvRodrigues2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvKMeans2'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvEllipse'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvInitFont'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvResetImageROI'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvGet2D'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCreateMat'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvFindChessboardCorners'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvGetFileNodeByName'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvSplit'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCartToPolar'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvGetRows'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvCreateSubdiv2D'
/export/home/pdmazubi3/workspace/WISE_C/Debug/libWISE_C.so: undefined reference to `cvConvexHull2'
collect2: ld returned 1 exit status
make: *** [Wise_test_C] Fehler 1
+3  A: 

Look in the logs / build output. The linker can't find the library you mean so compilation stops at object generation.

edit with respect to:

collect2: ld returned 1 exit status

The linker is failing

My guess ... OpenCV isn't being linked
It looks like your program also uses OpenCV. You need to link your executable to openCV so that the symbols in the library libWISE_C.so are resolved. Either add the dependency through eclipse or do it manually. Remember you need to include the opencv headers, include the library path through "-L" and also link the library binary.

In Eclipse, right-click on your project and go to Properties. Next, open the Libraries section under GCC C++ Linker. In the Libraries (-l) panel add an entry with the value for opencv and click OK.

Good LucK

Aiden Bell
But I have linked OpenCV in my library and I don't use anything from OpenCV in my program. Is it not enough? Do I need to link both libraries in me program if only libWISE_C.so need OpenCV?
If you open a terminal and type `ldd libWISE_C.so` in /export/home/pdmazubi3/workspace/WISE_C/Debug/ does opencv show up in the list?
Aiden Bell
Bottom line is opencv isn't being included by your library or program hence the ld error. Use ldd to obtain output on each.
Aiden Bell
+2  A: 

It looks like libWISE_C.so is using OpenCV or a similar library. You must provide that other library on the link line for the executable, or you will not get a successful link.

Since you built libWISE_C.so yourself, you should know which other library all the undefined symbols are supposed to come from.

You may also be able to add this "other library" to the link line of libWISE_C.so itself, and thus free libWISE_C.so clients from the need to do so.

Employed Russian
Hi, I wrote libWISE_C.so myself. I just want to test it.