I am compiling some source that is linked to two packages. One is OpenCV and the other is a driver library for an infrared camera. The company only provides a 32-bit version of the library via an rpm package. I compiled OpenCV from source and it's libraries are installed in /usr/local/lib64. I am running Fedora 18 64-bit version. Here is my CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED(VERSION 2.6) 
PROJECT(xeneth_test) 

SET(CMAKE_MODULE_PATH ${CMAKE_MODULES_PATH} /home/sam/Documents/common/CMakeModules) 
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 
SET(CMAKE_CXX_FLAGS "-m32") 

FIND_PACKAGE(Xeneth REQUIRED) 
INCLUDE_DIRECTORIES(${LIBXENETH_INCLUDE_DIRS}) 

FIND_PACKAGE(OpenCV REQUIRED) 

#GENERATE EXECUTABLES 
ADD_EXECUTABLE(myXenethTest src/myXenethTest.cpp) 
TARGET_LINK_LIBRARIES(myXenethTest ${XENETH_LIBRARIES} ${OpenCV_LIBS})

When I run make I get:

Scanning dependencies of target myXenethTest
[100%] Building CXX object CMakeFiles/myXenethTest.dir/src/myXenethTest.cpp.o
Linking CXX executable bin/myXenethTest
/usr/local/lib64/libopencv_calib3d.so: could not read symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [bin/myXenethTest] Error 1
make[1]: *** [CMakeFiles/myXenethTest.dir/all] Error 2
make: *** [all] Error 2

This is probably because I am trying to link my target against a 64-bit compiled OpenCV and the 32-bit Xeneth libraries. I have to inlude the -m32 compiler flag, otherwise the libxeneth library won't be used. I just started recently with this whole 64-bit computing and after some time trying to find a solution, I am quite lost. Looking forward to any input/suggestions/answers to my problem. Thanks for your time.

-Sam

32-bit binaries cannot be mixed with 64-bit binaries, period. There is no (easy) way to create an application that would link to some 32-bit libraries and some 64-bit libraries at the same time. Basically, if the program is 32-bit, then all its libraries (include shared-objects (.so files)) must also be 32-bit, and the same for 64-bit. The two cannot mix. In other words, x86-64 platforms can run either processes that are either 32bit or 64bit, but not a process that has a mix of both.

The solution is to compile OpenCV in 32bit too. (or get a 32bit version (i686) from a ppa repository).

Thanks for the reply. I had a feeling there was nothing else to do. I'll probably just have the 32-bit driver run as a seperate program and read the data from it through a shared memory buffer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.