Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NMAKE:致命错误U1077:cl.exe和NMAKE.exe返回代码“0x2” 我试图用CGuess和CLION构建C++项目,但我有一些错误我不能理解: "C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" --build C:\Users\username\project-name\cmake-build-debug --target all_tests Scanning dependencies of target all_tests [ 0%] Building CXX object CMakeFiles/all_tests.dir/tests/all_tests.cpp.obj all_tests.cpp C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/compiler_log_formatter.ipp(64): warning C4273: 'boost::unit_test::output::compiler_log_formatter::log_start': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/output/compiler_log_formatter.hpp(37): note: see previous definition of 'log_start' C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/compiler_log_formatter.ipp(76): warning C4273: 'boost::unit_test::output::compiler_log_formatter::log_finish': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/output/compiler_log_formatter.hpp(38): note: see previous definition of 'log_finish' // ... // ... many more warnings like these // ... C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/unit_test_parameters.ipp(759): warning C4273: 'boost::unit_test::runtime_config::save_pattern': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/unit_test_parameters.hpp(93): note: see previous definition of 'save_pattern' NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~3\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\cl.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop._C++_Windows_Boost_Cmake - Fatal编程技术网

NMAKE:致命错误U1077:cl.exe和NMAKE.exe返回代码“0x2” 我试图用CGuess和CLION构建C++项目,但我有一些错误我不能理解: "C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" --build C:\Users\username\project-name\cmake-build-debug --target all_tests Scanning dependencies of target all_tests [ 0%] Building CXX object CMakeFiles/all_tests.dir/tests/all_tests.cpp.obj all_tests.cpp C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/compiler_log_formatter.ipp(64): warning C4273: 'boost::unit_test::output::compiler_log_formatter::log_start': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/output/compiler_log_formatter.hpp(37): note: see previous definition of 'log_start' C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/compiler_log_formatter.ipp(76): warning C4273: 'boost::unit_test::output::compiler_log_formatter::log_finish': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/output/compiler_log_formatter.hpp(38): note: see previous definition of 'log_finish' // ... // ... many more warnings like these // ... C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/unit_test_parameters.ipp(759): warning C4273: 'boost::unit_test::runtime_config::save_pattern': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/unit_test_parameters.hpp(93): note: see previous definition of 'save_pattern' NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~3\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\cl.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop.

NMAKE:致命错误U1077:cl.exe和NMAKE.exe返回代码“0x2” 我试图用CGuess和CLION构建C++项目,但我有一些错误我不能理解: "C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" --build C:\Users\username\project-name\cmake-build-debug --target all_tests Scanning dependencies of target all_tests [ 0%] Building CXX object CMakeFiles/all_tests.dir/tests/all_tests.cpp.obj all_tests.cpp C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/compiler_log_formatter.ipp(64): warning C4273: 'boost::unit_test::output::compiler_log_formatter::log_start': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/output/compiler_log_formatter.hpp(37): note: see previous definition of 'log_start' C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/compiler_log_formatter.ipp(76): warning C4273: 'boost::unit_test::output::compiler_log_formatter::log_finish': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/output/compiler_log_formatter.hpp(38): note: see previous definition of 'log_finish' // ... // ... many more warnings like these // ... C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/impl/unit_test_parameters.ipp(759): warning C4273: 'boost::unit_test::runtime_config::save_pattern': inconsistent dll link C:\PROGRA~2\Boost\include\BOOST-~1\boost/test/unit_test_parameters.hpp(93): note: see previous definition of 'save_pattern' NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~3\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\cl.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop.,c++,windows,boost,cmake,C++,Windows,Boost,Cmake,我使用的cmake文件如下所示: cmake_minimum_required(VERSION 3.9) project(project_name) set(CMAKE_CXX_STANDARD 11) # private lib add_library(lib INTERFACE) target_include_directories(lib INTERFACE src/utilities) # boost set(BOOST_ROOT "C:\\Program Files\\Boost

我使用的cmake文件如下所示:

cmake_minimum_required(VERSION 3.9)
project(project_name)

set(CMAKE_CXX_STANDARD 11)

# private lib
add_library(lib INTERFACE)
target_include_directories(lib INTERFACE src/utilities)

# boost
set(BOOST_ROOT "C:\\Program Files\\Boost")
find_package(Boost CONFIG 1.71.0)
if(Boost_FOUND)
    message("FOUND")
    include_directories(${Boost_INCLUDE_DIR})
endif()

SET(MAIN "...")
SET(TESTS "...")

add_executable(all_tests tests/all_tests.cpp ${MAIN} ${TESTS})
target_link_libraries(all_tests lib)

请注意,同一个项目在我的mac电脑上运行,但当我尝试在windows 10中构建它时,会出现此错误,那么这里的问题是什么

编辑:

所有_tests.cpp:

#define BOOST_TEST_DYN_LINK

#include <boost/test/unit_test.hpp>
#include <boost/test/included/unit_test.hpp>

// initialization function:
bool init_unit_test() {
    return true;
}

// entry point:
int main(int argc, char* argv[], char* envp[]) {
    return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
}
测试套件示例:

#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "../../src/path/to/header.hpp"

BOOST_AUTO_TEST_SUITE( Suite1 )

    BOOST_AUTO_TEST_CASE( Test1 ) {
        auto res = header_class::function1();
        BOOST_CHECK_EQUAL(res, expected_result);
    }

    BOOST_AUTO_TEST_CASE( Test2 ) {
        auto res = header_class::function2();
        BOOST_CHECK_EQUAL(res, expected_result);
    }

BOOST_AUTO_TEST_SUITE_END()
我非常确定测试用例中的代码是正确的,它不会导致问题。

标题boost/test/unit\u test.hpp和boost/test/included/unit\u test.hpp包含相同的功能,但用途不同:

boost/test/unit_test.hpp仅声明库文件中定义的函数, boost/test/included/unit_test.hpp定义函数,因此不需要包含库文件。
绝对不需要同时使用这两个标题。

我们需要查看您的代码,最好是一个标题。具体来说,您在所有_tests.cpp中都包含了哪些boost头文件。@selbie添加了测试文件codecan您也可以向我们显示最后的编译器消息吗?具体地说,是否在结尾处出现了将警告视为错误的错误?如果我正确理解Boost头的意图,那么Boost/test/unit_test.hpp提供了库文件中定义的函数,但是Boost/test/included/unit_test.hpp提供了可以在没有库文件的情况下使用的函数。为什么要混合这些标题?