c++ - GLOG - flags.cc' is being linked both statically and dynamically into this executable - Stack Overflow

时间: 2025-01-06 admin 业界

CMakeLists.txt

cmake_minimum_required(VERSION 3.20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(siriusx-infer CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# ------------------------------------
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
find_package(GTest CONFIG REQUIRED)
find_package(glog CONFIG REQUIRED)

# ------------------------------------
aux_source_directory(siriusx/src/base/ DIR_BASE)

# ------------------------------------
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

# ------------------------------------
add_library(llama SHARED ${DIR_BASE})
target_link_libraries(llama PUBLIC GTest::gtest_main GTest::gtest glog::glog)
target_include_directories(llama PUBLIC ${glog_INCLUDE_DIR})
target_include_directories(llama PUBLIC ${PROJECT_SOURCE_DIR}/siriusx/include)


add_subdirectory(test)

test/CMakeLists.txt

find_package(GTest CONFIG REQUIRED)
find_package(glog CONFIG REQUIRED)


aux_source_directory(../test DIR_TEST)
aux_source_directory(../test/test_example DIR_TEST_EXAMPLE)
# aux_source_directory(../test/test_tensor DIR_TEST_TENSOR)

add_executable(my_test
    ${DIR_TEST}
    ${DIR_TEST_EXAMPLE}
    # ${DIR_TEST_TENSOR}
)
target_link_libraries(my_test PUBLIC GTest::gtest_main GTest::gtest glog::glog)

target_include_directories(my_test PUBLIC
    ${glog_INCLUDE_DIR}
    ${GTest_INCLUDE_DIR}
    ../siriusx/include
)

target_link_directories(my_test PUBLIC ${PROJECT_SOURCE_DIR}/lib)


# target_link_libraries(my_test PUBLIC llama)

when i want to add the last line target_link_libraries(my_test PUBLIC llama),some issues have arisen.

ERROR: something wrong with flag 'timestamp_in_logfile_name' in file '/Users/moguw/.vcpkg/buildtrees/glog/src/v0.7.1-795557b621.clean/src/flags'.  One possibility: file '/Users/moguw/.vcpkg/buildtrees/glog/src/v0.7.1-795557b621.clean/src/flags' is being linked both statically and dynamically into this executable.

i have close my miniconda, and compiler the dynamic library, but as a C++ beginner, i have no more ideas

最新文章