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?
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
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
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>
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.
Related
I cannot find a way to add boost in Xcode 11.2.1. I found a setting under the target called "Frameworks and Libraries". I dragged the boost directory there, and it got added to the "Frameworks" section of the project. However, in building the project, it says "file not found". For example:
#include <boost/lambda/lambda.hpp>
results in a "file not found" error. Instead of adding boost, I dragged the entire include area of Macports. It took a while for Xcode to parse through that, but I get the same error. So, under Frameworks it has "include", but it cannot find the relevant hpp file, even though I checked and it's there in the boost tree.
I have installed boost via Macports. It resides in /opt/local/include/boost.
In the Xcode documentation, I saw a reference to "USER_HEADER_SEARCH_PATHS". I figured how to set that in a configuration file, so I added a configuration file to the project. I added this to the configuration file:
USER_HEADER_SEARCH_PATHS = /opt/local/include/boost
but that does not work either. (If I remove the boost, that does not work either).
When I select "include" in the Frameworks location of the project, I see that there are different settings "Identity and Type" for that object (right side of Xcode window). I selected "absolute path" and it shows the full path as /opt/local/include which is correct. However, this does not solve the problem either.
Do I need to create a link in a pre-defined area so that Xcode can find it?
I did find a rather ugly work-around: create a soft link to the boost library in the same area where the STL resides (within the Xcode.app directory structure).
Using the setting only works with individual files. I can add individual file to the setting (via drag and drop), but it won't follow nested directories, so clearly this will not work for a library implemention such as boost.
I prefer to keep dependent libraries inside project area. So here is how I just do it for test:
Create new TestBoost project in Xcode from macOS Command-line App C++ template
(now there is TestBoost folder where TestBoost.xcodeproj is located)
Download latest boost boost_1_72_0.tar.gz and unarchive it
(now there boost_1_72_0 folder with boost)
Copy boost_1_72_0 folder inside project TestBoost folder, so it is located aside of TestBoost.xcodeproj
In Xcode Project Navigator select TestBoost project > select TestBoost target > select Build Settings tab
In Search Paths section select Header Search Path, double click on value area and enter ${SRCROOT}/boost_1_72_0 (leave non-recursive flag)
Delete default main.cpp from TestBoost target (to avoid main function confusing) and add some example from boost for testing, eg. boost_1_72_0/libs/algorithm/example/search_example.cpp
Build & Run > Success
Output:
I am working on an xcode project that requires me to use ITK (a c++ library), I have went through with the installation of ITK, by doing
ccmake InsightToolkit-4.13.1
and then configuring and generating the files, then runing
make
make install
but I do not know how to import the library into the xcode project, where I get the following error every time I try building it:
'itkImage.h' image file not found
I would like to know how could I import it and share it with other people on different computers.
The #include directive comes with two flavors:
With quotes (#include "file.h")
With ankle brackets (#include <file.h>)
The first usually refers to files relative to your project directory. The second is for system libraries.
You can influence the search path in the project setting:
double-click on the project in the project explorer
Click on Build settings
Click on your target
Click on All to view also hidden options
In the section Search Paths you can then update the header search path to include the absolute path of you rlibrary headers. Attention: you have to do this for the Debug and for the Release builds:
This will solve the error that you have reported.
Remark: be careful, because after this is solved, you could experience some other issues related to the good use of the library, as pointed out by drescherjm in the comments (link about registration of custom classes to the library's fatories if Cmake is not used to compile the project)
I'm trying to create a program that uses a lot of linear algebra and OpenGL, and a colleague of mine recommended that I use the Eigen library to make things a lot simpler. After downloading and extracting the library off of Eigen's official website and I clicked on the project, found the "Link Binary with Libraries" option, went into to the folder that resulted from the unarchiving (eigen-eigen-bdd17ee3b1b3), and then found the Eigen folder. This folder contains all of the header files.
The library showed up on the sidebar, and when I go into the correct sub-folder the header files were all there too. According to the Eigen website, you only need the header files for the includes to work, but no matter how I set up the filepath in the include statement, even if what I can physically see what I'm including on the sidebar, XCode tells me it can't find the file. I'm using an older version of XCode 4. Any advice?
Sounds like you are missing header search paths:
I am developing using OpenSceneGraph. I installed it from a user-runnable installer.
When I try to compile an application using OpenSceneGraph, I have this error :
Lexical or preprocessor error : Include cannot be found for all <osg/*> includes like <osg/AnimationPath>.
The file is available here /Library/Frameworks/osg.framework/Versions/92/Headers/XXXX So following this solution on how to "add existing frameworks" to the new Xcode, I added osg.framework to the project.
any idea is a welcome.
I am using :
IDE Xcode 4.5
Clang 4.1
OS X Mountain Lion
When compiling you will have to add the include files using the -I option of the compiler and also possibly add library directory using the -L option of the compiler(the options may be a bit different if you are using compiler different from gcc).
I guess both library and the include directories for this product should be subdirectories of the install destination you have chosen. For the include directory of course look for directories containing some kind of header files .h or .hpp and for the libraries look for .lib or .dll doesn't the library documentation mention what includes and libraries you need and where you can find them?
EDIT: you will also have to tell xcode where to search for your includes. I tried googling it and here is one of many results on how to add a directory to the include path of a project.
You will have to located which directory to add to the include path. It seems they set some environment variables in the official documentation for that.
Hope this helps.
You'll need to add /Library/Frameworks to the "Frameworks search path" in the project settings.
I am trying to solve a coupled set of ODE's in C++, and I have decided that I want to try out odeint (available here) as I have read many good things about it. However I am having compiling the examples that are included in the package. Here is the situation:
So far I have only downloaded the package and extracted it. I am running Visual C++ 6 on Windows XP and I am compiling the example "simple1d". I get the error message: "Cannot open include file: 'boost/config.hpp': No such file or directory".
It is not clear to me what I am missing. Do I need the full boost library to make this work? I was under the impression that ODEINT is a "standalone" package.
Your error says that compiler can not find the boost libraries. You should download them from boost.org and also add them to your header path.
Where did you download and extract the package to? The package homepage says that it's a header-only package, so you only need to let Visual find the header files. I haven't used Visual in a while, but a quick google of something like "Visual 6 add header path" should be a good place to start. Take a look at Where does Visual Studio look for C++ header files?.
Quoting from this page:
Within Visual Studio, go to the Project Settings dialog. We want to change the settings for both Debug and Release versions, so under the Settings For field, select "All Configurations". Under the C/C++ Tab, select Preprocessor options.
The package tarball has a directory called boost: you want to add the path of that directory into the Additional include directories box and then #include <boost/numeric/odeint/config.hpp> in your code.
Update
It appears, then, that you already have the odeint headers installed properly: the file boost/numeric/odeint/config.hpp has a line #include <boost/config.hpp>, which is what visual must be complaining about; so I guess the package is not standalone. It must need other boost header files installed. I can't find anything in either the package homepage or the package tarball that mentions any dependencies, so I suppose you should try to install boost too. Download version 1.51.0 here, and this is the windows documentation.
You must download odeint from http://headmyshoulder.github.io/odeint-v2/downloads.html and Boost c++ libraries from http://www.boost.org/users/history/version_1_51_0.html.
If you use codeblocks right click your project, select build oprions, select Search Directories and add two references one for odeint and one for boost.