All posts by stepan

Compiling OpenCV on mac OS 10.13.6 with CUDA

Just a little hint for myself:

cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PWD/install \
-DWITH_CUDA=ON -DWITH_OPENMP=ON \
-DOPENCV_EXTRA_MODULES_PATH=<path to opencv contrib repo>/modules \
-DOPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE=ON \
-DWITH_PROTOBUF=ON \
-DOPENCV_EXTRA_SHARED_LINKER_FLAGS="-lomp" \
<path to opencv source>

Important things here:

  • OPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE – is required, due to some weird staff in cmake (cmake internal FindCUDA.cmake seems to be wrong), this comment on opencv github by alalek was extemely usefull and provided us with right hint.
  • WITH_PROTOBUF is also required, otherwise it fails with crazy libprotobuf linker errors.
  • OPENCV_EXTRA_SHARED_LINKER_FLAGS=”-lomp” If you’re using clang 10 or older, you’ll need to to add “-lomp” to linker flags manually, because it ignores “-fopenmp” flag which cmake passes to clang driver in this case. Look’s like it falls just here:

  • Rest of flags looks pretty obvious
Please follow and like us:

Simple script to create Mac OS installation .iso media

Preamble

It is supposed, that you downloaded it with App Store, and it is stored as .app in your /Applications directory.

Below is script. The only parameter you have to customize is a “DIST” variable, which should be your distributive name (“Mojave”, “Catalina” and so on).

This article is based on instructions from techsviewer.com

As a result you should get .iso file on your desktop with name of your distributive (e.g. “Catalina.iso”).

Script

create-macos-iso.sh

DIST=Mojave
DMG_FILE=/tmp/$DIST
DMG_FILE_EXT=/tmp/$DIST.dmg
VOL_NAME=/Volumes/$DIST
INSTALL_APP="Install macOS $DIST.app"
MEDIA_VOL="Install macOS $DIST"
CDR_FILE="$HOME/Desktop/$DIST.cdr"
ISO_FILE="$HOME/Desktop/$DIST.iso"

echo Create dmg... &&
hdiutil create -o $DMG_FILE -size 8500m -volname $VOL_NAME \
       -layout SPUD -fs HFS+J &&

echo Attach dmg... &&
hdiutil attach $DMG_FILE_EXT -noverify -mountpoint $VOL_NAME &&

echo Create install media... &&
sudo /Applications/"$INSTALL_APP"/Contents/Resources/createinstallmedia \
    --volume $VOL_NAME --nointeraction &&

echo Detach $MEDIA_VOL... &&
hdiutil detach /Volumes/"$MEDIA_VOL" &&

echo Convert $DMG_FILE_EXT -\> $CDR_FILE &&
hdiutil convert $DMG_FILE_EXT -format UDTO -o $CDR_FILE &&

echo Rename $CDR_FILE -\> $ISO_FILE &&
mv $CDR_FILE $ISO_FILE &&

echo Cleanup... &&
rm $DMG_FILE_EXT
Please follow and like us:

Anti make install

What to do if you accidentally installed some experimental project to your system folder? Are here any ways to undo install script. Here is a simple solution.

Preamble

below may work or may not, this is all given as-is, you and only you are responsible person in case of some damage, data loss and so on. But I hope things go smooth!

To undo `make install` I would do (and I did) this:

Idea: check whatever script installs and undo this with simple bash script.

1. Reconfigure your build dir to install to some custom dir. I usually do this: `–prefix=$PWD/install`. For CMake, you can go to your build dir, open CMakeCache.txt, and fix CMAKE_INSTALL_PREFIX value.
2. Install project to custom directory (just run `make install` again).
3. Now we push from assumption, that `make install` script installs into custom dir just same contents you want to remove from somewhere else (usually `/usr/local`). So, we need a script.
3.1. Script should compare custom dir, with dir you want clean. I use this:

anti-install.sh

RM_DIR=$1
PRESENT_DIR=$2

echo "Remove files from $RM_DIR, which are present in $PRESENT_DIR"

pushd $RM_DIR

for fn in `find . -iname '*'`; do
# echo "Checking $PRESENT_DIR/$fn..."
if test -f "$PRESENT_DIR/$fn"; then
# First try this, and check whether things go plain
echo "rm $RM_DIR/$fn"

# Then uncomment this, (but, check twice it works good to you).
# rm $RM_DIR/$fn
fi
done

popd

3.2. Now just run this script (it will go dry-run)

bash anti-install.sh <dir you want to clean> <custom installation dir>

E.g. You wan’t to clean /usr/local, and your custom installation dir is /user/me/llvm.build/install, then it would be

bash anti-install.sh /usr/local /user/me/llvm.build/install

3.3. Check log carefully, if commands are good to you, uncomment `rm $RM_DIR/$fn` and run it again. But stop! Did you really check carefully? May be check again?

Good luck!

Please follow and like us: