I am trying to install libraries like eigen, sharkMl, xtensor, and others in VSCode for C++. Please if anyone can help me to know the right way to do that.
-
Eigen can be installed [from MSYS2](https://stackoverflow.com/q/30069830/2752075), along with an up-to-date GCC and a good build environment. The other two you'll probably have to build from source, they should include build instructions. – HolyBlackCat Dec 01 '21 at 19:45
1 Answers
All of these libraries use CMake for their build system so what I do is use CMake as my build system. My favorite way to do this is to use the libraries build systems to install them and then inlcude them with cmakes find_package
function. This you can do by cloning the git repository for the library then build it and install it with cmake. On linux you do this by:
git clone https://gitlab.com/libeigen/eigen.git
cd eigen
mkdir build
cd build
cmake ..
sudo make install
VSCode has good integration for cmake so if you have the C/C++ Extension pack you will be able to build with cmake. In your project folder make a CMakeLists.txt file and add the packages you want:
add_executable(main main.cpp)
find_package(Eigen3 3.4 NO_MODULE)
target_link_libraries(main Eigen3::Eigen)
(This example assumes the main cpp file is main.cpp and creates an executable called main) Then when you press ctr+shift+p and perform CMake: Configure you can select your compiler and build the executable.

- 41
- 2