least-squares-cpp
least-squares-cpp copied to clipboard
cmake: "target links to: lsqcpp::lsqcpp but the target was not found"
Hi, I've just tried to link lsqcpp. According to the readme it requires installation (installed to /usr) and
find_package(lsqcpp REQUIRED)
add_executable(myproject main.cpp)
target_link_libraries(myproject lsqcpp::lsqcpp)
But this leads to error:
-- Configuring done
CMake Error at myproject/CMakeLists.txt:22 (target_link_libraries):
Target "myproject" links to:
lsqcpp::lsqcpp
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
In lsqcpp/lsqcpp-config.cmake I can see following:
add_library(lsqcpp INTERFACE)
target_include_directories(lsqcpp INTERFACE "${lsqcpp_INCLUDE_DIR}")
target_link_libraries(lsqcpp INTERFACE Eigen3::Eigen)
add_library(lsqcpp::lsqcpp ALIAS lsqcpp)
So instead of target_link_libraries(myproject lsqcpp::lsqcpp) I tried just target_link_libraries(myproject lsqcpp) - it works.
I'm not a cmake expert, could you doublecheck if readme instructions are still actual?
And still I'm getting:
/usr/bin/ld: cannot find -llsqcpp: No such file or directory
collect2: error: ld returned 1 exit status
error, unless I specify cmake_policy(VERSION 2.8.3...3.23) at the top of lsqcpp/lsqcpp-config.cmake
(I just tested all stuff from eigen3/cmake/Eigen3Targets.cmake)
Hi @trufanov-nok,
thanks for using least-squares-cpp! I'm investigating your problem and I'll try to reproduce it on my side. Just from looking at the code it looks alright to be honest. I'll keep you updated!
Alright I realized that in the README a find_package(Eigen3 REQUIRED) was missing, so I updated the instructions. So after I installed least-squares-cpp as instructed in the README I get the following output:
-- Install configuration: ""
-- Up-to-date: /usr/local/include/lsqcpp
-- Installing: /usr/local/include/lsqcpp/lsqcpp.hpp
-- Installing: /usr/local/lib/lsqcpp/lsqcpp-config.cmake
I was then able to compile the following minimal example.
If you still run into problems, please let me know so we can dive into the issue. In that case it would be useful for me to know which system (ubuntu?) you are using and which CMake Version