0

I have a libname.a static library that works fine when I use gcc:

gcc -c main.c -o main.o ;
gcc main.o libname.a main

But now I would like to use CMake as the project is getting big, but I got this message and and I don't know how to include it in an appropriate way. (I tried link_target_library and/or link_directories and/or set(CMAKE_CC_FLAGS "absolute_path/libname.a").

Note that I don't have any source code for libname.a.

/usr/bin/ld: cannot find -llibname

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
N. F.
  • 1

1 Answers1

0

As said in my comment target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libname.a) works. I can't really tell what the reason for your problem is (maybe you used target_link_library instead of target_link_libraries ?).

gotocoffee
  • 199
  • 10