Eclipse CDT project with armadillo - CDT does not recognize 'arma' namespace - c++

I'm running on a CentOS 6.5 x64 OS and have used yum to install armadillo. I'm developing in Eclipse CDT
I've included the armadillo header in the project properties >> C/C++ Build >> Settings >> GCC C++ Compiler >> Includes >> Include files. The entry is: "/usr/include/armadillo"
The header file I am working on recognizes armadillo and the include statement isn't flagged for any errors or warnings.
Below is the code:
#include <armadillo>
using namespace std;
using namespace arma; // arma is not recognized as a symbol
const double DEGREES_PER_RADIAN = 180.0 / datum::pi; // datum is not recognized
I've checked the file /usr/include/armadillo and it does include the namespace arma section.
//! \namespace arma namespace for Armadillo classes and functions
namespace arma
{
// preliminaries
...
I've also checked the permissions and the /usr/include/armadillo file is readable to all users.
The problem is when I add the "using namespace arma", CDT marks it as an error and says that "Symbol 'arma' could not be resolved".
At this point, I don't have any other ideas to figure out why the namespace isn't recognized. Any insights or pointers to figure this out would be much appreciated.

This question's answer provided the answer to my issue:
Clean Eclipse Index, it is out of sync with code
Josh Kelley's answer from the linked issue:
Right-click on your project, go under the Index submenu, and choose either "Rebuild," "Update with modified files," or "Freshen all files."
I don't know the difference between those three options, but one of "Update with modified files" or "Freshen all files" usually fixes it for me.
Also, I'm sure you've already done this, but make sure that you're running the latest version of the Eclipse CDT. Current versions seem to have much more reliable indexing than previous versions.
After running Index >> Rebuild and Index >> Freshen All Files, the errors were gone.

Related

CodeLite not working with boost library

I'm having some troubles to get my CodeLite IDE working with Boost library.
So basically, I've got CodeLite v.6.1.1 and Boost library downloaded from sourceforge. I would love to make it actually working, but I failed to do so using the following concept:
I did create new workspace, than I did go -> Settings -> Build Settings -> Compilers (here I have two compilers, one of which is CodeLite 4.8.1 and the other one is MinGW Code::Blocks, I did select CodeLite 4.8.1. -> Advanced -> Global Paths -> and I did provide two blank lines of Include Path and Libraries Path with the directory of unpacked boost library (Windows 7): C:\boostlib\boost_1_57_0.
In this catalog (i.e.: C:\boostlib\boost_1_57_0), I have got all neccesary files, all of them are unzipped and yet I can't get it working.
Besides, I can't click on apply when I'm done with setting path to files containing boost library, all I can do is click ok but once I'm done with this I can't work with libraries from boost.
The following code isn't working:
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
// ERROR MESSAGE: boost/lambda/lambda.hpp, No such file or directory
typedef std::istream_iterator in;
std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << ” ” );
return 0;
}
The message I get is:
boost/lambda/lambda.hpp: No such file or directory
Is there any chance I can get CodeLite working with boost library or should I simply switch IDE and forget about it ?
Your on the right track but need to point to the libs and include folders inside the boost directory.
I use the the http://nuwen.net/mingw.html version of mingw as STL (the guy) includes boost as part of his distribution.
So in codeLite I just have to add
C:\MinGW\lib to the libraries path
C:\MinGW\include to the include path

Use dlib in Visual studio 2012

I want to use optimization algorithm lbfgs in my project but I do not want to code it myself. So I found Dlib is a good option.
http://dlib.net/compile.html is a good library. I downloaded it. I use windows 7 and visual studio 2012. If I create a new win 32 console project and set property->configuration properties->VC++ Directories->Include Directories to the path of Dlib(dlib-18.10/).
And it works fine which mean I can run examples.
But when I add it to my project. I occur errors.(error : "vector" is ambiguous)
I guess it maybe because the way I include it.
On the document of Dlib, it says,
Again, note that you should not add the dlib folder itself to your compiler's include path. Doing so will cause the build to fail because of name collisions (such as dlib/string.h and string.h from the standard library). Instead you should add the folder that contains the dlib folder to your include search path and then use include statements of the form #include <dlib/queue.h>. This will ensure that everything builds correctly.
But I am not clear what it means above. I googled the Visual Studio search path (Tools / Options / Projects and Solutions / VC++ Directories).. But in my project this is non-editable.
I only use optimization.h in dlib. If I delete 'using namespace dlib;', then ' typedef matrix column_vector;'then the error is matrix is not a template. If I keep 'using namespace dlib;' I have error "vector" is ambiguous`.
#include <dlib/optimization.h>
#include <iostream>
using namespace std;
using namespace dlib;
// ----------------------------------------------------------------------------------------
// In dlib, the general purpose solvers optimize functions that take a column
// vector as input and return a double. So here we make a typedef for a
// variable length column vector of doubles. This is the type we will use to
// represent the input to our objective functions which we will be minimizing.
typedef matrix<double,0,1> column_vector;
As the documentation says, include directory should be root directory of the zip you downloaded. Then you include as #include <dlib/vector.h>. However, since vector is defined under namespace of std as well, you should be specifically denote which namespace's STL you will use.
If you want to use std::vector,
#include <vector.h>
then use it as
std::vector<int> stdVar;
Similarly, for dlib,
#include <dlib/geometry/vector
then use it as
dlib::vector<int> dLibVar;
You could also delete using namespace std if you don't use it as frequent as dlib. Then every STL you reference will be dlib. If you want std, just type std::vector.
using namespace std;
using namespace dlib;
#define vector std::vector
use w/ caution

How do I include Boost.Interprocess and Boost.DateTime properly?

This is a really basic question because I am a C++ newbie. I want to use the Boost.Interprocess library, but am having trouble building it. I'm trying to follow these instructions, but it's not working for me. Here is what I have:
#define BOOST_DATE_TIME_NO_LIB
#include <boost/interprocess/shared_memory_object.hpp>
#include <iostream>
using namespace std;
int main() {
cout << "Hello, beautiful world!\n";
}
But I get this error:
boost_1_55_0\boost\date_time\gregorian_calendar.hpp(63) : fatal error C1083: Cannot open include file: 'boost/date_time/gregorian_calendar.ipp': No such file or directory
I know Boost is able to load properly, because I can get an example that uses #include <boost/lambda/lambda.hpp> to work just fine. It's just when I try to include the Boost.Interprocess library that I am having trouble. The cause is clearly because it's having trouble including the Boost.DateTime library properly, but according to the documentation (linked above) I should be able to get by without separately compiling Boost.DateTime if I define BOOST_DATE_TIME_NO_LIB, right?
What am I missing here?
You need to add it to the preprocessor
In VS go to - Project >> properties >> C/C++ >> Preprocessor in the 'Preprocessor Definitions' paste BOOST_DATE_TIME_NO_LIB.
You can download boost libraries here: https://www.boost.org/users/download/
After that, you can include them in your projects. Also, you can check this video on how to add boost libraries in eclipse IDE on Ubuntu: https://www.youtube.com/watch?v=gN8zrnWxFeI

Standard library not resolved in Eclipse Juno

I am building a Makefile project in Eclipse Juno, and I have it set up so it compiles and debugs (it's using CMake, so I'm not using the internal tools). However, Eclipse obviously hasn't been informed of the right headers, as in the following code:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello world << endl;
return 0;
}
the include "iostream" and symbols "std", "cout" and "endl" are all unresolved.
How should I make Eclipse aware of these so it will stop underlining everything in red and spamming with errors?
This can be resolved by specifying the following environmental variables in Project->Properties->C++ Build->Environment.
LANG=en_US
LC_ALL=en_US
Apparently they are needed for the auto-discovery tools to work out where the includes live.
Answer gleaned from this Eclipse forum thread.

STL namespace problem in Netbeans 6.8 on AIX

I'm trying to use NetBeans 6.8 on an AIX OS for C++ development.
I continue getting an error message for:
using namespace std;
even after adding the includes for the STL via
options -- c/c++ -- code assistance
The error says: "Unable to resolve identifier std"
Is this a bug in the Netbeans 6.8 AIX version? Or am I missing something?
Thanks for any help!
You can easily enough test if there is no std namespace getting included before your using directive by adding in
namespace std
{
}
just before it. If the compiler is now happy then there was no std namespace stuff actually included.