CMake FIND_PACKAGE finds wrong version of SQLite3 on MacOS Monterey - macos

I need to use a new version of SQLite3 in a project built using CMake. To find external dependencies we usually use the FIND_PACKAGE() command which tends to work fine. However, FIND_PACKAGE(SQLite3) finds the very old version shipped with the OS rather than the up-to-date version provided by Homebrew. Homebrew refuses to relink to its own headers, binaries and libraries. I guess I could do that manually, but I am hesitant if Homebrew so strongly discourages it (refuses even when --force flag is given).
Any pointers on how to control where CMake looks for SQLite3 would be very appreciated.

Related

Replacing old Xcode command line tool with newer Brew version

I'm trying to build a binary from source code which has a dependency on the package" NASM 2.12.02 or later. However, I have an earlier version already installed on my Mac via Xcode:
/usr/local/bin/nasm -v
NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on May 1 2018
So to (attempt to) rectify this, I used Homebrew to install a much newer version of the package
brew info nasm
nasm: stable 2.13.03 (bottled), HEAD
However, now my PATH is only pointed to the old NASM executable, while the new tool seems to be sitting in Homebrew's Cellar (ie. /usr/local/Cellar/nasm/2.13.03).
Is there a nice way of "switching" between these versions so that the system PATH views only the newer version and disregards the older one? So far I've thought of rm -rf-ing the old version and exporting the new version to my PATH, but that seems very destructive.
Also, I have run the command: brew doctor and have resolved all linker errors, but that has not seemed to help.
Any help would be greatly appreciated!
To fix this, I used the following command:
export PATH=/usr/local/Cellar/nasm/2.13.03/bin:$PATH
This modifies the PATH variable to point to the /usr/local/Cellar/nasm/2.13.03/bin directory and find the nasm executable there before looking in /usr/local/bin.

OSX install multiple version of Clang

I know that if I install Xcode i would get clang installed bundled with the Xcode.
I want to know if I can install multiple versions of clang(other than the one bundled together with Xcode) on my mac and how?
Yes, there are many ways you can install another version of Clang. The most straightforward way would be to use MacPorts (Homebrew might be an option also, although I'm not sure). You could compile, build, and install it yourself, however, I would recommend going with the first suggestion as it will not interfere with any of the native system files and you can easily uninstall it if you want.

libpng not linked on Mac OSX 10.9.2

I installed matrix2png on my Mac and had used it without problem before last week when I installed another image manipulating tool "circos". Circos requires me to install a different version of libpng, and I did. After that, I am no longer able to run matrix2png, which gives me the following error. I think the old ligpnb is not linked any more. Does anyone know how to fix this error? - appreciate your help.
dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/bin/matrix2png
Reason: image not found
Those step solve my problem:
brew versions libpng
You will see some versions of libpng, but unfortunately not 1.5.15, so next you should install 1.5.18.
git checkout 7bec702 Library/Formula/libpng.rb
brew install libpng
You'll will find version 1.5.18 and some another versions.
ln -s /usr/local/Cellar/libpng/1.5.18/lib/libpng15.15.dylib /usr/local/lib/libpng15.15.dylib`
See https://github.com/Homebrew/homebrew-php/issues/1055
Some more info on installing certain versions of brew formulas can be found at https://coderwall.com/p/lqphzg.
Your new version of libpng has probably changed the name of its dyld files. This often happens with upgrades (especially following a major release). To verify this, open up the terminal and type:
ls /usr/local/lib/libpng*
What do you see?
From your error message we know that matrix2png is looking for libpng15 but if you've upgraded when instaling circos then you may now have libpng16 on your system. Consequently matrix2png won't be able to find the files that it's looking for and will be unhappy.
Fixing it this time:
Try re-installing matrix2png and see whether it notices the dependency issues and fixes it for you. You don't really want to downgrade libpng nor do you want to have two versions of it on your system, so having an up-to-date version of matrix2png would be good.
It looks like matrix2png comes from C source code, so you'll want to rebuild it. Download the source code or and then open a terminal. Navigate to the folder with the source code and run configure and then make. Configure will generate a Makefile for your system, and then make will use that file to generate a new binary. I've tested this on my Mac (with libpng16), and found that matrix2png built without any errors.
Suggested future approach:
To prevent future linking problems, you may want to use a package manager like homebrew or macports. In case you're using (or want to use) homebrew, it has circos and lib2png (but not matrix2png, sorry!). Once brew is installed, type the following into the terminal:
brew install libpng
And it should detect linking issues / version conflicts and guide you through fixing them. Brew places all of it's files in a 'cellar' location in /usr/local/Cellar and then symbolically links them into your system.
In case you're already using brew, try brew doctor and follow the instructions to resolve problems.
My experience (I've been dealing with a lot of version conflicts in the past few weeks) is that package managers make life much easier. Occasionally I've had to remove and reinstall packages to fix version issues, but in general brew keeps things neat and working.

Haskell wx fails install Macosx

I was trying to get wxHaskell installed on my mac (Osx Mavericks). I fixed the issue with gcc, and I used brew to install wxmac (version 3.0). The issue that keeps coming up is that the hackage cabal searches for looks for wx 2.9, while I have 3.0. It says that it can't find:
Warning: No config found to match: /usr/local/bin/wx-config --version=2.9 --version-full
in /usr/local/Cellar/wxmac/3.0.0.0/lib/wx/config
If you require this configuration, please install the desired
library build. If this is part of an automated configuration
test and no other errors occur, you may safely ignore it.
You may use wx-config --list to see all configs available in
the default prefix.
I can't find any way to install a different version of wx through brew. Does anyone have a fix?
Thanks!

How can I prevent homebrew from upgrading VTK dependency for PCL?

I would like to install the pcl formula through homebrew, which is documented here:
http://www.pointclouds.org/documentation/tutorials/installing_homebrew.php
Unfortunately, homebrew decides it needs to upgrade my VTK installation to the latest release (6.0) even though I have a perfectly working version (5.10.1) installed already. I would like to compile against and link with this existing version. (The minimum VTK version for pcl is listed as 5.6.1, so everything should work fine. I actually manually build pcl and tried to link it against VTK 6.0, which doesn't even work, yet.)
Therefore, my question is, why does homebrew try to upgrade VTK (to an incompatible version) and how can I prevent it from doing this?
All I am calling is: brew install pcl, which triggers this:
==> Installing pcl dependency: vtk
==> Downloading http://www.vtk.org/files/release/6.0/vtk-6.0.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/vtk-6.0.0.tar.gz
This eventually leads to an error, as vtk 6.0 does not compile under Mac OS X 10.9 through homebrew (https://github.com/Homebrew/homebrew-science/issues/401).
To be clear, even if VTK 6.0 would compile fine, I do not want to upgrade, so does anyone know how to prevent homebrew from upgrading a dependent formula?
You can trick Homebrew to think it has Vtk 6.0 installed. For that you have to run this command in a terminal
ln -s /usr/local/Cellar/vtk/5.10.1 /usr/local/Cellar/vtk/6.0.0
When the time comes for you to really want to update vtk, just eliminate that symlink with
rm /usr/local/Cellar/vtk/6.0.0
and let Homebrew do its job.
Homebrew actually has a formula for vtk5 separately now, so this should now be the correct way to install it (currently it's 5.10.1).
brew install vtk5 --with-qt
You also need eigen, flann, qhull and boost. Also useful, but optional is getting sphinx via pip install sphinx if you want docs. If you want to build simulations (see below option) then you need to get glew too (although it wouldn't find the header).
I can verify that this works on 10.8 and will check 10.9 tonight. I've had problems installing 1.7.1 from the archive, but cloning the github repository worked for me.
$ git clone https://github.com/PointCloudLibrary/pcl pcl-trunk
$ cd pcl_trunk
$ mkdir build; cd build
$ cmake .. -DBUILD_global_tests=ON -DBUILD_examples=ON -DBUILD_simulations=ON
$ ./configure; make; make install
Without VTK you can get to a few % before the PCL install fails. Installing VTK with X11 seems to be a recipe for a disaster here, I had to manually install libX11, libXt and others because VTK was trying to include the incorrect headers. The problems continued with OpenGL and I couldn't compile past around 42%. I reinstalled vtk5 without --with-x11 and it compiled fully.
There is a PCL formula for Homebrew knocking around, but it's rarely updated and I didn't have much luck editing it (not familiar enough with Brew's syntax). I tried to update it and submit a pull request, but when it came to testing the actual 'stable' build fails at the moment so there's no point.
EDIT: To be clear, installing the 1.7.1 tarball fails due to some problem with Eigen (around 12% in when compiling pcl_search).
Proposed pull request, it's a HEAD only fix at the moment.
https://github.com/ros/homebrew-hydro/pull/7
Just downgrade to previous version.
1) cd /usr/local/Library/Taps/homebrew-science/
2) brew versions vtk
3) git checkout 27a4327 vtk.rb
4) brew uninstall vtk && brew install vtk

Resources