I've created a library and installed it in /usr/lib (using cmake) eg.:
set(CMAKE_INSTALL_PREFIX /usr/)
target_link_libraries(ssd1306)
set_target_properties(ssd1306 PROPERTIES VERSION 1.0.0 SOVERSION 1 )
install(TARGETS ssd1306 DESTINATION lib)
install(FILES ${SSD1306_HEADERS} DESTINATION include)
This worked fine and the library is present on my filesystem: The library:
ls -l /usr/lib/libssd1306*
/usr/lib/libssd1306.so -> libssd1306.so.1
/usr/lib/libssd1306.so.1 -> libssd1306.so.1.0.0
/usr/lib/libssd1306.so.1.0.0
And the header:
ls -l /usr/include/ssd1306.h
/usr/include/ssd1306.h
Then I wrote a program which use the library (again using cmake):
target_link_libraries(ssd1306-info libssd1306)
But for some reason it will not link to my library at compile time:
/usr/bin/ld: cannot find -llibssd1306
The header file was found and the object file was created, but linking failed.
Of course /usr/lib/ is in g++ search path:
g++ -print-search-dirs
install: /usr/lib/gcc/x86_64-linux-gnu/5/ programs: =/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/bin/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/bin/ libraries: =/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/lib/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/5/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/5/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
What do I do wrong?
make
in verbose mode to see how it attempt to build your program. You do it by adding theVERBOSE=1
argument when runningmake
. – Some programmer dudetarget_link_libraries(ssd1306-info ssd1306)
? – skypjack