Reputation: 1438
I've installed boost, so i'm trying to run compiler like this:g++ -LC:\MinGW\boost_1_55_0\stage\lib -lboost_regex-mgw49-mt-1_55 test.cpp
My programm test.cpp
is not very complicated:
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
boost::regex rex("[test]");
}
I'm of course failed: error: 'boost' has not been declared
. I can't understand what I must write in my test.cpp
file next to #include <iostream>
? #include <boost>
doesn't work, i'm getting error fatal error: boost: No such file or directory
.
#include <boost/regex.hpp>
also yield this error, maybe #include <boost_regex-mgw49-mt-1_55>
? But it still doesn't work.
Upvotes: 0
Views: 596
Reputation: 344
You need to include regex.hpp in your main. You hint that you tried to, but it apparently didn't work.
Make sure regex.hpp is where you tell the compiler it is relative to one of your search directories. It's not good enough to tell the compiler to include boost/regex.hpp, the file has to actually exist where the compiler is looking for it to be able to find it.
You will need to copy that file from wherever you downloaded it to somewhere the compiler will know to look for it. Once you do that, it should find it and that error should go away.
Also note that the same applies to the object file you're trying to link in. If the linker can't find that file, you'll just get a linker error once you clear up this compiler error.
Upvotes: 1