Cross Compiling Eigen library local to project Error: cannot find -lroot/testappt/local/eigen

Viewed 525

I'm still very new to Cmake and cross-compiling. I successfully integrated the Boost library into this project and am now trying to get the Eigen library to compile with it as well.

Here is my CMakeLists.txt:

cmake_minimum_required(VERSION "3.10.2")
project(testapp2)

# Target operating system name.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
# Name of C compiler.
set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#set(CMAKE_CXX_FLAGS -c  )
#set(CMAKE_SHARED_LINKER_FLAGS
#set(CMAKE_SHARED_LINKER_FLAGS -"Lroot/testapp2/local/boost_1_73_0/lib64-msvc-14.1")
set(BOOST_ROOT "root/testapp2/local/boost_1_73_0") #here or from the command line
set(EIGEN_ROOT "root/testapp2/local/eigen")
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_INCLUDE_DIRS "root/testapp2/local/boost_1_73_0/boost")
#set(Eigen_INCLUDE_DIRS "root/testapp2/local/eigen/cmake")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/local/eigen/cmake")

add_executable(testapp2 main3.cpp)
include_directories("./local/eigen" )
target_include_directories(testapp2 PUBLIC ${Boost_INCLUDE_DIRS}) # ${Eigen_INCLUDE_DIRS})
target_link_libraries(testapp2 ${Boost_LIBRARIES} ${EIGEN_ROOT})

Here is my current error: the cmake builds fine, but when I call make it gives me this error. Also, from above, if I comment back in theE igen_include_dir and the end of the target_include_directory line I get an error saying <Eigen/Dense> cannot be found

Scanning dependencies of target testapp2
[ 50%] Building CXX object CMakeFiles/testapp2.dir/main3.cpp.o
[100%] Linking CXX executable testapp2
/usr/lib/gcc-cross/aarch64-linux-gnu/7/../../../../aarch64-linux-gnu/bin/ld: cannot find -lroot/testapp2/local/eigen
collect2: error: ld returned 1 exit status
CMakeFiles/testapp2.dir/build.make:94: recipe 

Here is my main for reference:

#include<iostream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/math/constants/constants.hpp>
#include <Eigen/Dense>
using boost::multiprecision::cpp_dec_float_50;
using namespace std;
using namespace Eigen;
template<typename T>
inline T circle_area(T r) {
   // pi is predefined constant having value
        using boost::math::constants::pi;
        return pi<T>() * r * r;
 }

main() {
        float f_rad = 243.0/ 100;
        float f_area = circle_area(f_rad);
        double d_rad = 243.0 / 100;
        double d_area = circle_area(d_rad);
        cpp_dec_float_50 rad_mp = 243.0 / 100;
        cpp_dec_float_50 area_mp = circle_area(rad_mp);
        cout << "Float: " << setprecision(numeric_limits<float>::digits10) << f_area <<  endl;
        // Double area
        cout << "Double: " <<setprecision(numeric_limits<double>::digits10) << d_area << endl;
        // Area by using Boost Multiprecision
        cout << "Boost Multiprecision Res: " << setprecision(numeric_limits<cpp_dec_float_50>::digits10) << area_mp << endl;
        MatrixXd m = MatrixXd::Random(3,3);
        m = (m + MatrixXd::Constant(3,3,1.2)) * 50;
        cout << "m =" << endl << m << endl;
        VectorXd v(3);
        v << 1, 2, 3;
        cout << "m * v =" << endl << m * v << endl;
}
0 Answers
Related