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

macOS: pkgconfig contains wrong libdir #236

Closed
ole opened this issue Oct 8, 2017 · 9 comments
Closed

macOS: pkgconfig contains wrong libdir #236

ole opened this issue Oct 8, 2017 · 9 comments

Comments

@ole
Copy link

ole commented Oct 8, 2017

Is this the right place to report issues with the cmark formula for Homebrew? If not, my apologies. Could somebody direct me to the proper place? Thanks!

I installed cmark 0.28.0 on macOS 10.13 High Sierra (build 17A362a, i.e. the GM; the final release has build number 17A365, but I hope that's not relevant to this issue):

> brew --version
Homebrew 1.3.4
Homebrew/homebrew-core (git revision 7bce0; last commit 2017-10-08)

> brew doctor
Your system is ready to brew.

> brew install cmark
==> Downloading https://homebrew.bintray.com/bottles/cmark-0.28.0.high_sierra.bottle.tar.gz
Already downloaded: /Users/elo/Library/Caches/Homebrew/cmark-0.28.0.high_sierra.bottle.tar.gz
==> Pouring cmark-0.28.0.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/cmark/0.28.0: 17 files, 747.8KB

This is the pkgconfig file that I get:

> cat /usr/local/Cellar/cmark/0.28.0/lib/pkgconfig/libcmark.pc
prefix=/usr/local/Cellar/cmark/0.28.0
exec_prefix=/usr/local/Cellar/cmark/0.28.0
libdir=/usr/local/Cellar/cmark/0.28.0/
includedir=/usr/local/Cellar/cmark/0.28.0/include

Name: libcmark
Description: CommonMark parsing, rendering, and manipulation
Version: 0.28.0
Libs: -L${libdir} -lcmark
Cflags: -I${includedir}

If I'm not mistaken, libdir is wrong; it should be /usr/local/Cellar/cmark/0.28.0/lib, i.e. it's missing the final lib subdirectory.

As a result, pkgconfig returns the wrong thing for -L (libcmark.dylib is at cmark/0.28.0/lib, not cmark/0.28.0):

> pkg-config libcmark --libs --cflags
-I/usr/local/Cellar/cmark/0.28.0/include -L/usr/local/Cellar/cmark/0.28.0/ -lcmark

I don't think this issue is specific to macOS High Sierra. I downloaded the bottles for the older OSes manually (Sierra, El Capitan, Yosemite), and their libcmark.pc files look the same.

Building from source doesn't fix the issue, either:

> brew uninstall cmark
Uninstalling /usr/local/Cellar/cmark/0.28.0... (17 files, 747.8KB)

> brew install --build-from-source cmark
...
==> Installing cmark
==> Downloading https://github.com/jgm/cmark/archive/0.28.0.tar.gz
Already downloaded: /Users/elo/Library/Caches/Homebrew/cmark-0.28.0.tar.gz
==> cmake .. -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX
==> make
==> make test
==> make install
🍺  /usr/local/Cellar/cmark/0.28.0: 17 files, 748.5KB, built in 17 seconds

> cat /usr/local/Cellar/cmark/0.28.0/lib/pkgconfig/libcmark.pc
prefix=/usr/local/Cellar/cmark/0.28.0
exec_prefix=/usr/local/Cellar/cmark/0.28.0
libdir=/usr/local/Cellar/cmark/0.28.0/
includedir=/usr/local/Cellar/cmark/0.28.0/include

Name: libcmark
Description: CommonMark parsing, rendering, and manipulation
Version: 0.28.0
Libs: -L${libdir} -lcmark
Cflags: -I${includedir}
@jgm
Copy link
Member

jgm commented Oct 8, 2017 via email

@ole
Copy link
Author

ole commented Oct 8, 2017

@jgm Well, Homebrew says the right place is to "open an issue on the formula's repository", which is what led me here.

Having said that, I don't think anymore that this is a Homebrew issue (I'm going to edit the title of this issue accordingly).

I just built cmark from source and I'm seeing the same problem:

> cmake --version
cmake version 3.9.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

> git clone git@github.com:commonmark/cmark.git

Edit: I omitted the next two commands I typed when I first posted this:

> cd cmark
> make

Continuing with the results of make:

mkdir -p build; \
	cd build; \
	cmake .. \
		-G "Unix Makefiles" \
		-DCMAKE_BUILD_TYPE= \
		-DCMAKE_INSTALL_PREFIX=/usr/local \
		-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-- The C compiler identification is AppleClang 9.0.0.9000037
-- The CXX compiler identification is AppleClang 9.0.0.9000037
...
[100%] Built target libcmark_static
Binaries can be found in build/src

> cat build/src/libcmark.pc
prefix=/usr/local
exec_prefix=/usr/local
libdir=/usr/local/
includedir=/usr/local/include

Name: libcmark
Description: CommonMark parsing, rendering, and manipulation
Version: 0.28.0
Libs: -L${libdir} -lcmark
Cflags: -I${includedir}

Again, libdir in the pkgconfig file is /usr/local/ where I'd expect /usr/local/lib. I admit I don't know a lot about pkgconfig, but that's wrong, isn't it?

@ole ole changed the title Homebrew: pkgconfig contains wrong libdir macOS: pkgconfig contains wrong libdir Oct 8, 2017
@jgm
Copy link
Member

jgm commented Oct 9, 2017 via email

@ole
Copy link
Author

ole commented Oct 9, 2017

First of all, I made a copy-and-paste mistake above (apologies!) that may have made it seem like I passed some custom CMake options, but if I did I'm not aware of it. I just called make (now corrected in my post above).

I don't know anything about CMake, so it's hard for me to debug this, but it seems pretty clear that for whatever reason, @CMAKE_INSTALL_LIBDIR@ (used in libcmark.pc.in) is blank on my machine.

The hardcoded lib directory was replaced by @CMAKE_INSTALL_LIBDIR@ in #185.

I have no idea why this would be the case or what I may have done to misconfigure my system. As far as I know I'm using a stock CMake (v 3.9.4), installed via Homebrew.

The fact that the prebuilt binaries distributed by Homebrew (whoever maintains them) seem to have the same issue at least suggests I'm not alone.

@ole
Copy link
Author

ole commented Oct 9, 2017

Don't know if this helps, but my build/CMakeCache.txt file does list the value of CMAKE_INSTALL_LIBDIR as lib:

> cat build/CMakeCache.txt | grep -n -C 1 CMAKE_INSTALL_LIBDIR
110-//Object code libraries (lib)
111:CMAKE_INSTALL_LIBDIR:PATH=lib
112-
--
--
363-CMAKE_INSTALL_INFODIR-ADVANCED:INTERNAL=1
364://ADVANCED property for variable: CMAKE_INSTALL_LIBDIR
365:CMAKE_INSTALL_LIBDIR-ADVANCED:INTERNAL=1
366-//ADVANCED property for variable: CMAKE_INSTALL_LIBEXECDIR

@jgm
Copy link
Member

jgm commented Oct 9, 2017 via email

@jgm
Copy link
Member

jgm commented Oct 10, 2017 via email

@jgm jgm closed this as completed in afc9a17 Oct 10, 2017
@ole
Copy link
Author

ole commented Oct 10, 2017

@jgm Thanks!

@nwellnhof
Copy link
Contributor

CMAKE_INSTALL_LIBDIR being blank is probably caused by #240

talum referenced this issue in github/cmark-gfm Sep 14, 2021
For some reason this wasn't getting set in processing
libcmark.pc.in, and we were getting the wrong entry in libcmark.pc.
(See #236)

The new approach sets an internal libdir variable to
lib${LIB_SUFFIX}.  This variable is used both to set the
install destination and in the libcmark.pc.in template.

Closes #236.

However, I'd welcome comments from @juhp who originally
added CMAKE_INSTALL_LIBDIR in #185.  I think that the new
system should work fine with Fedora, since LIB_SUFFIX will
be set appropriately, but some testing is in order.
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

3 participants