brew install libusb linking failed - homebrew

I am installing libusb with brew in my Mac
brew install libusb
The linking step failed as below
Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local
Could not symlink lib/libusb-1.0.0.dylib
Target /usr/local/lib/libusb-1.0.0.dylib already exists.
You may want to remove it: rm '/usr/local/lib/libusb-1.0.0.dylib'
To force the link and overwrite all conflicting files: brew link
--overwrite libusb
So I removed the existing libusb with
sudo rm '/usr/local/lib/libusb-1.0.0.dylib'
and then did a link
brew link --overwrite libusb
The linking doesn't work, shows error below
Error: Could not symlink lib/libusb-1.0.0.dylib
/usr/local/lib is not writable.
If I try
sudo brew link --overwrite libusb
instead, that doesn't work either. What am I missing?
I am using OSX El Capitan version 10.11.4 (15E65)

If things seem not to work with homebrew, my general strategy is first to try:
brew doctor
and do whatever the good doctor recommends.
If that fails, I tend to uninstall things, normally using --force which really does a good clean-up and removes old versions. So, in your case:
brew rm libusb --force
Then re-install the "unhappy" package. So, in your case:
brew install libusb
In answer to your new question in the comments. Your installation looks correct because libusb isn't an executable program - it is just a library without any associated command-line tools - so it won't show up when you run which libusb.
You can see the constituent parts of the package with this command:
brew ls libusb
/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0/libusb.h
/usr/local/Cellar/libusb/1.0.20/lib/libusb-1.0.0.dylib
/usr/local/Cellar/libusb/1.0.20/lib/pkgconfig/libusb-1.0.pc
/usr/local/Cellar/libusb/1.0.20/lib/ (2 other files)
And, as you can see, there is no stand-alone executable program in /usr/local/bin called libusb, there are just
libusb.h - a C header file you would compile against
libusb...dylib - a dynamic library you would link against
libusb...pc - which supplies the info for the pkgconfig tool
So, if you wanted to compile and link an application against libusb, you would run pkg-config like this to find out the "Include path" and linker details
pkg-config --cflags --libs libusb
-I/usr/local/Cellar/libusb-compat/0.1.5/include \
-I/usr/local/Cellar/libusb/1.0.20/include/libusb-1.0 \
-L/usr/local/Cellar/libusb
which means your compilation command would look like this:
gcc yourApp.c $(pkg-config --cflags --libs libusb) -o yourApp

Related

Can I install arm64 libraries on x86_64 with homebrew?

I am cross-compiling on x86_64 MacOS 11 for arm64 architecture.
clang/XCode support it but I face an issue when external library is required.
Let it be boost, for example. I know that the bottle for arm64 is available but it looks like there is no way to select it for installation.
arch -arm64 brew ... says that this architecture is unknown which sounds fair.
So the question is wheather there is an option to force brew install bottles for 'foreign' architecture ?
Thanks to Homebrew team
https://github.com/Homebrew/discussions/discussions/2843
I made it work with the code like this:
setopt sh_word_split
mkdir arm-homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C arm-homebrew
alias arm-brew='$(pwd)/arm-homebrew/bin/brew'
response=$(arm-brew fetch --force --bottle-tag=arm64_big_sur boost | grep "Downloaded to")
parsed=($response)
arm-brew install $parsed[3]
Native system brew can be asked to download any desired bottle version with two switches:
--force ignores the compatibility check
--bottle-tag=arm64_big_sur downloads the ARM Big Sur build. This assumes the formula has this build, check the formula .rb for available tags. Big Sur is the earliest macOS with ARM support.
Then use brew --cache to get the filename of the downloaded bottle and pass to brew install:
brew fetch --force --bottle-tag=arm64_big_sur boost
brew install $(brew --cache --bottle-tag=arm64_big_sur boost)
You can verify that it worked with cd $(brew --prefix boost) then use file on any .dylib files to see what architecture they're built for.
If the formula has any dependencies then they will still be installed normally (for the native architecture), so you may have to follow the same process for them.

No rule to make target libopencv_calib3d.so.3.2.0 but opencv 3.4.1 installed, when making ROS workspace

I have opencv 3.4.1 installed from source on my ubuntu. But when running command catkin_make -DCMAKE_BUILD_TYPE=Release I get error:
No rule to make target '/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.3.2.0', needed by '~/ros_ws/devel/lib/stereo_slam/image_handle_node'. Stop.
No rule to make target '/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.3.2.0', needed by '~/ros_ws/devel/lib/libmetrics_lib.so'. Stop.
I've already tried following this: openCV program compile error "libopencv_core.so.2.4: cannot open shared object file: No such file or directory" in ubuntu 12.04
[EDIT] I get the same error compiling using clion or catkin_make directly from terminal, but clion creates special packages for release and debug versions. I don't quite understand these packages but in files CMakeCache.txt i found folowing lines:
//Dependencies for the target
metrics_lib_LIB_DEPENDS:STATIC=general;/opt/ros/melodic/lib/libtf.so;general;/opt/ros/melodic/lib/libtf2_ros.so;general;/opt/ros/melodic/lib/libactionlib.so;general;/opt/ros/melodic/lib/libmessage_filters.so;general;/opt/ros/melodic/lib/libtf2.so;general;/opt/ros/melodic/lib/libcv_bridge.so;general;/opt/ros/melodic/lib/libimage_geometry.so;general;/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_features2d.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_flann.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_imgcodecs.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_ml.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_objdetect.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_photo.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_shape.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_stitching.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_superres.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_video.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_videoio.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_videostab.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_viz.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_aruco.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_bgsegm.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_bioinspired.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_ccalib.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_datasets.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_dpm.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_face.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_freetype.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_fuzzy.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_hdf.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_line_descriptor.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_optflow.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_phase_unwrapping.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_plot.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_reg.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_rgbd.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_saliency.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_stereo.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_structured_light.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_surface_matching.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_text.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_ximgproc.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_xobjdetect.so.3.2.0;general;/usr/lib/x86_64-linux-gnu/libopencv_xphoto.so.3.2.0;general;/opt/ros/melodic/lib/libroscpp.so;general;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;general;/usr/lib/x86_64-linux-gnu/libboost_signals.so;general;/opt/ros/melodic/lib/librosconsole.so;general;/opt/ros/melodic/lib/librosconsole_log4cxx.so;general;/opt/ros/melodic/lib/librosconsole_backend_interface.so;general;/usr/lib/x86_64-linux-gnu/liblog4cxx.so;general;/usr/lib/x86_64-linux-gnu/libboost_regex.so;general;/opt/ros/melodic/lib/libxmlrpcpp.so;general;/opt/ros/melodic/lib/libroscpp_serialization.so;general;/opt/ros/melodic/lib/librostime.so;general;/opt/ros/melodic/lib/libcpp_common.so;general;/usr/lib/x86_64-linux-gnu/libboost_system.so;general;/usr/lib/x86_64-linux-gnu/libboost_thread.so;general;/usr/lib/x86_64-linux-gnu/libboost_chrono.so;general;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;general;/usr/lib/x86_64-linux-gnu/libboost_atomic.so;general;/usr/lib/x86_64-linux-gnu/libpthread.so;general;/usr/lib/x86_64-linux-gnu/libconsole_bridge.so.0.4;general;prometheus-cpp::core;general;prometheus-cpp::pull;general;ceres;general;proto;
I don't understand what these metrics_lib_LIB_DEPENDS are, and from where do they come from.
I also used erroneously sudo find / -name "opencv" -exec rm -i {} \; to remove opencv and I had the same problem.
I solved with :
sudo apt remove libopencv-dev
sudo apt remove libopencv-core3.2
However not all the opencv lib will be unistalled with this, so you need to remove all the opencv lib installed with ros (in my case I needed to remove also opencv-data). You can find them with:
sudo apt list --installed | grep opencv
after that you can install again ros melodic (or whatever you are using) :
sudo apt install ros-melodic-desktop-full
Problem was that I uninstalled previous version of opencv via next command:
sudo find / -name "*opencv*" -exec rm -i {} \;
By doing this I also erased the contents of the ROS OpenCV library. Later even after reinstalling ROS, these libraries did not reinstall because the system thinks they are installed but nothing was in them. I had to apt-get each library individually.
Don't purge OpenCV...

Built stuck at 0.0% while bundling index.ios.js

I don't know exactly why but all my react-native projects cannot build anymore today and I'm stuck with a the Bundling of index.ios.js at 0.0%.
I tried a couple of things but all my projects got the same issue.
NOTE: This workaround is for macOS.
Found out that the culprit was watchman 4.7.0.
My issues started after having upgraded to watchman 4.7.0 using brew.
Looks like there's an issue in this new version of watchman:
watchman issues 358.
At the end I solved my issue removing the content of the /usr/local/var/run/watchman/ folder.
I tried several things: the above answer, launchctl unload, restart, reinstall... You name it. Here's how I fixed it on MacOS:
TL;DR: Remove brew version and follow official documentation to compile from source. Use flags on configure: --enable-statedir=$HOME/.watchman --without-python --without-pcre
Reasoning: I don't need python bindings. I also suspect some permission issues and thought using my home would be safer than default path.
steps:
brew rm watchman
(just to be safe) launchctl unload -F ~/Library/LaunchAgents/com.github.facebook.watchman.plist
(just to be safe) restart mac
git clone https://github.com/facebook/watchman.git
cd watchman
git checkout v4.9.0 // Prefer lastest version here.
brew install autoconf automake libtool // Compilation tools
./autogen.sh
./configure --enable-statedir="$HOME/.watchman" --without-python --without-pcre
make // Wait... It'll compile the .o files
make install // If it fails try with sudo but it shouldn't.
After make install it should be in your path here: /usr/local/bin/watchman
Try to watchman version or something. Try to see if it fixed your problem.
Keep in mind most people have their stuff in /usr/local/var/run/watchman/. Our equivalent is now ~/.watchman/
Let me know if this helps you. :)
run the following command
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
This also may happen in case your node dependencies are not installed, e.g. node-modules/ in .gitignore and repo is freshly-pulled.
In this case, your should do npm install of yarn (in case you are using yarn).

How to link ntfs-3g with homebrew?

Forgive me if this is elsewhere, but I can't find it.
I am trying to install NTFS-3G on OS X 10.11 (El Capitan).
I am following the process at this link
But the step to install NTFS-3G reports:
$ brew install homebrew/fuse/ntfs-3g
Warning: homebrew/fuse/ntfs-3g-2015.3.14 already installed, it's just not linked
So...
How do I just link the installed item?
Once that's done, how do I complete the install process? Is there anything that the 'brew install...' process would do after linking?
EDIT:
Following bfontaine... I get:
$ brew link homebrew/fuse/ntfs-3g
Linking /usr/local/Cellar/ntfs-3g/2015.3.14...
Error: Could not symlink share/doc/ntfs-3g/README
Target /usr/local/share/doc/ntfs-3g/README
already exists. You may want to remove it:
rm '/usr/local/share/doc/ntfs-3g/README'
To force the link and overwrite all conflicting files:
brew link --overwrite ntfs-3g
To list all files that would be deleted:
brew link --overwrite --dry-run ntfs-3g
$ brew link --overwrite homebrew/fuse/ntfs-3g
Linking /usr/local/Cellar/ntfs-3g/2015.3.14...
Error: Could not symlink share/doc/ntfs-3g/README
/usr/local/share/doc/ntfs-3g is not writable.
Am I going down a hole? If I brew uninstall, will it clean everything up, or do I have to manually clean it up?
This is getting messy...
EDIT2:
The output of brew link --overwrite --dry-run is:
$ brew link --overwrite --dry-run homebrew/fuse/ntfs-3g
Would remove:
/usr/local/include/ntfs-3g/acls.h
/usr/local/include/ntfs-3g/attrib.h
/usr/local/include/ntfs-3g/attrlist.h
/usr/local/include/ntfs-3g/bitmap.h
/usr/local/include/ntfs-3g/bootsect.h
/usr/local/include/ntfs-3g/cache.h
/usr/local/include/ntfs-3g/collate.h
/usr/local/include/ntfs-3g/compat.h
/usr/local/include/ntfs-3g/compress.h
/usr/local/include/ntfs-3g/debug.h
/usr/local/include/ntfs-3g/device.h
/usr/local/include/ntfs-3g/device_io.h
/usr/local/include/ntfs-3g/dir.h
/usr/local/include/ntfs-3g/ea.h
/usr/local/include/ntfs-3g/efs.h
/usr/local/include/ntfs-3g/endians.h
/usr/local/include/ntfs-3g/index.h
/usr/local/include/ntfs-3g/inode.h
/usr/local/include/ntfs-3g/ioctl.h
/usr/local/include/ntfs-3g/layout.h
/usr/local/include/ntfs-3g/lcnalloc.h
/usr/local/include/ntfs-3g/logfile.h
/usr/local/include/ntfs-3g/logging.h
/usr/local/include/ntfs-3g/mft.h
/usr/local/include/ntfs-3g/misc.h
/usr/local/include/ntfs-3g/mst.h
/usr/local/include/ntfs-3g/ntfstime.h
/usr/local/include/ntfs-3g/object_id.h
/usr/local/include/ntfs-3g/param.h
/usr/local/include/ntfs-3g/realpath.h
/usr/local/include/ntfs-3g/reparse.h
/usr/local/include/ntfs-3g/runlist.h
/usr/local/include/ntfs-3g/security.h
/usr/local/include/ntfs-3g/support.h
/usr/local/include/ntfs-3g/types.h
/usr/local/include/ntfs-3g/unistr.h
/usr/local/include/ntfs-3g/volume.h
/usr/local/include/ntfs-3g/xattrs.h
/usr/local/share/man/man8/mkfs.ntfs.8 -> /usr/local/share/man/man8/mkntfs.8
/usr/local/share/man/man8/mkntfs.8
/usr/local/share/man/man8/mount.lowntfs-3g.8 -> /usr/local/share/man/man8/ntfs-3g.8
/usr/local/share/man/man8/mount.ntfs-3g.8 -> /usr/local/share/man/man8/ntfs-3g.8
/usr/local/share/man/man8/ntfs-3g.8
/usr/local/share/man/man8/ntfs-3g.probe.8
/usr/local/share/man/man8/ntfs-3g.secaudit.8
/usr/local/share/man/man8/ntfs-3g.usermap.8
/usr/local/share/man/man8/ntfscat.8
/usr/local/share/man/man8/ntfsclone.8
/usr/local/share/man/man8/ntfscluster.8
/usr/local/share/man/man8/ntfscmp.8
/usr/local/share/man/man8/ntfscp.8
/usr/local/share/man/man8/ntfsfix.8
/usr/local/share/man/man8/ntfsinfo.8
/usr/local/share/man/man8/ntfslabel.8
/usr/local/share/man/man8/ntfsls.8
/usr/local/share/man/man8/ntfsprogs.8
/usr/local/share/man/man8/ntfsresize.8
/usr/local/share/man/man8/ntfsundelete.8
/usr/local/lib/libntfs-3g.86.dylib
/usr/local/lib/libntfs-3g.a
/usr/local/lib/libntfs-3g.dylib -> /usr/local/lib/libntfs-3g.86.dylib
/usr/local/lib/pkgconfig/libntfs-3g.pc
$
but even after 'brew uninstall...' the directory /usr/local/include/ntfs-3g still exists
Use brew link homebrew/fuse/ntfs-3g.
To go further here are the common commands relevant here:
brew install <formula> # install (and link) the formula
brew unlink <formula> # unlink the formula
brew link <formula> # link the formula
brew uninstall <formula> # uninstall (and unlink) the formula
To understand this you need to know that when Homebrew installs a formula foo version 1.2.3, it installs everything under /usr/local/Cellar/foo/1.2.3/ then symlinks all binaries in /usr/local/bin; all manpages under /usr/local/share/man; etc. This means that /usr/local/bin/something is not a binary but a symlink to the relevant binary (e.g. /usr/local/Cellar/foo/1.2.3/bin/something).
Sometimes binaries conflict with each other. For example both mysql and mariadb provide a mysql binary. Homebrew won’t be able to link both at the same time so it allows you to install one; unlink it; then install the other. That way you can have both on your system without conflict.

Brew linking with ImageMagick

Installing:
ostaptan:~ ostap$ brew install imagemagick --disable-openmp --from-source
==> Downloading http://downloads.sf.net/project/machomebrew/mirror/ImageMagick-6.7.7-6.tar.bz2
Already downloaded: /Library/Caches/Homebrew/imagemagick-6.7.7-6.tar.bz2
==> Patching
patching file configure
Hunk #1 succeeded at 32371 (offset 447 lines).
==> ./configure --disable-osx-universal-binary --without-perl --prefix=/usr/local/Cellar/imagemagick/6.7.7-6 --enable-shared --disable-static
==> make install
Error: The linking step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link imagemagick'
==> Summary
/usr/local/Cellar/imagemagick/6.7.7-6: 1388 files, 32M, built in 61 seconds
linking after bad linking in install:
ostaptan:wand ostap$ brew link imagemagick
Linking /usr/local/Cellar/imagemagick/6.7.7-6...
Error: Could not symlink file: /usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick/wand/wand-view.h
Target /usr/local/include/ImageMagick/wand/wand-view.h already exists. You may need to delete it.
To force the link and delete this file, do:
brew link -f formula_name
To list all files that would be deleted:
brew link -n formula_name
How to link??? what to do?? Can't find answers anywhere!
As suggested in the brew link output, try
brew link -f imagemagick
This should clean up old links in /usr/local/include/ImageMagick/, and then link the files required to complete the installation.
If this doesn't work check that your user has permission to write to /usr/local/include/ImageMagick/*.
After hours and hours of trying the only thing that worked for me was:
sudo brew link --overwrite imagemagick
(Also requires /usr/local/bin/brew to be chowned to root)
Homebrew does not support the overwrite sudo command anymore.
sudo brew link --overwrite imagemagick
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

Resources