0

How can I connect external files to the library so that linking works? Becaus I get errors

*.obj : error LNK2019: unresolved external symbol "public: class ...

In CMakeLists i have target_include_directories(${PROJECT_NAME} PRIVATE "name of folder") But is not work

There are about 18 such directories for building the library.

  • In CMake **linking** is performed with `target_link_libraries` command. Note, that you need to explicitly specify each library you want to link, for this command passing a directory doesn't work. – Tsyvarev Aug 27 '23 at 15:08
  • So I do not have any libraries with which I need to link this library. – Alexey Ananyev Aug 27 '23 at 17:13
  • What do you mean by "external files" in your question post? If those files are **libraries** (`.lib`), then they should be linked using `target_link_libraries`, as I described in my previous comment. If those files are source files (`.cpp`), then they should be listed in `add_library` command which creates your library. If you want to collect all sources in some directory, then see e.g. [that question](https://stackoverflow.com/questions/3201154/automatically-add-all-files-in-a-folder-to-a-target-using-cmake). – Tsyvarev Aug 27 '23 at 18:10

0 Answers0