Idk why my previous topic was determined like 'question not related for programming and tools` but I'll ask again and more accurate.
I moved from Windows to Mac and started working on my C++ project.
I installed brew, configured it and started to install libraries that I need.
- I installed
openldap
lib. - Openldap installation hint helped me to add path into my
~./zshrc
environment:
export PKG_CONFIG_PATH="/opt/homebrew/opt/openldap/lib/pkgconfig"
After that CMake successfully detected ldap, but when I installed hiredis
, I got an error that hiredis
can't be found. Again.
So, then I moved to ~/.zshrc
again and add another path and my PKG_CONFIG_PATH
starts look like:
export PKG_CONFIG_PATH="/opt/homebrew/opt/openldap/lib/pkgconfig":"/opt/homebrew/opt/hiredis/lib/pkgconfig"
To be honest, it's awful. After any brew installation I should always add new library path to help CMake detect it? Or there is more simple way for it?
Idk why my previous topic was determined like 'question not related for programming and tools` but I'll ask again and more accurate.
I moved from Windows to Mac and started working on my C++ project.
I installed brew, configured it and started to install libraries that I need.
- I installed
openldap
lib. - Openldap installation hint helped me to add path into my
~./zshrc
environment:
export PKG_CONFIG_PATH="/opt/homebrew/opt/openldap/lib/pkgconfig"
After that CMake successfully detected ldap, but when I installed hiredis
, I got an error that hiredis
can't be found. Again.
So, then I moved to ~/.zshrc
again and add another path and my PKG_CONFIG_PATH
starts look like:
export PKG_CONFIG_PATH="/opt/homebrew/opt/openldap/lib/pkgconfig":"/opt/homebrew/opt/hiredis/lib/pkgconfig"
To be honest, it's awful. After any brew installation I should always add new library path to help CMake detect it? Or there is more simple way for it?
Share Improve this question asked Mar 3 at 13:18 GrimlockGrimlock 1379 bronze badges 12 | Show 7 more comments1 Answer
Reset to default 2When installing packages, the homebrew package manager links files from the package-specific directory /opt/homebrew/Cellar/$PACKAGE/$VERSION/...
into /opt/homebrew/{include,lib,share}
.
Packages that ship a pkg-config
.pc file (such as hiredis) end up linked into /opt/homebrew/lib/pkgconfig
. The homebrew-supplied pkg-config
knows to find them there, and CMake's FindPkgConfig
calls pkg-config
to find these packages.
However, some packages overlap system libraries / binaries and the Homebrew team does not do this automatic linking by default.
Openldap is one such package:
% brew info openldap
==> openldap: stable 2.6.9 (bottled) [keg-only]
...
==> Caveats
openldap is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have openldap first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/openldap/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/openldap/sbin:$PATH"' >> ~/.zshrc
For compilers to find openldap you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/openldap/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openldap/include"
For pkg-config to find openldap you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/openldap/lib/pkgconfig"
For packages like these, you must explicitly tell pkg-config where to look. There are two options:
- set
PKG_CONFIG_PATH
before invoking CMake as above, or - append
/opt/homebrew
toCMAKE_PREFIX_PATH
. CMake will know to look under/opt/homebrew/lib/pkgconfig
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745093039a4610808.html
openldap
library? The secondopt/
in the path looks weird. – Tsyvarev Commented Mar 3 at 13:51cmake
output log? Because homebrew installs symlinks to your pkgconfig files into/opt/homebrew/lib/pkgconfig
, so that is the only path you should add toPKG_CONFIG_PATH
. Moreover, on my system thePkgConfig
module adapts to the paths ofpkg-config
, which includes that directory by default so you don't need the variable at all! – Botje Commented Mar 3 at 20:40/opt/homebrew/lib/pkgconfig
if you callbrew link hiredis
yourself? – Botje Commented Mar 4 at 7:55