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

pkg-config returning wrong data for static linking #2988

Closed
hmel opened this issue Sep 5, 2020 · 5 comments
Closed

pkg-config returning wrong data for static linking #2988

hmel opened this issue Sep 5, 2020 · 5 comments
Labels

Comments

@hmel
Copy link
Contributor

hmel commented Sep 5, 2020

The cmake build creates a static library with the name libuv_a.a, but running with pkg-config --static --libs libuv returns -luv which then is not found by linker.

@bnoordhuis
Copy link
Member

Right, that's something I overlooked when switching to cmake.

CMakeListst.txt has two library targets, uv and uv_a, to allow building the shared and the static library at the same time.

Unfortunately, I don't know of a good way to inform pkg-config that the static library has a different name. I don't think it has e.g. a Libs.static: field.

I'm open to suggestions, as long as they're not variations on "drop the uv_a target." :-)

@hmel
Copy link
Contributor Author

hmel commented Sep 6, 2020

I'm no expert myself, but pkg-config has Libs.private which I think is what is needed in the .pc file.
On my system, for example, I have in vulcan.pc

exec_prefix=/usr
libdir=/usr/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: Vulkan-Loader
Description: Vulkan Loader
Version: 1.2.141
Libs: -L${libdir} -lvulkan
Libs.private:  -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
Cflags: -I${includedir}

and the output is

$ pkg-config --libs --static vulkan.pc
-lvulkan -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc

and

$ pkg-config --libs vulkan.pc
-lvulkan

@bnoordhuis
Copy link
Member

Libs.private: is for additional libraries that should be linked in when --static is specified, not for providing an alternative library name. I think pkg-config always uses Libs: for that.

@hmel
Copy link
Contributor Author

hmel commented Sep 8, 2020

After reading up some more on pkg-config I think the only option is to have two .pc files: libuv.pc and libuv-static.pc

@bnoordhuis
Copy link
Member

You know, that's not a bad idea. Want to open a PR?

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

No branches or pull requests

2 participants