I connect the static library to cmake:

project(protobuff) ... include_directories("D:/project/updater_proj/src/protobuff/protobuff-lib") ... target_link_libraries (protobuff libprotobuf) 

what the compiler curses: fatal error LNK1104: cannot open the file "libprotobuf.lib"

Where is the mistake? Sees but can not open? Or not at all? and how to connect a static library?

    2 answers 2

    include_directories is a compiler command that tells him where to look for headers (optional). You need to use the link_directories command:

     link_directories("D:/project/updater_proj/src/protobuff/protobuff-lib") 

    or directly indicate:

     target_link_libraries (D:/project/updater_proj/src/protobuff/protobuff-lib/protobuff.lib) 

    In general, according to the mind, it is done differently:

     find_package(protobuf REQUIRED) ... target_link_libraries(${PROTOBUF_LIBRARIES}) 

    That's all. What requirements does the search for this package have ?

    • The last link is very pleased! Thank you! - Mira

    The include_directories command is used to specify the directories in which the compiler will look for header files. You can use link_directories to specify the library search directories. Either use absolute paths (preferred method).

    If the linked library is external (that is, not one of your targets), then use import:

     add_library( lib STATIC IMPORTED ) set_target_properties( lib PROPERTIES IMPORTED_LOCATION ${Path_to_lib} ) 

    Or use find_package .