Witam,
w ramach laboratoriów z programowania obiektowego mam za zadanie działać na repozytorium i je rozwijać. Dostałem na początku maszynę wirtualną z wszystkimi potrzebnymi narzędziami (CentOS 9), gdzie zacząłem pracę z projektem (dodam, że w środowisku CLion). Jednak po jakimś czasie uznałem, że praca na moim systemie będzie bardziej wydajniejsza, dlatego sklonowałem repozytorium na swój system Windows.
Wcześniej zainstalowałem w systemie (Windows) środowisko MSYS2 razem z narzędziami MinGW (toolchain, cmake, boost, qt5) oraz narzędziami MSYS2 (man, git, svn). Jeżeli chodzi o ustawienia CLion'a, to na Linuxie korzysta on z domyślnych narzędzi oraz generatora Ninja, na Windowsie korzysta z tego samego generatora (domyślnie) i zainstalowanych narzędzi MinGW. Dodałem odpowiednie ścieżki do PATH.
Program źródłowy projektu uruchamia się bez problemów, jednak budowanie projektu kończy się błędami. Poniżej zamieszczam listing z CLion'a:
"C:\Program Files\JetBrains\CLion 2022.3.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\Users\kamil\Desktop\wwan_cz_1330_05\jaskiewicz\workshop\CarRental\cmake-build-debug --target all -j 6
[1/1] Linking CXX executable library\LibraryTest.exe
FAILED: library/LibraryTest.exe
cmd.exe /C "cd . && C:\PROGRA~1\JETBRA~1\CLION2~1.3\bin\mingw\bin\G__~1.EXE -g3 -gdwarf-4 library/CMakeFiles/LibraryTest.dir/test/master.cpp.obj library/CMakeFiles/LibraryTest.dir/test/ClientTest.cpp.obj -o library\LibraryTest.exe -Wl,--out-implib,library\libLibraryTest.dll.a -Wl,--major-image-version,0,--minor-image-version,0 library/libLibrary.a C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: library/CMakeFiles/LibraryTest.dir/test/master.cpp.obj:C:/msys64/mingw64/include/boost/test/unit_test.hpp:64: undefined reference to `__imp__ZN5boost9unit_test14unit_test_mainEPFbvEiPPc'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: library/CMakeFiles/LibraryTest.dir/test/master.cpp.obj:C:/msys64/mingw64/include/boost/test/unit_test_log.hpp:227: undefined reference to `__imp__ZN5boost9unit_test15unit_test_log_t8instanceEv'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: library/CMakeFiles/LibraryTest.dir/test/master.cpp.obj: in function `boost::unit_test::ut_detail::global_configuration_impl<MyConfig>::global_configuration_impl()':
C:/msys64/mingw64/include/boost/test/tree/global_fixture.hpp:86: undefined reference to `__imp__ZN5boost9unit_test20global_configurationC2Ev'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: library/CMakeFiles/LibraryTest.dir/test/master.cpp.obj: in function `boost::unit_test::ut_detail::global_configuration_impl<MyConfig>::~global_configuration_impl()':
C:/msys64/mingw64/include/boost/test/tree/global_fixture.hpp:84: undefined reference to `__imp__ZN5boost9unit_test20global_configurationD2Ev'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(decorator.o):(.text+0x61): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(decorator.o):(.text+0x132): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(decorator.o):(.text+0xa4a): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(decorator.o):(.text+0xbb5): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(decorator.o):(.text+0xf3d): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(decorator.o):(.text+0x1443): more undefined references to `__stack_chk_fail' follow
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(decorator.o):(.rdata$.refptr.__stack_chk_guard[.refptr.__stack_chk_guard]+0x0): undefined reference to `__stack_chk_guard'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(framework.o):(.text+0xf2): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(framework.o):(.text+0x1a2): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(framework.o):(.text+0x5e3): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(framework.o):(.text+0x1507): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(framework.o):(.text+0x21df): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(framework.o):(.text+0x2588): more undefined references to `__stack_chk_fail' follow
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(debug.o):(.text+0x1c3): undefined reference to `__chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(debug.o):(.text+0x2fd): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(execution_monitor.o):(.text+0xb2): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(execution_monitor.o):(.text+0x45e): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(execution_monitor.o):(.text+0xc60): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(execution_monitor.o):(.text+0xd09): undefined reference to `__stack_chk_fail'
C:\Program Files\JetBrains\CLion 2022.3.3\bin\mingw\bin/ld.exe: C:/msys64/mingw64/lib/libboost_unit_test_framework-mt.a(execution_monitor.o):(.text$_ZN5boost4core8demangleB5cxx11EPKc[_ZN5boost4core8demangleB5cxx11EPKc]+0xa2): more undefined references to `__stack_chk_fail' follow
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Jeżeli to pomoże, zamieszczam również zawartość CMakeLists.txt dla podprojektu Library:
cmake_minimum_required(VERSION 3.4)
project(Library)
set(SOURCE_FILES
include/model/Client.h src/model/Client.cpp)
#Utwórz bibliotekę typu STATIC, SHARED albo MODULE ze wskazanych źródeł
add_library(Library ${SOURCE_FILES})
target_include_directories(Library PUBLIC include)
enable_testing()
find_package (Boost 1.60.0 COMPONENTS "unit_test_framework" REQUIRED)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS}
)
set(SOURCE_TEST_FILES test/master.cpp test/ClientTest.cpp) # tu w przyszłości będą dodawane pliki źródłowe testów
add_executable (LibraryTest ${SOURCE_TEST_FILES})
#dołącz bibliotekę z testowanymi klasami oraz bibliotekę boost.test do programu testów
target_link_libraries (LibraryTest
Library
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
)
#dodaj test TestBiblioteki1. Instrukcji cmake add_test może być wiele.
#Dodatkowe parametry wpływają na szczegółowość generowanego raportu. Standardowo znajduje się on w Testing/Temporary.
add_test(LibraryTest1 LibraryTest
--report_level=detailed
--log_level=all
--color_output=yes
)
W czym tkwi błąd? Jak można to naprawić?