如何在Windows中使用cmake构建库

时间:2017-12-01 05:24:53

标签: cmake

我尝试在Windows中使用cmake构建一个库(称为libiec61850)。我已经安装了cmake,并在我安装了cmake的目录中配置了“path”环境。然后, 1-I在我的库目录中创建了一个名为“build”的子文件夹 2-我在命令行中复制子文件夹目录并键入    cmake -G“Visual Studio 14 2015”并收到如下错误:   - lagénérationadémarré   - echec de la build   - Cmakeoutput.log:“系统是:Windows - 6.1.7601 - AMD64”

参见附件。

请你帮助将是宝贵的。error_cmake_windows

1 个答案:

答案 0 :(得分:0)

我只是抬起图书馆并自己试了一下,然后我开始工作了。

我通常使用NMake来编译Visual Studios程序。如果您要使用相同的,则需要确保在使用之前正确设置了MSVC环境。我通常先在cmd中运行vcvarsall.bat,如下所示:

D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat

您可以在Visual Studio 2015文件夹中的vcvarsall.bat文件的任何位置执行相同的操作(我使用的是Visual Studio 2017,但它也适用于Visual Studio 2015)。

接下来,这些是我使用的命令及其各自的输出:

D:\Users\patrick\src\vs2017>cd libiec61850

D:\Users\patrick\src\vs2017\libiec61850>mkdir build

D:\Users\patrick\src\vs2017\libiec61850>cd build

D:\Users\patrick\src\vs2017\libiec61850\build>cmake .. -G "NMake Makefiles"
-- The C compiler identification is MSVC 19.11.25547.0
-- The CXX compiler identification is MSVC 19.11.25547.0
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503
/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503
/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.255
03/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.255
03/bin/Hostx64/x64/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 clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
server-example-logging: sqlite not found
-- Generating RC file : D:/Users/patrick/src/vs2017/libiec61850/build/src/version.rc
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
-- Performing Test COMPILER_HAS_DEPRECATED
-- Performing Test COMPILER_HAS_DEPRECATED - Success
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Users/patrick/src/vs2017/libiec61850/build

D:\Users\patrick\src\vs2017\libiec61850\build>nmake

Microsoft (R) Program Maintenance Utility Version 14.11.25547.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Scanning dependencies of target iec61850
[  0%] Building CXX object src/CMakeFiles/iec61850.dir/common/string_map.c.obj
string_map.c

然后继续编译。

尝试所有这些。如果你创建一个构建目录,你可能需要“cd”#c;进入它,然后运行cmake与' ..'表示CMakeLists.txt目录是一个目录。如果您不能使用NMake或者它不起作用,请告诉我。