Probably a dumb / simple question, but I have not been able to find an answer. I have no clue how adding libraries works with CodeBlocks c++. I downloaded the .zip file from http://eigen.tuxfamily.org/index.php?title=Main_Page and extracted the files into my directory. How can I use this library now in my project?
It's a template library. You can put it anywhere as long as it's in the path (accessible). Just include the proper headers and it should work. No need to link anything, everything is in the headers.
PATH=$PATH:$HOME/my_library_path_to_include
–
Hinson Add one line of code to your source file where you want to use Eigen.
#include "Eigen/Dense"
Put Eigen (extracted zip file) in a directory where you put your existing working header file.
Personally I had no idea how to install eigen on code blocks, but those are the steps I made and it worked:
- unpack the ZIP into some arbitary folder
- go to codeblocks Settings-> complier-> Search Directories-> Add-> enter the address of the folder you chose in (1)-> o.k
- declare
#include "Eigen/Dense"
before the main function.
I learned the steps from here
Compiler
, Linker
, Resource compiler
. We have select Compiler
tab under Search Directories
beforing selecting Add
. –
Melton in my radio astronomy project i install Eigen by the following command:
sudo apt-get install libeigen3-dev
my cmake automatically find the eigen header which i used. it is a sample of my header
#include <eigen3/Eigen/Core>
This one was a tricky one for me. I am using Code::Blocks Ver 17.12.
a) I downloaded Eigen 3.3.5 (http://eigen.tuxfamily.org/index.php?title=Main_Page). The zip file downloaded is named as "eigen-eigen-b3f3d4950030"
b) Extracted the file to my project folder.
c) Changed the name of the extracted file from "eigen-eigen-b3f3d4950030" to "Eigen3" (you can choose any name).
d) Inside this folder, you will find other folders such as bench, blas, cmake, debug....
Now you have to add the library files for your project (so that the compiler knows where to look for the required library files).
e) In codeblocks, click on Settings --> Compiler --> Search Directories --> Compiler
Click Add and add the Eigen3 folder (the downloaded and extracted folder which was renamed in previous step 'c'). Once added, click on Linker tab (just beside 'Compiler' tab) and add the same path to Eigen3 folder.
f) Now click on Build Options tab, which is found besides 'Search Directories' tab.
g) Tick the "Explicitly add currently compiling file's directory to compiler search dirs" h) Tick the "Explicitly add project's top-level directory to compile search dirs"
i) Click OK.
Now your build should work and the compiler knows how to search for Eigen libraries.
Any issues, just post it here.
Best wishes
Shre
It's a template library. You can put it anywhere as long as it's in the path (accessible). Just include the proper headers and it should work. No need to link anything, everything is in the headers.
PATH=$PATH:$HOME/my_library_path_to_include
–
Hinson © 2022 - 2024 — McMap. All rights reserved.