B_Tree)
set(SOURCES
B_Tree.cpp)
add_executable(B_Tree ${SOURCES})
target_link_libraries(B_Tree LINK_PUBLIC Tree_Base)
CMakeList.txt( в папке Tree_Base)
set(SOURCES
Tree_Base.cpp)
add_library(Tree_Base ${SOURCES})
target_include_directories(Tree_Base PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
CMakeList.txt( самый главный)
cmake_minimum_required(VERSION 3.20)
project(Tree CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(Tree main.cpp)
add_subdirectory(Tree_Base)
add_subdirectory(B_Tree)
target_link_libraries(${PROJECT_NAME} Tree_Base)
Где я здесь совершаю ошибку, что он линковать правильно не хочет?
Первый лист B_Tree является частью Tree_Base
/usr/bin/ld: CMakeFiles/Tree.dir/main.cpp.o: in function `main': /home/ansasequence/Desktop/Workspace/Tree/main.cpp:5: undefined reference to `tree::B_Tree::B_Tree()' /usr/bin/ld: /home/ansasequence/Desktop/Workspace/Tree/main.cpp:5: undefined reference to `tree::B_Tree::~B_Tree()' collect2: error: ld returned 1 exit status make[3]: *** [CMakeFiles/Tree.dir/build.make:93: Tree] Error 1 make[2]: *** [CMakeFiles/Makefile2:118: CMakeFiles/Tree.dir/all] Error 2 make[1]: *** [CMakeFiles/Makefile2:125: CMakeFiles/Tree.dir/rule] Error 2 make: *** [Makefile:124: Tree] Error 2
ок, а конструктор B_Tree в каком cpp находится?
B_Tree.cpp
Обсуждают сегодня