How to build Boost (I tried version 1.48.0) with Visual Studio C++ 11? bootstrap.bat cannot find toolset vc11. I added toolset vc11 to F:\Programming\boost_1_48_0\tools\build\v2\engine\build.bat but got a message:
ERROR: Cannot determine the location of the VS Common Tools folder.
EDIT: The Ferruccio answer works for VS 2012 Express and Boost 1.51.0 too.
This answer works beautifully for:
VS2012 (Visual Studio 2012 Update 2)
or VS2015 (Visual Studio 2015 Update 2)
Windows 7 x64
or Windows 10 x64
Boost v1.53
or Boost v1.60
In a nutshell
Open a Visual Studio 2012 command prompt. From the start menu its: All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt.
Unzip boost_1_53_0.zip to C:\boost153.
run bootstrap.bat
run bjam.exe
In any new C++ project, include the path to the Boost libraries, as per the screenshot below.
(optional) Step-by-Step Instructions
Install Visual Studio 2012.
Install Update 2.
Download Boost from SourceForge.
Unzip into "C:\boost153"
Open a Visual Studio Command prompt with Administrator privileges. From the start menu, its All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt.
Change to the boost directory with cd c:\boost153.
Run bootstrap.bat.
Run bjam.exe. This builds all of the libraries.
There may be some warnings, but you can ignore these.
When it has finished compiling after about 5 minutes, it states:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
C:/boost153
The following directory should be added to linker library paths:
C:\boost153\stage\lib
This is important, we will need to add these two paths to any new C++ project.
Create a new C++ project.
As noted a couple of steps ago, add C:/boost153 to the compiler include path and C:\boost153\stage\lib to the linker library path.
Right click on the project, select Properties, select Configuration Properties..VC++ Directories. See the two portions of bolded text in the screenshot below):
Let's run a simple program that shows off the power of boost, by adding support for foreach loops:
// Source code below copied from:
// http://www.boost.org/doc/libs/1_53_0/doc/html/foreach.html
#include "stdafx.h"
#include <string>
#include <iostream>
#include <conio.h> // Supports _getch()
#include <boost/foreach.hpp>
int main()
{
std::string hello( "Hello, world!" );
BOOST_FOREACH( char ch, hello )
{
std::cout << ch;
}
_getch();
return 0;
}
Result:
Hello, world!
More Answers
See Boost compiling with MSVC 11 (VS 2012).
See Official Boost docs on compiling with Visual Studio under Windows.
See Building Boost v1.64.
Update 2016-05-05
Checked with Win10 x64 + VS2015.2 + Boost v1.6.0.
I managed to get it to build by following these steps:
Open a Visual Studio command prompt. From the start menu it's: All Programs|Microsoft Visual Studio 11|Native x64 Command Prompt.
Unzip boost_1_48_0.zip and set the working directory to boost_1_48_0
run bootstrap.bat
run bjam.exe
It does generate a lot of warnings about not being able to detect the toolkit version, but it proceeds anyway.
Update: I created GitHub repo called cclibs which makes it simpler to build Boost and some other C++ libraries.
bootstrap.bat
bjam.exe --toolset=msvc-11
Check that your installation is correct by confirming the output of the following command:
C:\>echo %VS110COMNTOOLS%
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
Here's some simple instructions to follow to get rid of warnings when bootstrapping: http://landoftheninja.blogspot.com/2011/11/visual-c-11-and-boost.html
Don't miss his follow-up post that deals with the automatic linking.
vs2012 ERROR: Cannot determine the location of the VS Common Tools folder.
vcvarsall.bat need call a "reg.exe" which in "C:\windows\system32\".
if not in search path,will cause this error.
Add C:\windows\system32 to %PATH% will solved the problem.
In addition to above answers, I find BlueGo really helpful for building boost versions with MSVC 10/11/12. You can select different configurations and just select build, and it does the trick.
Related
Just installed visual studio 2019 on windows 10, was using visual studio for the first time and ran into the following error, It's a basic hello world console program that I tried to run.
error C1083: Cannot open include file: 'corecrt.h': No such file or directory
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
Severity Code Description Project File Line Suppression State
Warning MSB8003 The WindowsSDKDir property is not defined. Some build tools may not be found. ConsoleApplication2 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets 434
I tried searching for this error over YouTube and of course here, and also Microsoft's offical forum but couldn't find anything.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
}
the code looks just fine.
I ran into the same issue today. It turns out I didn't check the Win10SDK to save disk space while installation.
Solution:
In VS, go Tools menu=>Get Tools and Features=>install the Windows 10 SDK(10.XX.XX.XX)
Once installed, launch VS and open your project, right-click your project(NOT Solution)->properties->General->Windows SDK Version, check the value should be 10.0 instead of blank.
Then the compiling just worked.
I've got the same issue and turned out that I haven't installed Windows SDK. It can be done by typing "Install Windows SDK" into visual studio's search prompt
I had same problem when I installed Visual Studio 2019 on Windows7 and opened project created in Visual Studio 2017 (witch wasn't installed on that machine).
To solve the problem I went to project Properties -> General -> Windows SDK Version
And changed it from 10 to 8.1.
I fixed this issue by repairing Windows SDK. Now it's working as expected.
Steps:
Go to Settings>Apps & Features.
Click on Windows Software Development Kit - Windows 10.0.18362.1
(Note: Version number might be different for you)
Click on Modify.
Select Repair from options.
Click Next.
Restart VS and try running your project.
I was just having thesame issue so I figured maybe the headers were in a different directory than where the program is searching. When I went looking for tge header files none existed. So the problem is probably with iostream not existing.
Is there anyone who succeed to include libjpeg in some compiler? I tried everything: Dev C++, VS10, CodeBlocks, copy the headers and the lib by hand, add with the linker but nothing. Right now I am really confisued as there is not an official guide on how to compile it in any compiler. I would be really happy if someone could provide a tutorial on how the library can be compiled in any compiler.
Thank you in advance.
To compile libjpeg 9 in Visual Studio 2012, here are the steps (after unzipping the archive file):
Download the file WIN32.MAK (for example, from http://www.bvbcode.com/code/f2kivdrh-395674-down), and place a copy in the root source code directory (possibly C:\jpeg-9, but it depends where you unzipped it). I will refer to this directory as %jpegsrc% from now on. Having this file is important; otherwise step 3 will produce an error.
In the Visual Studio command prompt, open to %jpegsrc%:
cd %jpegsrc%
At the same command prompt, execute the following:
NMAKE /f makefile.vc setup-v10
This will create two Visual Studio 2010 solutions in %jpegsrc%: jpeg.sln and apps.sln.
Open each solution in Visual Studio 2012. Each one will prompt you to update all the projects to 2012 format. Click on “Update.” One time I did it, the prompt did not appear. In case that happens, right-click on the jpeg solution in the Solution Explorer, and choose “Update VC++ projects...,” which will produce the same prompt.
Save and build each solution as normal. (You have to build the jpeg.sln solution before apps.sln, since the latter depends on the former.)
Note: this process should work correctly in Visual Studio 2010, without the updating, but I have not tested it.
Update: This method still works in Visual Studio 2015 for libjpeg-9a.
Here is how I've built libjpeg using MinGW on Windows :
1. Get MinGW with MSYS
I've got a copy from http://sourceforge.net/projects/mingw/.
Quoting from www.mingw.org :
MSYS is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present.
We will need it to run the configure script that comes with libjpeg sources.
2. Get libjpeg sources
From http://www.ijg.org/, take the Unix format package (the Windows one won't work with this procedure). I took the jpeg_8d version.
3. Prepare a building directory
I've made a temporary directory named tmp in D:\, but you could choose whatever suits your needs. The thing that matters is the name of paths in MSYS. As it brings some * Unixity * to Windows, paths cannot be used in their original form.
In a nutshell:
C:\path\to\file becomes /c/path/to/file in MSYS land, an so
D:\tmp becomes /d/tmp.
Decompress the libjpeg sources in D:\tmp, so you have a jpeg-8d directory in there.
Create a jpeg-build directory inside D:\tmp, it will hold the built library.
Now everything is ready for the build.
4. ./configure, make, make install
That is the mantra of building in Unix land. An option should be added to redirect the install process to D:\tmp\jpeg-build.
Run the following commands in an MSYS shell (also named MinGW shell in Windows start menu):
cd /d/tmp/jpeg-8d
./configure --prefix=/d/tmp/jpeg-build
make
make install
As an additional step, you can run make test for safety.
These commands will build both static and shared versions of libjpeg.
5. Take the goods, delete the temporaries
If everything runs fine, you can delete the D:\tmp\jpeg-8d directory, but keep the jpeg-build one. It contains:
an include directory, containing libjpeg headers. You can move them to your compiler's headers directory.
a lib directory, with .a file to pass to the linker. You can move them to your compiler's library directory.
a bin directory, holding the libjpeg shared library libjpeg-8.dll and jpeg tools.
a share directory, containing man pages for the jpeg tools.
You can now build your program and link it against libjpeg by indicating the right include and library paths.
You can find many details about the libjpeg building and installation process in install.txt inside the source package.
I hope this will be useful.
It is really simple to build jpeg.lib with VS10.
First, download the libjpeg source code in zip format. At the time I'm writing this you can find it here.
Then extract the contents of the zip file to your disk.
Then open a VS2010 command prompt shell (or call vcvarsall.bat on any command prompt window), cd to the jpeg source directory (jpeg-8d in the download referenced above) and type the following:
nmake -f makefile.win setup-v10
This will generate two VS2010 solutions, and a bunch of project files. The solutions are:
jpeg.sln, which builds jpeg.lib
apps.sln, which builds the sample applications.
Good luck!
If you don't happen to have Visual Studio 2010 installed, here is what works on Visual Studio 2017:
Basic / Common steps:
Download the latest version of libjpeg from: http://www.ijg.org/ (zip version) and extract it to a folder
Open the "Developer Command Prompt for VS2017"
Change directory (cd) to where you extracted the library source
VS 2017 Approach:
Include the Windows SDK v7.1A directory (required for Win32.Mak by nmake later on) by running: set INCLUDE=%INCLUDE%;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
Run nmake /f makefile.win setup-v15 (note the v15 for VS2017 here)
From here on follow what #AthanasiusOfAlex explained to upgrade the Visual Studio 2010 solution to the Visual Studio version you are running. If you want the Debug configuration, follow what #SteveEng explained.
Errors you might stumble across:
If nmake fails and tells you it doesn't know how to make
jconfig.h, manually rename the file jconfig.vc to jconfig.h
If nmake fails and tells you Win32.Mak cannot be found, manually copy it from the SDK dir mentioned in step #4 to the libjpeg source directory. If you don't happen to have that SDK version installed, download the file from a trustworthy resource.
If nmake fails and tells you it doesn't know how to make setup-v15, trial and error your way through starting with setup-v10, setup-v11, etc... These are VS versions and one of them should work as long as you have any VS version later than VS 2008 installed.
Hope this helps people going through similar pain with this.
If you want debug mode as well in MSVC. Follow AthanasiusOfAlex's method, build the release, then:
Right-click on the project and select properties at the very
bottom
Click on configuration manager and on the active solution
configuration drop-down select -new-
Set the name to debug and on
the drop-down select copy configuration settings from release and
click OK
Close the dialog, go to general settings and under Target
Name add a d to the end so it looks like this: $(ProjectName)d
On Whole Program Optimization drop-down select: No Whole Program Optimization
Then click on the C/C++ under configuration properties on the left and on the Debug Information Format drop-down select C7 compatible (/Z7)
Under optimization select disabled and select NO for both Enable Fiber-Safe Optimizations and Whole Program Optimizations
Under preprocessor, preprocessor definitions, click on edit and use the following:
WIN32
_DEBUG
DEBUG
_LIB
_CRT_SECURE_NO_WARNINGS
Under code generation, under runtime library select Multi-threaded Debug DLL (/MDd)
Build and you're done!
This is for VS2019 with version number 16.0
Consider the Visual Studio Version name correctly like this for creating the .sln file.
Product name Code name Version number
Visual Studio 2019 Dev16 16.0
Visual Studio 2017 Dev15 15.0
Visual Studio 2015 Dev14 14.0
Visual Studio 2013 Dev12 12.0
I just installed Visual Studio 2010, and wanted to test it out by writing a hello world application.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
After trying to compile this I get this error
error C1083: Cannot open include file: 'iostream': No such file or directory
Here are my visual studio include directories
$(VCInstallDir)include; $(VCInstallDir)atlmfc\include; $(WindowsSdkDir)include; $(FrameworkSDKDir)\include;
And my library directories
$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib
If you are unable to build a simple hello world application then it suggests that either Visual Studio or the Windows SDK isn't installed correctly. Have you downloaded and installed the Windows SDK? (note: if you need to build for XP you might need to use the Win7 SDK instead)
I seem to recall that after installing the Windows SDK you may need to 'integrate' it for use with VS2010. Each version of Visual Studio can have a different default SDK that it builds against. You may need to run the SDK Configuration Tool to register it for use with VS2010. Alternatively, you might need to check the 'Platform Toolset' settings in the project, as described here
Ultimately, once that is correctly setup then you should be able to build simple C++ apps without any further configuration.
The pages given below may help you:
1.) http://msdn.microsoft.com/en-us/library/8z9z0bx6.aspx
2.) http://msdn.microsoft.com/en-US/library/hdkef6tk.aspx
<iostream> is normally stored in the C:\Program Files\Microsoft Visual Studio 10\VC\include folder. First check if it is still there.
the /P compiler option is uese to preprocess helloWorld.cpp(say),this will generate helloWorld.i, and then you check to see where iostream is getting included.
and the builded log should be helpful as well as using the /showincludes option to show the paths to the include files.
Go through the normal easy process of creating a new Project --> Templates: Visual C++ --> Win32 Console Application. If not, search your HDD for iostream and set the include path manually.
I know that similar questions you can find in web and, particularly in stackoverflow but I still need to write this question because i could no find any page where there is a step by step tutorial how to setup boost library and integrate it with visual studio 2010 express.
Even here: How to use Boost in Visual Studio 2010
there are steps (e.g. 3, 4) that I can't find the menus or so...
So please help me to be able to use boost with visual studio 2010 express on Win7.
For building:
Download Boost from here: http://www.boost.org/users/download/ and extract files
Double click on build.bat file
Press Win+R, type cmd and press enter. The cmd.exe will be invoked.
In cmd.exe type "cd the_directory_name_where_you_run_build.bat" and press enter
Then type "bjam --prefix=C:\Boost install"
See here the item 1.3 (Installation) for building and building details: http://en.highscore.de/cpp/boost/ Also this a very good Boost tutorial/book with lots of examples.
Then the rest is to set include directories and static link directories in MVS and that all. In order to do that in Solution Explorer right click on the solution name you want to compile, and go to Properties->Configuration Properties->VC++ Directories and for Include Directories and Library Directories add appropriate paths to header (.hpp) and static library (.lib) files. (Search them in C:\Boost!)
I meet some linking issue when I install boost with installer from "BoostPro Computing". And I solve it by compiling boost lib from source code. Here is the steps:
download boost from http://www.boost.org/users/history/version_1_52_0.html
unzip it
enter Visual Studio 2010 Express Command Prompt
cd to the unzipped boost dir
bootstrap.bat
.\b2
Done.
Here is my environment:
Win7 64bit
Visual Studio 2010 Express
boost 1_52_0
P.S. At the end of Boost build mentions the include directory and lib directory that should be added to corresponding paths so that Visual Studio could find them.
The link you found is a step-by-step guide..
If you can't do something like find the property manager, then I suggest you look at the help which will show you where it is..
For that particular case, the Property Manager can be found in the View menu, under 'Other Windows'
I tried to compile TinyXML++(or TICPP) using premake4 with these settings: "premake4 vs2010 [--unicode] [--ticpp-shared] [--dynamic-runtime]". It compiles the .libs but I can't compile TiCPP.vcxproj because the compiler says "Unable to start program c:\ticpp\lib\ticpp.lib. This file is an unrecognized or unsupported binary file." Anyone got a clue how to make this work? Oh and one more thing, why does Windows ask me if I want to open a .vcxproj with Visual Studio 2010 or Visual Studio 10? How do I make it so that it only picks one, and what's the difference. I tried the first answer, but it didn't work.
Download last version of premake, it does support VS2010
I have compiled tinyXML++ using it, by executing:
premake4 vs2010
it does generate valid sln and vcxproj files.
From oolua build instructions
Visual Studio 2010 (vs10) is not currently supported by premake yet if you have vs10 installed you can run the following command, it will generate vs9 projects and update them using the vs10 command line tool.
premake4 vs2010
As vs10 adds files which have not been created directly by premake, a specific clean operation has been added to the premake script.
premake4 cleanVS10
Scripts to build a local install, build and run unit test etc. have been added for vs10 in the script directory.
Notes:
* oolua's premake4 script may not be the same as yours.
* VS2010 support is borked in premake. Current workaround is to make a 2008 project and make VS2010 convert it for you.