When CMAKE_INSTALL_LIBDIR and CMAKE_INSTALL_INCLUDEDIR are set to absolute paths, the msgpack-c.pc file generated by CMake improperly configures libdir and includedir. This leads to incorrect paths that prevent the compiler from locating necessary header and library files.
The generated msgpack-c.pc file does not handle absolute paths correctly. Here is the result of the incorrect configuration in How to reproduce section. In the following msgpack-c.pc file, libdir and includedir are showing unrecognized paths, leading to incorrect paths.
% cat /tmp/local/lib/pkgconfig/msgpack-c.pc
prefix=/usr/local
exec_prefix=/usr/local
libdir=${prefix}//tmp/local/lib <- Here the path is wrong. We expected `/tmp/local/lib`
includedir=${prefix}//tmp/local/include <- Here the path is wrong. We expected `/tmp/local/include`
Name: MessagePack
Description: Binary-based efficient object serialization library
Version: 6.0.1
Libs: -L${libdir} -lmsgpack-c
Cflags: -I${includedir}
Solution
Modify the CMakeLists.txt file to ensure that libdir and includedir use absolute paths. This change addresses the issue by providing correct paths to the compiler and linker.
Issue
When
CMAKE_INSTALL_LIBDIR
andCMAKE_INSTALL_INCLUDEDIR
are set to absolute paths, themsgpack-c.pc
file generated by CMake improperly configureslibdir
andincludedir
. This leads to incorrect paths that prevent the compiler from locating necessary header and library files.How to reproduce
Build and install
msgpack-c
.Compile
example/simple_c.c
using installed msgpack-c. The following error happens because the linker cannot find paths provided by pkg-config.Expected
Successfully compile
example/simple_c.c
using installed msgpack-c. We can executesimple_c
like the following.Explain the problem in detail
The generated
msgpack-c.pc
file does not handle absolute paths correctly. Here is the result of the incorrect configuration inHow to reproduce
section. In the followingmsgpack-c.pc
file,libdir
andincludedir
are showing unrecognized paths, leading to incorrect paths.Solution
Modify the
CMakeLists.txt
file to ensure thatlibdir
andincludedir
use absolute paths. This change addresses the issue by providing correct paths to the compiler and linker.