Не получается запустить проект в VScode через CMake - ошибка "undefined reference to"

При запуске кода с таким содержимым CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0167 NEW)

set(PATCH_VERSION "1" CACHE INTERNAL "Patch version")
set(PROJECT_VESRION 0.0.${PATCH_VERSION})
set(Boost_DIR "C:/libs/boost_1_80_0")
set(Boost_DIR "C:/libs/boost_1_80_0/boost_lib/lib/cmake/Boost-1.80.0")

project(helloworld VERSION ${PROJECT_VESRION})

find_package(Boost COMPONENTS unit_test_framework REQUIRED)

configure_file(version.h.in version.h)

add_executable(helloworld_cli main.cpp)
add_library(helloworld lib.cpp)
add_executable(test_version test_version.cpp)

set_target_properties(helloworld_cli helloworld test_version PROPERTIES
    CXX_STANDARD 14
    CXX_STANDARD_REQUIRED ON
)
target_include_directories(helloworld
    PRIVATE "${CMAKE_BINARY_DIR}"
)

set_target_properties(test_version PROPERTIES
    COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK"
)

target_include_directories(test_version PRIVATE ${Boost_INCLUDE_DIR})

#set_target_properties(test_version PROPERTIES
#    COMPILE_DEFINITIONS BOOST_TEST_DYN_LINK
#    INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}
#)

target_link_libraries(helloworld_cli PRIVATE
    helloworld
)
target_link_libraries(test_version
    ${Boost_LIBRARIES}
    helloworld
)

if (MSVC)
    target_compile_options(helloworld_cli PRIVATE
        /W4
    )
    target_compile_options(helloworld PRIVATE
        /W4
    )
    target_compile_options(test_version PRIVATE
        /W4
    )
else ()
    target_compile_options(helloworld_cli PRIVATE
        -Wall -Wextra -pedantic -Werror
    )
    target_compile_options(helloworld PRIVATE
        -Wall -Wextra -pedantic -Werror
    )
    target_compile_options(test_version PRIVATE
        -Wall -Wextra -pedantic -Werror
    )
endif()



install(TARGETS helloworld_cli RUNTIME DESTINATION bin)

if(MSVC)
    set(CPACK_GENERATOR NSIS)

else()
    set(CPACK_GENERATOR DEB)
endif()

set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")

set(CPACK_PACKAGE_CONTACT [email protected])

include(CPack)

enable_testing()

add_test(test_version test_version)

В выходных данных выводит:

[main] Сборка папки: c:/Codes/ProgLabAction/build all
[build] Запуск сборки.
[proc] Выполнение команды: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Codes/ProgLabAction/build --config Debug --target all --
[build] [2/5  20% :: 0.475] Building CXX object CMakeFiles/helloworld.dir/lib.cpp.obj
[build] [3/5  40% :: 0.900] Linking CXX static library libhelloworld.a
[build] [4/5  60% :: 1.445] Linking CXX executable test_version.exe
[build] FAILED: test_version.exe 
[build] C:\Windows\system32\cmd.exe /C "cd . && C:\msys64\mingw64\bin\g++.exe -g  CMakeFiles/test_version.dir/test_version.cpp.obj -o test_version.exe -Wl,--out-implib,libtest_version.dll.a -Wl,--major-image-version,0,--minor-image-version,0  C:/libs/boost_1_80_0/boost_lib/lib/libboost_unit_test_framework-mgw14-mt-d-x64-1_80.a  libhelloworld.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `main':
[build] C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/unit_test.hpp:64:(.text+0x38): undefined reference to `__imp__ZN5boost9unit_test14unit_test_mainEPFbvEiPPc'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `test_valid_version_invoker':
[build] C:/Codes/ProgLabAction/test_version.cpp:9:(.text+0x117): undefined reference to `__imp__ZN5boost9unit_test15unit_test_log_t14set_checkpointENS0_13basic_cstringIKcEEyS4_'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Codes/ProgLabAction/test_version.cpp:9:(.text+0x1f8): undefined reference to `__imp__ZN5boost9unit_test15unit_test_log_t14set_checkpointENS0_13basic_cstringIKcEEyS4_'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Codes/ProgLabAction/test_version.cpp:9:(.text+0x2e8): undefined reference to `__imp__ZN5boost9unit_test15unit_test_log_t14set_checkpointENS0_13basic_cstringIKcEEyS4_'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Codes/ProgLabAction/test_version.cpp:9:(.text+0x3d8): undefined reference to `__imp__ZN5boost9unit_test15unit_test_log_t14set_checkpointENS0_13basic_cstringIKcEEyS4_'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Codes/ProgLabAction/test_version.cpp:9:(.text+0x4c8): undefined reference to `__imp__ZN5boost9unit_test15unit_test_log_t14set_checkpointENS0_13basic_cstringIKcEEyS4_'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj:C:/Codes/ProgLabAction/test_version.cpp:11: more undefined references to `__imp__ZN5boost9unit_test15unit_test_log_t14set_checkpointENS0_13basic_cstringIKcEEyS4_' follow
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `test_version::test_valid_version::test_method()':
[build] C:/Codes/ProgLabAction/test_version.cpp:11:(.text+0x67a): undefined reference to `__imp__ZN5boost10test_tools9tt_detail16report_assertionERKNS0_16assertion_resultERKNS_9unit_test12lazy_ostreamENS5_13basic_cstringIKcEEyNS1_10tool_levelENS1_10check_typeEyz'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `__static_initialization_and_destruction_0':
[build] C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/unit_test_log.hpp:227:(.text+0x6f1): undefined reference to `__imp__ZN5boost9unit_test15unit_test_log_t8instanceEv'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `__static_initialization_and_destruction_0':
[build] C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/unit_test_suite.hpp:383:(.text+0x763): undefined reference to `__imp__ZN5boost9unit_test9framework4impl29master_test_suite_name_setterC1ENS0_13basic_cstringIKcEE'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `__static_initialization_and_destruction_0':
[build] C:/Codes/ProgLabAction/test_version.cpp:7:(.text+0x76c): undefined reference to `__imp__ZN5boost9unit_test9decorator11collector_t8instanceEv'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Codes/ProgLabAction/test_version.cpp:7:(.text+0x7c1): undefined reference to `__imp__ZN5boost9unit_test9ut_detail24auto_test_unit_registrarC1ENS0_13basic_cstringIKcEES5_yRNS0_9decorator11collector_tE'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Codes/ProgLabAction/test_version.cpp:9:(.text+0x7ca): undefined reference to `__imp__ZN5boost9unit_test9decorator11collector_t8instanceEv'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Codes/ProgLabAction/test_version.cpp:9:(.text+0x848): undefined reference to `__imp__ZN5boost9unit_test9ut_detail24auto_test_unit_registrarC1EPNS0_9test_caseERNS0_9decorator11collector_tEm'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Codes/ProgLabAction/test_version.cpp:14:(.text+0x86c): undefined reference to `__imp__ZN5boost9unit_test9ut_detail24auto_test_unit_registrarC1Ei'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `boost::unit_test::lazy_ostream::~lazy_ostream()':
[build] C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/utils/lazy_ostream.hpp:34:(.text$_ZN5boost9unit_test12lazy_ostreamD2Ev[_ZN5boost9unit_test12lazy_ostreamD2Ev]+0xb): undefined reference to `__imp__ZTVN5boost9unit_test12lazy_ostreamE'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `boost::unit_test::lazy_ostream::~lazy_ostream()':
[build] C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/utils/lazy_ostream.hpp:34:(.text$_ZN5boost9unit_test12lazy_ostreamD1Ev[_ZN5boost9unit_test12lazy_ostreamD1Ev]+0xb): undefined reference to `__imp__ZTVN5boost9unit_test12lazy_ostreamE'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `boost::unit_test::lazy_ostream::instance()':
[build] C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/utils/lazy_ostream.hpp:36:(.text$_ZN5boost9unit_test12lazy_ostream8instanceEv[_ZN5boost9unit_test12lazy_ostream8instanceEv]+0x7): undefined reference to `__imp__ZN5boost9unit_test12lazy_ostream4instE'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `boost::unit_test::lazy_ostream::lazy_ostream(bool)':
[build] C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/utils/lazy_ostream.hpp:54:(.text$_ZN5boost9unit_test12lazy_ostreamC2Eb[_ZN5boost9unit_test12lazy_ostreamC2Eb]+0x10): undefined reference to `__imp__ZTVN5boost9unit_test12lazy_ostreamE'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/test_version.dir/test_version.cpp.obj: in function `boost::unit_test::make_test_case(boost::function<void ()> const&, boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long long)':
[build] C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/tree/test_unit.hpp:265:(.text$_ZN5boost9unit_test14make_test_caseERKNS_8functionIFvvEEENS0_13basic_cstringIKcEES8_y[_ZN5boost9unit_test14make_test_caseERKNS_8functionIFvvEEENS0_13basic_cstringIKcEES8_y]+0x63): undefined reference to `__imp__ZN5boost9unit_test9ut_detail24normalize_test_case_nameB5cxx11ENS0_13basic_cstringIKcEE'
[build] C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/libs/boost_1_80_0/boost_lib/include/boost-1_80/boost/test/tree/test_unit.hpp:265:(.text$_ZN5boost9unit_test14make_test_caseERKNS_8functionIFvvEEENS0_13basic_cstringIKcEES8_y[_ZN5boost9unit_test14make_test_caseERKNS_8functionIFvvEEENS0_13basic_cstringIKcEES8_y]+0x9d): undefined reference to `__imp__ZN5boost9unit_test9test_caseC1ENS0_13basic_cstringIKcEES4_yRKNS_8functionIFvvEEE'
[build] collect2.exe: error: ld returned 1 exit status
[build] [4/5  80% :: 1.485] Building CXX object CMakeFiles/helloworld_cli.dir/main.cpp.obj
[build] ninja: build stopped: subcommand failed.
[proc] Выход из команды "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Codes/ProgLabAction/build --config Debug --target all -- с кодом 1
[driver] Сборка выполнена: 00:00:01.654
[build] Сборка выполнена с кодом выхода 1.
[main] Не удалось подготовить исполняемый целевой объект с именем "undefined"

Ответы (0 шт):