问题
I'm trying to use variant
from boost and I'm receiving this error:
fatal error C1083: Cannot open include file: 'boost/variant.hpp': No such file or directory
I've included the files in project properties.
In the Reference Directories and Library Directories I've tried also with
- "...\lib"
- "....\stage\lib"
And also in the Include Directories I've tried also with:
- "...\boost_1_68_0"
- "...\boost_1_68_0\boost"
In the beginning, I used D:\Libs\boost_1_68_0\libs and because it didn't work I've compiled boost and I've tried with D:\Libs\boost_1_68_0\stage\lib after that.
But it didn't work out.
Also, I should say that I've tried this in VisualStudio2010 and also in 2015 and I've followed this tutorial.
Any solution for me? Thanks in advice :)
回答1:
You have set your include to D:\Libs\boost_1_68_0\boost
. But the includes in your code will look like <boost/variant.hpp>
. So if you set your include, instead, to D:\Libs\boost_1_68_0
then the <boost/whatever/...>
will follow from there.
What you really should do is set an environment variable called BOOST_ROOT
to D:\Libs\boost_1_68_0
. Then in your project set additional includes with $(BOOST_ROOT)
Note that you have to restart Visual Studio for the environment change to take effect.
Now in the future, when boost_1_69 comes out, you can put it where ever you would like and all the previous projects where you have used $(BOOST_ROOT)
will follow when you up date the environment variable.
Always build your boost lib in /stage/lib
, it is the default for the b2
builder. And for your additional libs use $(BOOST_ROOT)/stage/lib
来源:https://stackoverflow.com/questions/51961860/c-boost-not-found-file