g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
I have a static library called sdpAPI.a
I am trying to link my cpp file to it using cmake.
My CMakeLists.txt looks like this?
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(demo_project CXX)
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_C_FLAGS "-Wall -Wextra -Wunreachable-code -O0 -D_DEBUG -ggdb -m32")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
INCLUDE_DIRECTORIES(sdpapi)
LINK_DIRECTORIES(~/projects/test_sdp/sdpapi)
SET(source_files main.cpp)
SET(libs sdpAPI)
ADD_EXECUTABLE(demo ${source_files})
TARGET_LINK_LIBRARIES(demo ${libs})
And my sdpAPI.a is located in this directory test_sdp/sdpapi/sdpAPI.a
The error I am getting is the following:
[100%] Building CXX object CMakeFiles/demo.dir/main.cpp.o
Linking CXX executable demo
/usr/bin/ld: cannot find -lsdpAPI
collect2: ld returned 1 exit status
make[2]: *** [demo] Error 1
make[1]: *** [CMakeFiles/demo.dir/all] Error 2
make: *** [all] Error 2
Can anyone see anything obvious that I am doing wrong.
I should have renamed sdpAPI.a
to libsdpAPI.a
This solved my problem. A silly mistake which cost me 3 hours.
Hope this helps someone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With