Could not link boost file system - c++

I use Visual Studio 2012 Update 4. I cannot build my project.
I've downloaded boost archive, extracted it to C:\boost.
Opened Developer Command Line for VS2012 and executed bootstrap.bat and bjam.exe in boost directory (took about 5 minutes).
In my project, i've added C:\boost to additional include directories and C:\boost\stage\lib to additional library directories (in build settings).
If i write in my code:
#include <boost\filesystem.hpp>
I get linkage error:
Error 1 error LNK1104: cannot open file 'libboost_filesystem-vc110-mt-gd-1_58.lib'
Project type is: Win32 application (CLR support).
Other boost headers seems to work well on other project.
What should i learn about linking boost what i am missing?

Fixed this issue by running this command in c:\boost (thanks #marom):
b2.exe --with-filesystem --toolset=msvc-11.0 --build-type=complete stage

Related

Boost with Qt Creator

I was trying to use boost/filesystem in my C++ project made with QtCreator.
The problem was that when building, I got the following error:
"error: undefined reference to `boost::system::generic_category()'"
To use boost, I had performed the following actions:
download boost library boost_1_73_0.7z file
unzip it in my computer (under D:\Development\Boost)
in .pro file, I have added the following option
INCLUDEPATH += D:/Development/Boost
in my .cpp file, I have added the following include
#include "boost/filesystem.hpp"
At this point, when compiling, I had the following error in Qt creator IDE
"error: undefined reference to `boost::system::generic_category()'"
The root cause is the following : FileSystem needs to be built. Therefore, I have built this boost library by :
adding gcc and g++ to the path variable (it is succesful as I could call 'g++' and 'gcc' from the command prompt).
opening Qt command prompt (I used Qt 5.15.0 (MinGW 73.0 64-bit) ) and by navigating to the repository where boost is installed.
executing the following command in the command prompt in the directory (D:\Development\Boost): bootstrap gcc
executing the following command in the command prompt in the directory where I had unzipped Boost: b2 toolset=gcc link=shared threading=multi --build-type=complete stage. This action has created a the directory D:\develoment\Boost\Stage\lib with all the dll, including 'libboost_filesystem-mgw8-mt-d-x64-1_73.dll'.
Now it's time to link the library in Qt creator. I have thus added the following in my .pro file:
LIBS += -LD:/Development/Boost/stage/lib libboost_filesystem-mgw8-mt-d-x64-1_73
When compiling, the error is gone.
Thanks for your help.
Gatien
As #drescherjm commented, you need to build the boost libraries.
They are not in the D:/Development/Boost/libs directory.
You appear to be using Windows and have boost installed on your "D:" drive.
I assume your using the MinGw compiler that comes with Qt Creator, not Visual Studio.
To build boost with MinGw, first open the relevant Qt Command prompt, e.g. Qt 5.12.3 (MinGW 7.3.0 64-bit) and type the following:
D:
cd \Development\Boost
bootstrap.bat gcc
b2 toolset=gcc link=shared threading=multi --build-type=complete stage
This will build the MinGw boost libraries in your directory: D:\Development\Boost\stage\lib.
Then change the link command to:
LIBS += -LD:/Development/Boost/stage/lib -l boost_system-mgw73-mt-x64-d-1_66
Note: the precise name of the boost_system library depends upon how boost named it in your version.
See Boost Getting Started on Windows: library naming. the answer here: mingw-w64 cannot find -lboost_filesystem and the filenames you built in the D:\Development\Boost\stage\lib directory.

Boost.Python not the .lib

I think I have built it properly. I have other boost libraries working. I am getting the following error
Error: SNK1104 cannot open file 'boost_pythonPY_MAJOR_VERSIONPY_MINOR_VERSION-vc141-mt-x32-1_67.lib'.
I'm on windows using Visual Studios, with boost 1.67
boost-python is notoriously hard to install. Make sure you specify with-python when building from source. Something like this:
Download and configure boost
cd boost_1_55_0\tools\build\v2\engine
build.bat mingw
Add this to your path
C:\boost_1_55_0\tools\build\v2\engine\bin.ntx86
Build from source
bjam toolset=gcc --with-python link=shared
Add this to your path
C:\boost_1_55_0\stage\lib

Unable to link to boost 1.60 thread library in Visual Studio 2013 on Window 7

i am trying to use boost 1.60 thread library in my project with visual studio 2013 on window 7. Following command i used to build boost
b2.exe toolset=msvc-12.0 variant=debug link=shared threading=multi address-model=32 -j5 --build-dir=some_directory --libdir=some_directory install
Though building was successful when i add thread library in visual studio linker input option i get error saying
error LNK1104: cannot open file 'libboost_thread-vc120-mt-gd-1_60.lib'
Few NOTES::
1. Is boost directory is in include path : Yes
2. Is boost lib directory is added to additional lib directory path : Yes
3. Is boost lib dll is in application's environment path : Yes
4. Did i build boost with different version of visual studio and trying to use in different version : No, both is VS2013
5. Is boost build address model is different than application's address model : No, both is 32 bit
after checking multiple times all of the above my knowledge base ends on this :(
kindly extend it solve this problem. What else i need to check?
For anyone who gets into same problem in future..
Just make sure you have added preprocessor flag BOOST_ALL_DYN_LINK if you are using shared library version of Boost

Installing boost 1.52 with VS2012

I followed these instructions to install boost and to compile all libraries:
https://www.quantnet.com/threads/tutorial-quantlib-boost-installation-in-visual-studio-2012.11891/
Boost Installation The Boost library can be downloaded here.
Currently, the latest version available is Boost 1.52.0. You can build
boost by following the instruction here.
Alternative you can download
a pre-built lib from here. Once downloaded, copy the installer into
the Boost 1.52.0 folder and run it. Rename the folder to lib once
done.
So I downloaded boost 1.52, then copied that to C:\Program Files (x86)\boost\
I then downloaded the 1.52 64 bit installer and once downloaded, pasted that to:
C:\Program Files (x86)\boost\boost_1_52_0\boost_1_52_0\
I executed the installer- it said "extracting" and then many library names.
I then renamed the last folder to lib, so that I had:
C:\Program Files (x86)\boost\boost_1_52_0\lib\
In my VS2012 I then added the previous directory to my project. The project then starting parsing through the libraries and I had no linker errors. However, when building the project I still got:
LINK: fatal error LNK1104: cannot open file
'libboost_date_time-iw-mt-gd-1_52.lib'
(The only usage of boost in my project is file_mapping and mapped_region)
Help?
EDIT: I am aware about some libraries needing to be compiled separately in boost. I thought the above was to achieve this? If not, could someone please advise how because this really becomes a pain.
Boost has some libraries (most of them) used as source headers (.h files) that do not need to be pre-compiled, but there are also some libraries that need to be pre-compiled (.lib files). You can either download the libraries pre-compiled from the Boost website (http://www.boostpro.com/download/), although you might get some older versions from there, or compile them (the latest version or any of those available you want) on your own, although please have in mind that this might take some time, depending on your computer specs. See here for more: http://www.boost.org/doc/libs/1_54_0/libs/regex/doc/html/boost_regex/install.html.
After downloading the "normal" boost package, put the folders/files extracted on a folder and then assocciate it in VS2012 by putting the folder path in
(YourProject > Right-Click > Preferences >)General > VC++ Directories > Include Directories.
Then download and install the pre-compiled libraries (extract them on a folder) and then associate this folder with the VS, in
(YourProject > Right-Click > Preferences >) Linker > General > Additional Library Directories.
Of course, as mentioned before, you can also compile the packages you want, and then associate them with Visual Studio the same way.

BOOST Version 1.46.1 with Visual Studio 2010 P.E

I'm trying to run some simple examples with Boost and I'm continuously running into this error and I have tried to compile this but I haven't been able to create "libboost_system-vc100-mt-gd-1_46_1.lib".
I keep ending up with this issue:
error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_46_1.lib'
Anyone encounter this error before? How do you compile this properly with NMAKE because it keeps telling me it's bulding "boost.regex without ICU / Unicode Support" which is giving it a "fatal error U1073 and tells me it doesn't know how to make "../src/c_regex_traits.cpp".
Sorry if this is a jumble it's just a lot of information that's getting more and more confusing to me.
Your boost is not properly built or installed. Please follow the instruction on how to install boost.
You need to build the boost libraries first.
To do this, open command line & go to boost root eg C:\dev\boost\1_46_1.
Depending on whether you want to build for 64bit or 32bit applications, type
(x64):bjam toolset=msvc address-model=64 variant=debug,release link=static threading=multi runtime-link=static,shared stage
(x86): bjam toolset=msvc variant=debug,release link=static threading=multi runtime-link=static,shared stage
to start compiling. Be patience while boost is building, it takes a lot of time. When building is complete you can find the library files in "stage\lib" folder.
Also note that you can delete the folder "bin.v2" once building is complete.
Now you need to point your VS2010 project to those libraries. Modifying part of mlimber's answer:
In VS2010, right-click on your project, select Properties and then go to Configuration Properties -> Linker -> General. Look for "Additional Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Another way to do this is the following
In VS2010, right-click on your project, select Properties and then go to Configuration Properties -> VC++ Directories. Look for "Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Apart from the above, one could also download from
http://sourceforge.net/projects/boost/files/boost-binaries/1.46.1/
the necessary libraries (including the file missing).
While trying to build Pion network library, I ran into a very similar problem since Pion has dependency on Boost library.
My Boost build was built using boostrap and bjam, and not BoostPro.
The error I got was this: LINK : fatal error LNK1104: cannot open file 'boost_thread-vc100-mt-gd-1_46_1.lib'
When I looked at C:\OpenSource\boost_1_46_1\stage\lib directory, I saw every file name started with libboost_ and not boost_. The file boost_thread-vc100-mt-gd-1_46_1.lib was clearly missing. That made me suspicious that not all boost libraries were built by bjam. After a little research, I reran bjam with the option --build-type=complete
Now I noticed that it started creating lib file names starting with boost_. Not to mention, Pion library could now compile successfully.
Hope this adds some clarity to this thread.
Or alternatively to ybungalobill's suggestion use the installer from www.boostpro.com.
In the installer you must just select the boost versions for msvc 10 and after installation update your visual studio include and lib directories in the VS2010 property sheets to point to the boost include and lib directory.
I take it that you used the BoostPro installer, but which library types did you install -- header only, static linking, DLLs, everything?
Assuming you did everything, then the problem is probably that you don't have the path to boost in your library paths. The problematic file name starts with "libboost" which tells me you're trying to use the statically linked version, which is fine. You should add the library path to your Makefile or project settings for all build configurations. It's probably something like C:\Program Files\Boost\boost_1_46_1 (for the newest version on a 32-bit version of Windows).
In VS2010, right-click on your project, select "All Configurations" at the top, then go to Configuration Properties | Linker [or Librarian if you're making a library] | General. Look for "Additional Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Do that for each project in the solution that uses Boost libraries that are not header-only.
For a Makefile, you'll have to locate the library paths and add Boost to it similarly but by hand.