Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: "target links to: lsqcpp::lsqcpp but the target was not found" #10

Open
trufanov-nok opened this issue Jul 21, 2023 · 3 comments

Comments

@trufanov-nok
Copy link

trufanov-nok commented Jul 21, 2023

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?

@trufanov-nok
Copy link
Author

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)

@Rookfighter
Copy link
Owner

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!

@Rookfighter
Copy link
Owner

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.

myproject.tar.gz

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants