无法通过命令行编译Visual Studio项目。我究竟做错了什么?

时间:2018-09-09 17:01:21

标签: visual-studio command-line cross-compiling

我并不是真的想学习C / C ++,但是我需要编译将与Python一起使用的实用程序的源代码。

安装说明说我需要运行CMake来生成Visual Studio项目。成功运行后,我得到了此输出

C:/metis-5.1.0\build\Windows>cmake -DCMAKE_CONFIGURATION_TYPES="Release" ..\..
-- Building for: Visual Studio 14 2015
-- Selecting Windows SDK version  to target Windows 10.0.17134.
-- The C compiler identification is MSVC 19.0.24210.0
-- The CXX compiler identification is MSVC 19.0.24210.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for execinfo.h
-- Looking for execinfo.h - not found
-- Looking for getline
-- Looking for getline - not found
-- Configuring done
-- Generating done
-- Build files have been written to: C:/metis-5.1.0/build/Windows

由于我需要为Python 3.5 x86构建以上代码,因此我认为最好的选择是使用Visual C ++ 2015 x86 x64交叉构建工具命令提示符,因此我打开了该命令提示符,并使用以下命令行来编译结果项目(由上面创建)

C:\metis-5.1.0\build\Windows>MSBuild METIS.sln /property:Configuration=Release /property:Platform=x86
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 9/8/2018 8:36:45 PM.
Project "c:\metis-5.1.0\build\Windows\METIS.sln" on node 1 (default targets).
c:\metis-5.1.0\build\Windows\METIS.sln.metaproj : error MSB4126: The specified solutio
n configuration "Release|x86" is invalid. Please specify a valid solution configuration using the Configuration and Platform proper
ties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the defaul
t solution configuration. c:\metis-5.1.0\build\Windows\METIS.sln]
Done Building Project "c:\metis-5.1.0\build\Windows\METIS.sln" (default targets) -- FA
ILED.


Build FAILED.

c:\metis-5.1.0\build\Windows\METIS.sln" (default target) (1) ->
(ValidateSolutionConfiguration target) ->
  c:\metis-5.1.0\build\Windows\METIS.sln.metaproj : error MSB4126: The specified solut
ion configuration "Release|x86" is invalid. Please specify a valid solution configuration using the Configuration and Platform prop
erties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the defa
ult solution configuration. [c:\metis-5.1.0\build\Windows\METIS.sln]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.10

我在做什么错了?

更新:这是构建说明

The Visual Studio project will be called METIS.sln. Open it in Visual
Studio. If the configuration is not already "Release", set it to
"Release". Type F7 to build. The METIS library will be in
<BINARY_DIR>\libmetis\Release and the executable programs will be in
<BINARY_DIR>\programs\Release. (<BINARY_DIR> will be build\windows if
you used the command line or whatever you choose if using the CMake
GUI.) 

它们用于Visual Studio,而不用于命令行,所以我不知道是否必须设置“ Release”标志以及在何处?

更新:将命令行更改为 MSBuild METIS.sln / property:Configuration =发布/ property: Platform = Win32 解决了问题,但现在我遇到了其他错误:-(

1 个答案:

答案 0 :(得分:0)

不得不将命令行平台选项更改为Win32