symbol(s) not found for architecture x86_64 os x lion
Solution 1
This looks like you are not linking against the library correctly. There are at least two similar questions on stackoverflow that deal with this issue, namely this one and that one. Did you take a look at them? Furthermore, please supply more information about how you are compiling. Can you compile a simple OpenCV test program such as this one (taken from their wiki):
#include <cv.h>
#include <highgui.h>
int main ( int argc, char **argv )
{
cvNamedWindow( "My Window", 1 );
IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
CvFont font;
double hScale = 1.0;
double vScale = 1.0;
int lineWidth = 1;
cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
hScale, vScale, 0, lineWidth );
cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font,
cvScalar( 255, 255, 0 ) );
cvShowImage( "My Window", img );
cvWaitKey();
return 0;
}
Solution 2
I generated this error when I accidentally combined separate target_link_libraries() in my CMakeLists.txt file when compiling with cmake.
Specifically, I took the correct:
target_link_libraries(
GradientComputer
)
target_link_libraries(
Overlap
PointAreaComputer
)
and combined them to create the incorrect:
target_link_libraries(
GradientComputer
Overlap
PointAreaComputer
)
Courier
Updated on March 18, 2020Comments
-
Courier about 4 years
When trying to compile a simple c++ test.cpp code with opencv 2.3.1 as as third library, I get the following error message:
Undefined symbols for architecture x86_64:
"_cvLoadImage", referenced from: _main in test.cpp.o ld: symbol(s) not found for architecture x86_64For info, am using CMake for linking, and gcc 4.2.1 i686-apple-darwin11 obtained from Xcode 4.2. OpenCV had been installed using CMake:
ccmake ../sourcecodeNote please that I get a similar message when trying to compile SoQt (coin3D), after commands ./configure & sudo make:
. . .
"typeinfo for QWidget", referenced from: typeinfo for SoQtThumbWheelin SoQtThumbWheel.o "QWidget::staticMetaObject", referenced from: SoQtThumbWheel::staticMetaObject in SoQtThumbWheel.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit statusThe CMakeLists.txt of the main project is:
cmake_minimum_required(VERSION 2.8) PROJECT(TOTO ) FIND_PACKAGE(OpenCV) INCLUDE_DIRECTORIES(${TOTO_SOURCE_DIR}/src/control) SET(ALL_LIB_RAF ${OPENCV_LIBRARIES} Hello ) # FILEs to consider ADD_SUBDIRECTORY(main) ADD_SUBDIRECTORY( src )
While the CMakeLists.txt for test.cpp is:
ADD_EXECUTABLE(helloWorld test) TARGET_LINK_LIBRARIES(helloWorld ${ALL_LIB_RAF} )
Perhaps the issue consists in the fact that OpenCV needs to be compiled in 64-bit (?). I found an interesting link. But am wondering how that mights be applied to CMake.
Any help please?
Thanks.