如何使用Visual Studio

时间:2015-06-21 01:08:52

标签: visual-studio visual-studio-2012 visual-c++ boost

我正在开发一个需要Boost的正则表达式库的新项目。我能够使用无编译头,但需要一些需要编译的二进制文件。 Boost在Visual Studio中编译的文档不是很有帮助(导致了一些错误),我看到有相当数量的人在网上遇到这些相同的问题,但是需要大量的Google搜索来完成所有这些,所以我已经包括以下详细步骤,以帮助任何有相同问题的人。

我正在运行Windows 10预览版和Visual Studio 11(2012),但这些步骤也适用于其他版本。

步骤1 - 在Visual Studio中设置开发人员命令提示符

您需要这个来编译二进制文件。 VS命令窗口(Ctrl + W,A)似乎不起作用。

1. In VS , select "Tools" at the top, then select "External Tools" and enter the following:
    -Title: "VS2013 Native Tools-Command Prompt" (your choice)
    -Command: C:\Windows\System32\cmd.exe
    -Arguments: /k "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"  (make sure to use the correct path to your version of VS)
    -Initial Directory: Select as suits your needs (if you'll use boost a bunch, I'd select the folder where you dropped boost)
2. Click OK. Now you have command prompt access under the same "Tools" menu, where it will show up as a new option.

Source: https://stackoverflow.com/questions/21476588/where-is-developer-command-prompt-for-vs2013

步骤2 - 从VS developer命令提示符

运行Bootstrap.bat
1. Navigate to your Boost folder (mine is C:\Program Files\boost\boost_1_58_0)
2. Run `.\Bootstrap.bat` which results in the following error:

    > 'cl' is not recognized as an internal or external command"

    Cl.exe is is a tool that controls the Microsoft C and C++ compilers and linker.  This error is because cl.exe is not in your path environment variable; it isn't automatically added when you install VS. Check by running the following:
    -In PowerShell - `($env:path).replace(';',"`n")` (easy to read)
    -In cmd.exe - `echo %path%` (harder to read)  

 4. Add cl.exe to your path by adding its parent folder "C:\Program Files (x86)\Microsoft Visual Studio [your version]\VC\bin"
    -Hit Win+X -> System -> Advanced System Settings -> Environment Variables -> Select "Path" under System Variables (in bottom pane) -> Edit -> paste the following to the end: ";C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin" (don't forget the semicolon on the front)
    -Test by opening a new command prompt or PowerShell window and type `cl.exe -?`

步骤3 - 使用路径中的cl.exe重新运行bootstrap

您可能缺少Visual Studio的某些环境变量,导致以下错误:

  找不到mspdb110.dll

1. Navigate to the Visual Studio path in your Visual Studio developer command prompt (for me it's C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin) 
2. Run `.\vcvars32.bat` which automatically sets some variables for you, but there is no output -- lack of error means likely success

步骤4 - 编译Boost二进制文件

现在,在Visual Studio开发人员命令提示符下运行.\Bootstrap.bat应该会成功,现在您可以在项目中使用二进制文件了!

0 个答案:

没有答案