2017-03-26 1 views
0

J'ai construit yaml-cpp avec vs.bat cmake -G "Visual Studio 14 2015" ../:Comment construire yaml-cpp sur Visual Studio/cmake en ligne de commande?

$ vs.bat cmake -G "Visual Studio 14 2015" ../ 
-- The C compiler identification is MSVC 19.0.23506.0 
-- The CXX compiler identification is MSVC 19.0.23506.0 
-- Check for working C compiler: F:/VisualStudio2015/VC/bin/cl.exe 
-- Check for working C compiler: F:/VisualStudio2015/VC/bin/cl.exe -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Check for working CXX compiler: F:/VisualStudio2015/VC/bin/cl.exe 
-- Check for working CXX compiler: F:/VisualStudio2015/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 
-- Found PythonInterp: D:/Evandro/Documentos/Cygwin64/bin/python (found version "1.4") 
-- Looking for pthread.h 
-- Looking for pthread.h - not found 
-- Found Threads: TRUE 
-- Configuring done 
-- Generating done 
-- Build files have been written to: D:/source/libraries/yaml-cpp/bin_msvs 

vs.bat est:

@echo off 

:: Path to your Visual Studio folder. 
:: 
:: Examples: 
::  C:\Program Files\Microsoft Visual Studio 9.0 
::  F:\VisualStudio2015 
set VISUAL_STUDIO_FOLDER=F:\VisualStudio2015 

:: Load compilation environment 
call "%VISUAL_STUDIO_FOLDER%\VC\vcvarsall.bat" x64 

:: Invoke compiler with any options passed to this batch file 
%* 

Après genereating le projet pour Visual Studio, j'ai couru vs.bat devenv YAML_CPP.sln /Build:

$ vs.bat devenv YAML_CPP.sln /Build 
Microsoft Visual Studio 2015 Version 14.0.24720.0. 
Copyright (C) Microsoft Corp. All rights reserved. 
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------ 
1> Checking Build System 
1> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/CMakeFiles/generate.stamp is up-to-date. 
1> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/test/CMakeFiles/generate.stamp is up-to-date. 
1> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/test/gmock-1.7.0/CMakeFiles/generate.stamp is up-to-date. 
1> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/test/gmock-1.7.0/gtest/CMakeFiles/generate.stamp is up-to-date. 
1> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/util/CMakeFiles/generate.stamp is up-to-date. 
2>------ Build started: Project: gmock, Configuration: Debug Win32 ------ 
3>------ Build started: Project: gtest, Configuration: Debug Win32 ------ 
4>------ Build started: Project: yaml-cpp static md, Configuration: Debug Win32 ------ 
5>------ Build started: Project: gmock_main, Configuration: Debug Win32 ------ 
3> Building Custom Rule D:/source/libraries/yaml-cpp/test/gmock-1.7.0/gtest/CMakeLists.txt 
3> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/test/gmock-1.7.0/gtest/CMakeFiles/generate.stamp is up-to-date. 
3> gtest-all.cc 
2> Building Custom Rule D:/source/libraries/yaml-cpp/test/gmock-1.7.0/CMakeLists.txt 
2> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/test/gmock-1.7.0/CMakeFiles/generate.stamp is up-to-date. 
4> Building Custom Rule D:/source/libraries/yaml-cpp/CMakeLists.txt 
5> Building Custom Rule D:/source/libraries/yaml-cpp/test/gmock-1.7.0/CMakeLists.txt 
4> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/CMakeFiles/generate.stamp is up-to-date. 
2> gtest-all.cc 
5> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/test/gmock-1.7.0/CMakeFiles/generate.stamp is up-to-date. 
5> gtest-all.cc 
4> binary.cpp 
4> convert.cpp 
4> directives.cpp 
2> gmock-all.cc 
5> gmock-all.cc 
3> gtest.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\test\gmock-1.7.0\gtest\Debug\libgtest.lib 
6>------ Build started: Project: gtest_main, Configuration: Debug Win32 ------ 
4> emit.cpp 
6> Building Custom Rule D:/source/libraries/yaml-cpp/test/gmock-1.7.0/gtest/CMakeLists.txt 
6> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/test/gmock-1.7.0/gtest/CMakeFiles/generate.stamp is up-to-date. 
4> emitfromevents.cpp 
5> gmock_main.cc 
4> emitter.cpp 
6> gtest_main.cc 
2> Generating Code... 
2> gmock.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\test\gmock-1.7.0\Debug\libgmock.lib 
7>------ Skipped Build: Project: RUN_TESTS, Configuration: Debug Win32 ------ 
7>Project not selected to build for this solution configuration 
8>------ Skipped Build: Project: format, Configuration: Debug Win32 ------ 
8>Project not selected to build for this solution configuration 
6> gtest_main.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\test\gmock-1.7.0\gtest\Debug\libgtest_main.lib 
4> emitterstate.cpp 
5> Generating Code... 
4> emitterutils.cpp 
5> gmock_main.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\test\gmock-1.7.0\Debug\libgmock_main.lib 
4> exceptions.cpp 
4> exp.cpp 
4> memory.cpp 
4> node.cpp 
4> node_data.cpp 
4> nodebuilder.cpp 
4> nodeevents.cpp 
4> null.cpp 
4> ostream_wrapper.cpp 
4> parse.cpp 
4> parser.cpp 
4> regex_yaml.cpp 
4> Generating Code... 
4> Compiling... 
4> scanner.cpp 
4> scanscalar.cpp 
4> scantag.cpp 
4> scantoken.cpp 
4> simplekey.cpp 
4> singledocparser.cpp 
4> stream.cpp 
4> tag.cpp 
4> graphbuilder.cpp 
4> graphbuilderadapter.cpp 
4> Generating Code... 
4> yaml-cpp.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\Debug\libyaml-cppmdd.lib 
9>------ Build started: Project: parse, Configuration: Debug Win32 ------ 
10>------ Build started: Project: read, Configuration: Debug Win32 ------ 
11>------ Build started: Project: run-tests, Configuration: Debug Win32 ------ 
12>------ Build started: Project: sandbox, Configuration: Debug Win32 ------ 
9> Building Custom Rule D:/source/libraries/yaml-cpp/util/CMakeLists.txt 
12> Building Custom Rule D:/source/libraries/yaml-cpp/util/CMakeLists.txt 
10> Building Custom Rule D:/source/libraries/yaml-cpp/util/CMakeLists.txt 
9> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/util/CMakeFiles/generate.stamp is up-to-date. 
12> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/util/CMakeFiles/generate.stamp is up-to-date. 
10> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/util/CMakeFiles/generate.stamp is up-to-date. 
9> parse.cpp 
12> sandbox.cpp 
10> read.cpp 
11> Building Custom Rule D:/source/libraries/yaml-cpp/test/CMakeLists.txt 
11> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/test/CMakeFiles/generate.stamp is up-to-date. 
11> main.cpp 
11> ostream_wrapper_test.cpp 
12> sandbox.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\util\Debug\sandbox.exe 
12> sandbox.vcxproj -> D:/source/libraries/yaml-cpp/bin_msvs/util/Debug/sandbox.pdb (Full PDB) 
10> read.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\util\Debug\read.exe 
10> read.vcxproj -> D:/source/libraries/yaml-cpp/bin_msvs/util/Debug/read.pdb (Full PDB) 
9> parse.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\util\Debug\parse.exe 
9> parse.vcxproj -> D:/source/libraries/yaml-cpp/bin_msvs/util/Debug/parse.pdb (Full PDB) 
11> regex_test.cpp 
11> emitter_test.cpp 
11> encoding_test.cpp 
11> gen_emitter_test.cpp 
11> handler_spec_test.cpp 
11> handler_test.cpp 
11> load_node_test.cpp 
11> node_spec_test.cpp 
11> node_test.cpp 
11> Generating Code... 
11> run-tests.vcxproj -> D:\User\Dropbox\Applications\SoftwareVersioning\SublimeText\Data\Packages\ObjectBeautifier\source\libraries\yaml-cpp\bin_msvs\test\Debug\run-tests.exe 
11> run-tests.vcxproj -> D:/source/libraries/yaml-cpp/bin_msvs/test/Debug/run-tests.pdb (Full PDB) 
13>------ Build started: Project: ALL_BUILD, Configuration: Debug Win32 ------ 
13> Building Custom Rule D:/source/libraries/yaml-cpp/CMakeLists.txt 
13> CMake does not need to re-run because D:/source/libraries/yaml-cpp/bin_msvs/CMakeFiles/generate.stamp is up-to-date. 
14>------ Skipped Build: Project: INSTALL, Configuration: Debug Win32 ------ 
14>Project not selected to build for this solution configuration 
========== Build: 11 succeeded, 0 failed, 0 up-to-date, 3 skipped ========== 

Maintenant, je suis en train de le lier avec mon fichier de test de projet appelé main.cpp:

#include "yaml-cpp/yaml.h" 

#include <iostream> 
#include <sstream> 
#include <cstdlib> 
#include <exception> 

#include <fstream> 
#include <string> 
#include <vector> 

int main(int argumentsCount, char* argumentsStringList[]) 
{ 
    std::cout << "YAML\n" << std::endl; 

    // https://learnxinyminutes.com/docs/yaml/ 
    YAML::Node SyntaxFile = YAML::LoadFile("test.beauty-blocks"); 

    return EXIT_SUCCESS; 
} 

Lorsque je tente de le compiler avec vs.bat cl.exe /I. /I./libraries/yaml-cpp/include libraries/yaml-cpp/bin_msvs/Debug/libyaml-cppmdd.lib /EHsc /Femain.exe main.cpp est fait des sorties:

$ vs.bat cl.exe /I. /I./libraries/yaml-cpp/include libraries/yaml-cpp/bin_msvs/Debug/libyaml-cppmdd.lib /EHsc /Femain.exe main.cpp 

Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86 
Copyright (C) Microsoft Corporation. All rights reserved. 

main.cpp 
Microsoft (R) Incremental Linker Version 14.00.23506.0 
Copyright (C) Microsoft Corporation. All rights reserved. 

/out:main.exe 
libraries/yaml-cpp/bin_msvs/Debug/libyaml-cppmdd.lib 
main.obj 
libyaml-cppmdd.lib(parse.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(parse.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(exceptions.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(exceptions.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(parser.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(parser.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(nodebuilder.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(nodebuilder.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(directives.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(directives.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(scanner.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(scanner.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(singledocparser.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(singledocparser.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(node_data.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(node_data.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(memory.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(memory.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(regex_yaml.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(regex_yaml.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(stream.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(stream.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(simplekey.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(simplekey.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(scantoken.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(scantoken.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(tag.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(tag.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(null.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(null.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(scanscalar.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(scanscalar.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(scantag.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(scantag.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmdd.lib(exp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in main.obj 
libyaml-cppmdd.lib(exp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MT_StaticRelease' in main.obj 
msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" ([email protected]@@[email protected]@Z) already defined in libcpmt.lib(xlock.obj) 
msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" ([email protected]@@[email protected]) already defined in libcpmt.lib(xlock.obj) 
msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "bool __cdecl std::uncaught_exception(void)" ([email protected]@@YA_NXZ) already defined in libcpmt.lib(uncaught.obj) 
... 
libyaml-cppmdd.lib(exp.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(scantoken.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(tag.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(scanscalar.obj) : warning LNK4217: locally defined symbol __invalid_parameter imported in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
libyaml-cppmdd.lib(scantag.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(memory.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(regex_yaml.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(stream.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(simplekey.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(directives.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(scanner.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
libyaml-cppmdd.lib(singledocparser.obj) : warning LNK4049: locally defined symbol __invalid_parameter imported 
... 
libyaml-cppmdd.lib(parse.obj) : error LNK2001: unresolved external symbol __imp___CrtDbgReportW 
libyaml-cppmdd.lib(exceptions.obj) : error LNK2001: unresolved external symbol __imp___CrtDbgReportW 
libyaml-cppmdd.lib(parser.obj) : error LNK2001: unresolved external symbol __imp___CrtDbgReportW 
libyaml-cppmdd.lib(nodebuilder.obj) : error LNK2001: unresolved external symbol __imp___CrtDbgReportW 
libyaml-cppmdd.lib(tag.obj) : error LNK2001: unresolved external symbol __imp___wassert 
libyaml-cppmdd.lib(nodebuilder.obj) : error LNK2001: unresolved external symbol __imp___wassert 
libyaml-cppmdd.lib(scanner.obj) : error LNK2001: unresolved external symbol __imp___wassert 
libyaml-cppmdd.lib(singledocparser.obj) : error LNK2001: unresolved external symbol __imp___wassert 
libyaml-cppmdd.lib(node_data.obj) : error LNK2001: unresolved external symbol __imp___wassert 
MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4 
main.exe : fatal error LNK1120: 3 unresolved externals 

Moreoever Je recherche l'erreur error LNK2038: mismatch detected for et je trouve cette question:

  1. error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj

Il dit que je suis compiler un projet avec debug mode, mais je ne pouvais pas savoir comment le configurer pour construire à la fois sur release mode ou debug mode.


Resumely ce sont les lignes de commande utilisées:

cmake -G "Visual Studio 14 2015" ../ 
devenv YAML_CPP.sln /Build 
cl.exe /I. /I./libraries/yaml-cpp/include libraries/yaml-cpp/bin_msvs/Debug/libyaml-cppmdd.lib /EHsc /Femain.exe main.cpp 

Comment serait de les mettre à libérer ou le mode de débogage? La documentation yaml-cpp ne mentionne pas comment procéder. J'ai essayé d'utiliser cette autre réponse:

  1. Debug vs Release in CMAKE

Mais quand je courais vs.bat cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 14 2015" ../ délivrer en sortie:

$ vs.bat cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 14 2015" ../ 
-- Configuring done 
-- Generating done 
CMake Warning: 
    Manually-specified variables were not used by the project: 

    CMAKE_BUILD_TYPE 


-- Build files have been written to: D:/source/libraries/yaml-cpp/bin_msvs 

Il ne semble pas être reconnaissant la variable CMAKE_BUILD_TYPE mentionnée sur cette réponse.A été également ouvert une question sur: https://github.com/jbeder/yaml-cpp/issues/483


Mise à jour

Même après la réponse de @flyx Je suis une nouvelle erreur:

./cl_env.bat /I. /I./libraries/yaml-cpp/include libraries/yaml-cpp/bin_msvs/Release/libyaml-cppmd.lib /EHsc /Femain.exe main.cpp 
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86 
Copyright (C) Microsoft Corporation. All rights reserved. 

main.cpp 
Microsoft (R) Incremental Linker Version 14.00.23506.0 
Copyright (C) Microsoft Corporation. All rights reserved. 

/out:main.exe 
libraries/yaml-cpp/bin_msvs/Release/libyaml-cppmd.lib 
main.obj 
libyaml-cppmd.lib(exceptions.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmd.lib(memory.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmd.lib(node_data.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmd.lib(parse.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmd.lib(parser.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmd.lib(nodebuilder.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj 
libyaml-cppmd.lib(directives.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main.obj 
... 
libyaml-cppmd.lib(nodebuilder.obj) : warning LNK4049: locally defined symbol __invalid_parameter_noinfo_noreturn imported 
libyaml-cppmd.lib(directives.obj) : warning LNK4049: locally defined symbol __invalid_parameter_noinfo_noreturn imported 
libyaml-cppmd.lib(scanner.obj) : warning LNK4049: locally defined symbol __invalid_parameter_noinfo_noreturn imported 
libyaml-cppmd.lib(exceptions.obj) : warning LNK4217: locally defined symbol __invalid_parameter_noinfo_noreturn imported in function "void __cdecl std::_Deallocate(void *,unsigned int,unsigned int)" ([email protected]@@[email protected]) 
libyaml-cppmd.lib(memory.obj) : warning LNK4049: locally defined symbol __invalid_parameter_noinfo_noreturn imported 
libyaml-cppmd.lib(node_data.obj) : warning LNK4049: locally defined symbol __invalid_parameter_noinfo_noreturn imported 
libyaml-cppmd.lib(parse.obj) : warning LNK4049: locally defined symbol __invalid_parameter_noinfo_noreturn imported 
libyaml-cppmd.lib(scanscalar.obj) : warning LNK4049: locally defined symbol ___std_exception_destroy imported 
libyaml-cppmd.lib(scantag.obj) : warning LNK4049: locally defined symbol ___std_exception_destroy imported 
... 
libyaml-cppmd.lib(singledocparser.obj) : warning LNK4049: locally defined symbol ___std_exception_copy imported 
libyaml-cppmd.lib(scantoken.obj) : warning LNK4049: locally defined symbol ___std_exception_copy imported 
libyaml-cppmd.lib(tag.obj) : warning LNK4049: locally defined symbol ___std_exception_copy imported 
libyaml-cppmd.lib(scanscalar.obj) : warning LNK4049: locally defined symbol ___std_exception_copy imported 
libyaml-cppmd.lib(node_data.obj) : warning LNK4217: locally defined symbol ___std_exception_copy imported in function "public: __thiscall YAML::Exception::Exception(struct YAML::Mark const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@@[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) 
libyaml-cppmd.lib(parse.obj) : warning LNK4217: locally defined symbol ___std_exception_copy imported in function "public: virtual void * __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::`scalar deleting destructor'(unsigned int)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]) 
... 
libyaml-cppmd.lib(parse.obj) : warning LNK4217: locally defined symbol __errno imported in function _memcpy_s 
libyaml-cppmd.lib(scanscalar.obj) : warning LNK4217: locally defined symbol _memchr imported in function "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::find_last_not_of(char const *,unsigned int,unsigned int)const " ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) 
MSVCRT.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4 
main.exe : fatal error LNK1120: 1 unresolved externals 

Mais après avoir cherché error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease', j'ai découvert LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in file.obj , donc j'ai ajouté /MD (desc) à ma ligne de commande main, résultant de cette version complète étapes:

cmake -G "Visual Studio 14 2015" ../ 
devenv YAML_CPP.sln /Build Release 
cl.exe /I. /I./libraries/yaml-cpp/include libraries/yaml-cpp/bin_msvs/Debug/libyaml-cppmdd.lib /EHsc /MD /Femain.exe main.cpp 

Maintenant, il est enfin en train de se compiler.

Répondre

1

Visual Studio est une cible CMake qui permet de multiples configurations (vous pouvez avoir à la fois un débogage, un de presse et plusieurs autres configurations de construction dans un projet Visual Studio). Par conséquent, CMAKE_BUILD_TYPE est ignoré lors de la génération du fichier *.sln.

Au lieu de cela, vous devez donner la configuration lors de l'appel du compilateur, à savoir

vs.bat devenv YAML_CPP.sln /build Debug 

ou

vs.bat devenv YAML_CPP.sln /build Release 

Il semble étrange que votre commande fonctionne même étant donné que le nom de configuration est facultative selon le documentation.

Puisque vous compilez votre main.cpp sans options de débogage, vous devez compiler yaml-cpp avec la configuration Release.

En général, il serait judicieux de générer un fichier de solution pour votre code avec CMAKE - vous pouvez alors inclure le fichier yaml-cpp CMAKE et vous êtes assuré que tout se compile avec les mêmes commutateurs.