mercredi 27 mai 2020

CMakeFiles: undefined reference to 'include header file' on running make [duplicate]

My CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

# set the project name and version 
project(test1 VERSION 1.0)

# specify the C++ standard 
set(CMAKE_CXX_STANDARD 11) 
set(CMAKE_CXX_STANDARD_REQUIRED True) 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_UNIX_ -D_LINUX_")


include_directories("/opt/workswell/wic_sdk/include/"
                  "/opt/pleora/ebus_sdk/Ubuntu-x86_64/include/"
                          ) 
link_directories("/opt/workswell/wic_sdk/lib/"
                  "/opt/pleora/ebus_sdk/Ubuntu-x86_64/lib/")

add_executable( test1 test_cam.cpp)

where the header files and libraries are pointing to the WIC sdk

my Source file : test_cam.cpp

#include <pthread.h>
#include <iostream>
#include <string>
#include <jpeglib.h>
#include "CameraCenter.h"

int main() {
    uint16_t *buffer;

    cout << "WIC_SDK_Sample" << endl;

    //creates a list of connected camera objects
    CameraCenter *cameras = new CameraCenter("/opt/workswell/wic_sdk/sample/src/"); // Path to folder containing license file

    cout << "Number of detected cameras: " << cameras->getCameras().size() << endl;

    if (cameras->getCameras().size() == 0) {
        cout << "No camera found!" << endl;
        return -1;
    }
}

where CameraCenter header file is from the sdk

on running cmake.. it configures and generates properly but on doing make it gives error:

[ 50%] Linking CXX executable test1
CMakeFiles/test1.dir/test_cam.cpp.o: In function `main':
test_cam.cpp:(.text+0x7d): undefined reference to `CameraCenter::CameraCenter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: error: ld returned 1 exit status
CMakeFiles/test1.dir/build.make:94: recipe for target 'test1' failed
make[2]: *** [test1] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/test1.dir/all' failed
make[1]: *** [CMakeFiles/test1.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Solution tried:

added target_link_libraries

target_link_libraries(test1 "/opt/workswell/wic_sdk/lib/libWIC_sdk.so"
                      "/opt/pleora/ebus_sdk/Ubuntu-x86_64/lib/"  )

New Error in make :

make[2]: *** No rule to make target '/opt/workswell/wic_sdk/lib/libWIC_sdk.so', needed by 'test1'.  Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/test1.dir/all' failed
make[1]: *** [CMakeFiles/test1.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

P.S. the header file is pointing to the sdk

Please suggest what could be the problem here,and how can I resolve it, as it is not able to connect to the header files

Aucun commentaire:

Enregistrer un commentaire