Preventing other software from linking against MacPorts libraries

Ryan Schmidt ryandesign at macports.org
Thu May 9 08:14:10 UTC 2024


On May 9, 2024, at 01:03, Smith wrote:
> 
> I occasionally run into a problem where I'm building software from a tarball or a git clone outside of MacPorts, and the build process somehow ends up linking or trying to link against libraries in the MacPorts space (/opt/local). How can I prevent this from happening? Sometimes I just end up deleting /opt/local to get it to build and then re-install MacPorts, which can be painful or at least tiresome. I have to assume there is a better way or that I'm doing something wrong?

It depends on the software you're building and the libraries it's finding. 

Some software finds its dependencies using pkg-config. If that's what's happening here, you can prevent it by deactivating the pkgconfig port. 

Some software that builds with CMake uses its capabilities to find things. Sometimes it uses pkg-config for this and other times it checks a predefined list of paths, which includes standard system directories and MacPorts and Homebrew locations. (The MacPorts version of CMake is patched to remove the Homebrew references.) If this is what's happening, I'm not aware of a way to prevent CMake from finding libraries installed in those paths. For each such library, you may need to supply a CMake argument telling it where the library you want it to use is located, or to disable the use of that library. Consult the documentation for the program you are building to discover what options it has for this. 

Some software just has a hard coded list of paths where it looks for things (like CMake does). If this is what's happening, and the software doesn't let you override those choices, you can patch its build system to remove the references to /opt/local or to change them to something else. 

If you need help with a specific situation, let us know what software you're building and what library it's finding and we can try to figure out how that's happening. 




More information about the macports-users mailing list