gpt4 book ai didi

c++ - 如何使用 cmake 在 C++ 中包含外部库

转载 作者:行者123 更新时间:2023-11-28 01:41:55 25 4
gpt4 key购买 nike

我的目录如下:

-lib
-- mylibrary.dll
-- mylibrary.lib
-- mylibrary.exp
-main.cpp
-cmakelist

我希望我的 cmake 将库包含到主项目中,如下所示:

link_directories(${CMAKE_BINARY_DIR}/lib)
add_executable(test_app main.cpp)
target_link_libraries(testapp mylibrary)

但是 include 没有找到标题。我试过 find_package 但没有用...

谁能帮帮我?

最佳答案

您需要使用 include_directories将 CMake 指向您的标题搜索文件夹。

Add the given directories to those the compiler uses to search for include files. Relative paths are interpreted as relative to the current source directory.

关于c++ - 如何使用 cmake 在 C++ 中包含外部库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46810463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com