How to install check.h library?

Recently I had a need to install this library on my Mac, but I encountered a number of problems.

  1. I didn't have the access rights to install it properly.

  2. I just didn't understand what to do)

Just in case, check.h is a unit testing library in C and here is a guide on how to install it.

First, install brew, below is a bash script for installing brew directly into goinfre

#!/bin/bash

INSTALL_DIR="$HOME/goinfre/.brew"

# Delete and reinstall Homebrew from Github repo
rm -rf "$INSTALL_DIR"
git clone --depth=1 https://github.com/Homebrew/brew "$INSTALL_DIR"

# Create .brewconfig script in the installation directory
cat > "$INSTALL_DIR/.brewconfig.zsh" <<EOL
# HOMEBREW CONFIG

# Add brew to path
export PATH=$INSTALL_DIR/bin:\$PATH

# Set Homebrew temporary folders
export HOMEBREW_CACHE=/tmp/\$USER/Homebrew/Caches
export HOMEBREW_TEMP=/tmp/\$USER/Homebrew/Temp

mkdir -p \$HOMEBREW_CACHE
mkdir -p \$HOMEBREW_TEMP

# If NFS session
# Symlink Locks folder in /tmp
if df -T autofs,nfs \$HOME 1>/dev/null; then
  HOMEBREW_LOCKS_TARGET=/tmp/\$USER/Homebrew/Locks
  HOMEBREW_LOCKS_FOLDER=$INSTALL_DIR/.brew/var/homebrew

  mkdir -p \$HOMEBREW_LOCKS_TARGET
  mkdir -p \$HOMEBREW_LOCKS_FOLDER

  # Symlink to Locks target folders
  # If not already a symlink
  if ! [[ -L \$HOMEBREW_LOCKS_FOLDER && -d \$HOMEBREW_LOCKS_FOLDER ]]; then
     echo "Creating symlink for Locks folder"
     rm -rf \$HOMEBREW_LOCKS_FOLDER
     ln -s \$HOMEBREW_LOCKS_TARGET \$HOMEBREW_LOCKS_FOLDER
  fi
fi
EOL

# Add .brewconfig sourcing in your .zshrc if not already present
if ! grep -q "# Load Homebrew config script" "$HOME/.zshrc"; then
    cat >> "$HOME/.zshrc" <<EOL

# Load Homebrew config script
source "$INSTALL_DIR/.brewconfig.zsh"
EOL
fi

source "$INSTALL_DIR/.brewconfig.zsh"
rehash
brew update

echo -e "\nPlease open a new shell to finish installation"

Then:

  • brew install check

  • brew install gcc

  • brew install pkg-config

  • pkg-config –cflags –libs check – used to get compiler and linker flags for a library check. One path with flag I, the other with flag L.

  • Then go to zshrc – nano ~/.zshrc (in the main folder) and insert two lines after CPATH= what was in that command after I, after LIBRARY_PATH= what was in that command after L and don't forget to write export.(export CPATH=…) before these commands.

  • And reboot this shell source ~./zshrc

And voila, this library works and the compiler sees it, after that I no longer had problems

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *