As this has been marked as duplicate earlier: This problem has nothing to do with the basic "How to install boost...". Boost is installed and all libraries but coroutine2 are working correctly. So this is a coroutine2 problem.
When trying to compile my project I get the following linker error:
LNK1104 cannot open file 'libboost_coroutine2-vc140-mt-gd-1_64.lib'
After checking I noticed that file was missing, even though I built boost with the following command:
b2 install --build-type=complete msvc -mt
So I tried to build it manually using the following command:
b2 install --build-type=complete msvc -mt --with-coroutine2
Something interesting happened: It built Boost.Context (which was already built by the first command) which it is built on, but no Coroutine2 lib in sight.
Now I tried to run the project on my other computer with boost 1.61 installed - and it worked flawlessly! After checking the coroutine2/detail/config.hpp (which determines which library to link against) I noticed that boost 1.61 wants to load the coroutine lib while boost 1.64 requires a coroutine2 lib...
On Boosts Getting Started page Coroutine2 isn't listed as a "has-to-be-built" library and after dissecting the config.hpp file I came up with the idea to define #define BOOST_COROUTINES2_NO_LIB which resulted in many unknown symbols...
I don't know what else I can do, please help, dear professionals :)
First of all I've found which exact cpp is generating LNK1104 error. Then I've enabled "Preprocess to a File" option to see in the preprocessed file, who's making the linking request. Then bingo!
#line 401 "C:\\libdev4\\boost\\boost/config/auto_link.hpp"
#pragma comment(lib, "boost_coroutine2" "-" "vc140" "-mt" "-gd" "-" "1_64" ".lib")
So, it's a bug in boost 1.64 auto_link.hpp
p.s. disabling the automatic linking via defining BOOST_ALL_NO_LIB in my project and setting the necessary libs manually, solves the problem.
boost.coroutine2 is a header-only library - a libboost_coroutine2-vc140-mt-gd-1_64.lib ist not created. You should check the linker flags of your project and remove the reference to libboost_coroutine2.
EDIT: remove sub directory 'build' from boost.coroutine2
I faced same issue in Boost 1.64 when building from MS Visual Studio.
With Boost 1.65 I don't face this problem anymore.
You can copy the libboost_coroutine-xxx.lib to boost_coroutine2-xxx.lib and put it in the lib path. because oroutine2 no use lib. So no matter what content in the lib make no difference .
Related
I am trying to build libtorrent (http://www.libtorrent.org/) using the provided jamfile. If I try to build it in its vanilla state everything goes well. I am then building using this command:
bjam msvc-12.0 boost=source
However I want to build it with OpenSSL which there seem to be support for. This is where I run into problems. Most likely because it is the first time I use Bjam (actually anything else than make files). I now try to run the following command:
bjam msvc-12.0 boost=source encryption=openssl
Now the compiler starts to complain about not finding the OpenSSL include files.
So I guess I have to include this path in the JAM file. But I have no idea where.
I also tried to add the path into the INCLUDE environment varaible in windows but that doesn't seem to be picked up by BJAM or msvc. Any suggestions?
My understanding of how this is normally done on windows is by installing libraries and headers into visual studio's include and lib folders.
(That's how I install openssl on windows at least).
The jamfile is also supposed to pick up CXXFLAGS and LDFLAGS environment variables, which you could use to introduce the library- and include paths. However, it only does this when boost=system is specified, i.e. you're building against "system" boost libraries instead of from source.
During the process of linking my program to the boost::filesystem module in release mode I get the next error:
error LNK1104: cannot open file
'libboost_filesystem-vc100-mt-s-1_49.lib'
However, in the boost\stage\lib directory I only have the next libraries referred to filesystem module:
libboost_filesystem-vc100-mt-1_49.lib
libboost_filesystem-vc100-mt-gd-1_49.lib
My questions are:
Why does the VC++ is asking for 'libboost_filesystem-vc100-mt-s-1_49.lib?
Which compiler/linking properties should I change to get the compiler to ask for libboost_filesystem-vc100-mt-1_49.lib?
UPDATE: My VC2010++ solution has 2 projects that include the previous boost library: x is a library and y (the main program) which invokes to x.
When I build x with Configuration type=Static library and RuntimeLibrary=Multi-threaded (/MT), it is ok.
When I build y with Configuration type=Application (.exe) and RuntimeLibrary=Multi-threaded (/MT), it issues the error I indicated, if I change to Configuration type=Static library it builds ok, but my main program has .lib extension and not the expected .exe.
You are using /MT or /MTd option in C/C++/Code Generation/Runtime Library which require static library, boost default build with shared library output. You can switch Runtime Library to /MD or /MDd. An other option is recompile boost with static library output and you'll get 'libboost_filesystem-vc100-mt-s-1_49.lib'..
I had a similar problem with a recent project (inherited from a long legacy).
Here is a "poor man's" solution to this issue:
Rebuild the boost libraries with all variants, to be sure that you have the correct variant for your needs.
Run:
.\b2 --build-type=complete
Note that the boost build time will obviously be longer with this option.
This is not an elegant solution, but I didn't have time to mess about figuring out which exact option I needed for my project, so I just built them all.
You can paste the following characters into you control console (win+r----cmd , then go to boost src directory , find the bjam.exe)
ps:double click the bootstrap.bat can get bjam.exe
bjam --toolset=msvc-1.0 --stagedir=./lib_x64 --builddir=./ address-model=32 link=static variant=release runtime-link=static threading=multi stage debug releasde
libboost_filesystem-vc100-mt-s-1_49.lib
"link=static" correspond to -s-
"threading=multi" correspond to -mt-
"runtime-link=static" correspond to lib prefix
"variant=release" make sure libboost_filesystem-vc100-mt-s-1_49.lib don't contain -gd-
The boost libraries that you have in your boost\stage\lib directory are linking dynamically to the standard C++ libraries. See the following post:
boost lib build configuraton variations
Your code is linking statically to the standard C++ libraries, hence a mismatch. Try linking your code dynamically to the standard libraries. (Project Settings->General->Configuration Type)
run below command to rebuild boost in static in VS2013 x86 Native Tools Command Prompt.
b2 -link=static
Add your linker library paths in your project link path in VS.
Then, rebuild your project, error gone.
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.
I'm compiling boost with bjam under Windows 7 (64bit-should be irrelevant)
D:\development\boost\boost_1_44\libs\iostreams\build>bjam stage ^
--toolset=msvc-10.0 link=static ^
--build-type=complete ^
-s ZLIB_SOURCE=C:\zlib125-dll ^
-s ZLIB_LIBPATH=C:\zlib125-dll\lib ^
-s ZLIB_INCLUDE=C:\zlib125-dll\include ^
-s ZLIB_BINARY=C:\zlib125-dll
But I only get
stage/libboost_iostreams-vc100-mt-gd-1_44.lib
bin.v2/libs/iostreams/build/msvc-10.0/debug/threading-multi/boost_iostreams-vc100-mt-gd-1_44.dll
bin.v2/libs/iostreams/build/msvc-10.0/debug/threading-multi/boost_iostreams-vc100-mt-gd-1_44.lib
bin.v2/libs/iostreams/build/zlib/msvc-10.0/debug/threading-multi/boost_zlib-vc100-mt-gd-1_44.dll
bin.v2/libs/iostreams/build/zlib/msvc-10.0/debug/threading-multi/boost_zlib-vc100-mt-gd-1_44.lib
but stage/libboost_zlib-vc100-mt-gd-1_44.lib is missing.
Am I compiling something wrong?
when I try running my project that worked well with boost and self-compiled boost/thread libraries I get the following error when I include the boost zlib stuff
6>LINK : fatal error LNK1104: cannot open file 'libboost_zlib-vc100-mt-gd-1_44.lib'
Does anyone know what I'm doing wrong?
I did manage to build them using the option
-sZLIB_SOURCE="C:\zlib-1.2.5"
Note there is no space after the -s and the quotes around the path.
It took me a while to get Boost to build correctly with zlib support.
The problem I ran into was that at some point zlib no longer included a gzio.c source file. The jamfile for the Boost build system (jamfile.v2) had a reference to the gzio module which caused it fail. The solution was to remove that reference before building.
I'm not sure this answer is relevant any longer, unless you're trying to build an old version of Boost. I believe the original build issue has been fixed in more recent versions of Boost.
I had the same problem (Windows 7 Visual Studio) and I believe the issue is not in how you build boost.
1) As ecotax, there should not be a space after the -s
2) When running bjam, add the flag --debug-configuration. If in the output you do not see errors and it prints out something like
notice: iostreams: using prebuilt zlib
then it has found your zlib copy, which it is good.
3) Notice that the library libboost_zlib-vc100-mt-gd-1_44.lib should not be produced.
4) When you compile your application in Visual Studio, seems that Boost.Iostreams auto-linking still wants libboost_zlib-vc100-mt-gd-1_44.lib and reports a link error.
What it worked for me (I founded googling) was to add to the preprocessor definitions the flag
BOOST_IOSTREAMS_NO_LIB
I was trying all sorts of things and had a hard time finding the correct solution for newer versions of boost (1.75.0).
All the -sZLIB_xxx switches seem to be not working anymore.
Boost Documentation just states
On Windows the zlib, bzip2, zstd and/or LZMA binaries need to be in the PATH, else they will not ordinarily be found by default, so it is always a good idea under Windows to setup the zlib, bzip2, zstd and/or LZMA toolsets in your own jamfile.
Setting path did not lead to any success, so I dig through more documentation. Boost provided jam documentation and examples are not the most helpful, so through analysis of the Conan Recipe for the Conan boost package I finally came up with this minimal user-config.jam file that does the trick for me:
using zlib : your.zlib.version :
<include>"path/to/zlib/include/headers"
<search>"path/to/zlib/library/file" ;
The minimal b2 command to execute this for me is:
.\b2.exe --user-config="path/to/user-config.jam"
Hope this can be of help to others so they don't need to waste a lot of time as I did.
For guys, who compiling, using prebuilt 'zlib'.
These steps needs to be done:
Download and build 'zlib'
Run b2.exe --with-iostreams -s ZLIB_BINARY=zlib -s ZLIB_INCLUDE=C:/Sys/zlib-1.2.7/Include -s ZLIB_LIBPATH=C:/Sys/zlib-1.2.7/Lib release
Update paths to your local installation zlib folder. This way, Boost will embed into libboost_iostreams the gzip.cpp, zlib.cpp files. No libboost_zlib will be generated.
At your source file add this lines (somewhere in stdafx.h, before including Boost.Iostream headers):
--
#ifdef _DEBUG
#define BOOST_ZLIB_BINARY zlibd
#else
#define BOOST_ZLIB_BINARY zlib
#endif
This tells that you don't want to link against libboost_zlib, but you provide precompiled zlib library instead.
At your project settings provide path to zlib.lib file.
It should compile and link now.
I took a combination of advice from other answers here and this is what I did:
Extract zlib to C:\zlib\zlib-1.2.11.
Use CMake to configure and generate MS Visual Studio 2017 project and use MS Visual Studio 2017 to build the project. I built it in place so that C:\zlib\zlib-1.2.11 now contains (in addition to previous contents) directories lib and include.
Extract Boost 1.67.0 to C:\Boost\boost_1_67_0.
(Be on drive C:)
cd \Boost\boost_1_67_0
bootstrap.bat
set ZLIB_SOURCE="C:\zlib\zlib-1.2.11"
set ZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include"
set ZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
The following line built libboost_iostreams and it did put libboost_zlib files in C:\Boost\boost_1_67_0\stage\lib:
b2 --debug-configuration --with-iostreams -sZLIB_SOURCE="C:\zlib\zlib-1.2.11" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
The following line built the rest of Boost:
b2 -sZLIB_SOURCE="C:\zlib\zlib-1.2.11" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
Don't know if this is the most optimal way to do it, but it did build the libboost_zlib lib files.
set ZLIB_SOURCE="c:\zlib"
set ZLIB_INCLUDE="c:\zlib"
.\b2
.\bjam will not build but .\b2 will build the library: stage/libboost_zlib-vc100-mt-gd-1_44.lib
My development shop has put together a fairly useful Python-based test suite, and we'd like to test some Linux-based C++ code with it. We've gotten the test project they ship with Boost to compile (type 'bjam' in the directory and it works), but we're having issues with our actual project.
Building the boost libraries and bjam from source (v1.35.0), when I run bjam I get a .so in the bin/gcc-4.1.2/debug directory. I run python and "import " and I get:
ImportError: libboost_python-gcc41-d-1_35.so.1.35.0: cannot open shared object file: No such file or directory
Looking in the library directory, I have the following:
libboost_python-gcc41-mt-1_35.so libboost_python-gcc41-mt-1_35.so.1.35.0 libboost_python-gcc41-mt.so
Obviously I need the -d instead of the -mt libraries, or to point at the -mt libraries instead of -d, but I can't figure out how to make my Jamroot file do that.
When I install Debian Etch's versions of the libraries, I get "No Jamfile in /usr/include" - and there's a debian bug that says they left out the system-level jamfile.
I'm more hopeful about getting it working from source, so if anyone has any suggestions to resolve the library issues, I'd like to hear them.
Response to answer 1: Thanks for the tip. So, do you know how I'd go about getting it to use the MT libraries instead? It appears to be more of a problem with bjam or the Jamfile I am using thinking I am in debug mode, even though I can't find any flags for that. While I know how to include specific libraries in a call to GCC, I don't see a way to configure that from the Boost end.
If you want to build the debug variants of the boost libraries as well, you have to invoke bjam with the option --build-type=complete.
On Debian, you get the debug Python interpreter in the python2.x-dbg packages. Debug builds of the Boost libraries are in libboost1.xy-dbg, if you want to use the system Boost.
Found the solution! Boost builds a debug build by default. Typing "bjam release" builds the release configuration. (This isn't listed in any documentation anywhere, as far as I can tell.) Note that this is not the same as changing your build-type to release, as that doesn't build a release configuration. Doing a 'complete' build as Torsten suggests also does not stop it from building only a debug version.
It's also worth noting that the -d libraries were in <boost-version>/bin.v2/libs/python/build/<gcc version>/debug/ and the release libraries were in <gcc-version>/release, and not installed into the top-level 'libs' directory.
Thanks for the other suggestions!
One important Point: -d means debug of course, and should only be linked to a debug build of your project and can only be used with a debug build of python (OR NOT, SEE BELOW). If you try to link a debug lib to a non-debug build, or you try to import a debug pyd into a non-debug python, bad things will happen.
mt means multi-threaded and is orthogonal to d. You probably want to use a mt non-d for your project.
I am afraid I don't know how to tell gcc what to link against (I have been using Visual Studio). One thing to try:
man gcc
Somewhere that should tell you how to force specific libs on the linker.
EDIT: Actually you can import a debug version of you project into a non-debug build of python. Wherever you included python.h, include boost/python/detail/wrap_python.hpp instead.