CMake Cannot Locate Library Despite Using ""link_directories"
In your CMake configuration, you specified the directory containing the shared library with link_directories(/usr/lib/x86_64-linux-gnu). However, the linker reported undefined references to functions in the protobuf library.
The key to resolving this issue lies in the ordering of your CMake commands. Ensure that link_directories is called before add_executable:
link_directories(/usr/lib/x86_64-linux-gnu) add_executable(test main.cpp)
By adjusting the order, CMake will correctly locate the library and link it to your executable.
The above is the detailed content of Why Does CMake Fail to Find My Library Despite Using `link_directories`?. For more information, please follow other related articles on the PHP Chinese website!