Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible error in generated pkg-config file #59

Open
franko opened this issue May 19, 2021 · 2 comments
Open

possible error in generated pkg-config file #59

franko opened this issue May 19, 2021 · 2 comments

Comments

@franko
Copy link

franko commented May 19, 2021

I have compiled the reproc library on windows using MSYS2 using the command:

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DREPROC++=OFF -DBUILD_SHARED_LIBS=OFF ..

so I have disabled the build of the shared library to have only the static library.

Now the pkg-config --libs command on reproc will return "-lreproc" and not the ws2_32 library required on Windows. This is because the ws2_32 library is declared as private in the ".pc" file:

prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@

Name: @TARGET@
Description: @PROJECT_DESCRIPTION@
URL: @PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -l@TARGET@
Libs.private: @REPROC_THREAD_LIBRARY@ @REPROC_WINSOCK_LIBRARY@ @REPROC_RT_LIBRARY@

The problem is that I have installed only the static library and the ws2_32 is needed.

The pkg-config documentation states:

Libs.private: The link flags for private libraries required by this package but not exposed to applications. The same rule as Cflags applies here.

In my understanding, when the dynamic library is disabled and the static library is going to be used all the libraries required should be listed in "Libs:" in the .pc file because "they are exposed to applications".

@DaanDeMeyer
Copy link
Owner

From what I understand, it should be possible to use the same pkgconfig file for both static and dynamic versions of reproc. Shouldn't you be running pkg-config --libs --static when you're using reproc as a static library?

@franko
Copy link
Author

franko commented Jun 13, 2021

If a library is available only as a static library it means that an application that tries to link using pkg-config --libs will fail. So the application needs to know by some other means if the library is provided as a static or shared library and based on this information use a different pkg-config command, with or without the --static flag.

To me this is the wrong behavior. If the library is available as a static library the plain command pkg-config --libs should simply return the right flags to correctly link. Please note that this is normally how other library works when they are compiled and installed as a static library. This is also what Meson was doing for reproc out of the box with the configuration I proposed in the PR.

To me the --static flag is there only for the case when the library is provided both as a static or dynamic library. In this case the --static flag let you choose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants