clang --version permission denied error - c++

I have installed the latest clang-6.0 using the instructions from here:
install latest clang (6.0) on Ubuntu 16.04 (xenial) / WSL. Basically, these are the steps:
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
sudo apt-get update
sudo apt-get install -y clang-6.0
It was successful but while checking for the version I'm getting the following error
❯ clang --version
⏎
zsh: permission denied: clang
What's the issue here and how to resolve this?

The way you are installing, the clang binary is being installed at /usr/bin/clang-6.0. However, you are trying to run clang --version. This is likely to avoid clobbering in case you have multiple versions of clang installed.
You have 2 options:
Install clang without the version, apt-get install clang, which should still install clang 6 since it is in your package list.
Use the binary by the correct name, clang-6.0 --version
I tested this out using the following Dockerfile:
FROM ubuntu:16.04
# Install software we need to test
RUN apt-get update && apt-get install -y \
software-properties-common \
wget \
zsh
# Get clang-6.0 package
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
# Install clang-6.0 package
RUN apt-get update && apt-get install -y \
clang-6.0
# Default to shell
ENTRYPOINT ["zsh"]
I get the output:
# which clang
clang not found
# which clang-6.0
/usr/bin/clang-6.0

Related

LLVM 15 packages not available after setting up LLVM repositories

I'm running the following script to install clang-format on a GitHub Action and running apt search clang-format afterwards doesn't show clang-format-15 as an option to install.
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" | sudo tee /etc/apt/sources.list.d/llvm.list
echo "deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" | sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt update
This is line-for-line what the LLVM website says I should do for my OS (Ubuntu 20.04). What am I doing wrong?
Just use add-apt-repository, unless you really wanna isolate llvm's PPA from the rest (/etc/apt/sources.list).
sudo add-apt-repository -y "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"

(/usr/bin/ld: cannot find -lGL) Trying to build a GLFW application in docker

thank you for taking the time to read this question and hopefully helping.
So I am trying to use docker to build a GLFW application and I can't get ld to link in my OpenGL so file. I've installed many different packages that should include libGL.so, and it is present at /usr/lib/x86_64-linux-gnu/. It's a symlink to libGL.1.so, which is a symlink to libGL.1.7.0 which appears to be an actual shared object.
g++ --static -o bin/x86-64/linux/main build/x86-64/linux/main.o --libs=glfw3 -lm -lGLU -L/usr/lib/x86_64-linux-gnu/ -lGL
That's the command in my makefile that causes ld to return code 1. I've made sure to use capital GL in the command, I've made sure that ld is looking in the right directory, and i can verify that libGL.so is present.
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
make: *** [makefile:24; build_x86-64_linux] Error 1
I'm racking my brain trying to follow every single stackoverflow, askubuntu and nvidia forum entry where someone has the same error but all of their problems seem to be solved by fixing broken symlinks or installing a missing dependency.
FROM ubuntu:latest
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y build-essential
RUN apt-get install -y libgl1-mesa-dev
RUN apt-get install -y libglu1-mesa
RUN apt-get install -y libglu1-mesa-dev
RUN apt-get install -y libglm-dev
RUN apt-get install -y mingw-w64
RUN apt-get install -y libglfw3
RUN apt-get install -y vulkan-tools
RUN apt-get install -y libvulkan-dev
RUN apt-get install -y vulkan-validationlayers-dev
RUN apt-get install -y spirv-tools
RUN apt-get install -y mesa-common-dev
RUN apt-get install -y mesa-utils
RUN apt-get install -y freeglut3-dev
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y tzdata
RUN apt-get install -y libglfw3-dev
ARG CPLUS_INCLUDE_PATH=/usr/lib/x86_64-linux-gnu/
VOLUME /root/env
WORKDIR /root/env
That is my Dockerfile, and as you can see there I have all the necessary dependencies.
The result of ls -ls at /usr/lib/x86_54-linux-gnu/
You can see there that my shared object file is present and as and where I described it and told the linker to look.
If there is anything else I should include please tell me what I should add and ill update the post with the relevant information.

How to install openCV 2.4.13 for Python 2.7 on Ubuntu 16.04?

I have tried a lot of online posts to install opencv but they are not working for Ubuntu 16.04. May anyone please give me the steps to install openCV 2.4.13 on it?
There's a script I had made a while back, for installing the latest version of OpenCV (4.2 as of the last update to this answer)
Here's the link to it
https://github.com/rsnk96/Ubuntu-Setup-Scripts/blob/master/Build-OpenCV.sh
NOTE: For Ubuntu 16.10+, there are some minor dependency changes you will have to make. Have a look at the comments for the same.
Since you do not want to install opencv contrib, and you specifically want opencv 2.4.13, I have modified the script below. I would suggest you go through the script and understand what is happening before you execute it
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install build-essential -y
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y
sudo apt-get install python3-numpy python3-pip python3-scipy python3-matplotlib python-dev python-matplotlib python-numpy python-scipy -y
sudo apt-get install python-pip python-tk libqt4-dev libqt4-opengl-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant -y
echo "GUI and openGL extensions"
sudo apt-get install qt4-default libqt4-opengl-dev libvtk5-qt4-dev libgtk2.0-dev libgtkglext1 libgtkglext1-dev -y
echo "image manipulation libraries"
sudo apt-get install libpng3 pngtools libpng12-dev libpng12-0 libpng++-dev -y
sudo apt-get install libjpeg-dev libjpeg9 libjpeg9-dbg libjpeg-progs libtiff5-dev libtiff5 libtiffxx5 libtiff-tools libjasper-dev libjasper1 libjasper-runtime zlib1g zlib1g-dbg zlib1g-dev -y
echo "video manipulation libraries"
sudo apt-get install libavformat-dev libavutil-ffmpeg54 libavutil-dev libxine2-dev libxine2 libswscale-dev libswscale-ffmpeg3 libdc1394-22 libdc1394-22-dev libdc1394-utils -y
echo "codecs"
sudo apt-get install libavcodec-dev -y
sudo apt-get install libfaac-dev libmp3lame-dev -y
sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev -y
sudo apt-get install libtheora-dev libvorbis-dev libxvidcore-dev -y
sudo apt-get install ffmpeg x264 libx264-dev -y
sudo apt-get install libv4l-0 libv4l v4l-utils -y
echo "multiproccessing library"
sudo apt-get install libtbb-dev -y
echo "finally download and install opencv"
mkdir opencv
cd opencv
wget "https://github.com/opencv/opencv/archive/2.4.13.2.zip"
unzip opencv-2.4.13.2.zip
cd opencv-2.4.13.2
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DBUILD_EXAMPLES=ON \
-DBUILD_opencv_cvv=OFF \
-DBUILD_NEW_PYTHON_SUPPORT=ON \
-DWITH_TBB=ON \
-DWITH_V4L=ON \
-DWITH_QT=ON \
-DWITH_OPENGL=ON \
-DWITH_VTK=ON ..
echo "making and installing"
make -j8
sudo make install
echo "finishing off installation"
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "Congratulations! You have just installed OpenCV. And that's all, folks! :P"
P.S. Create a script file out of this and then just execute the script file, rather than copy-pasting it line by line into the terminal. You can do that by copying all of it, placing it in a file with the extension .sh, and then simply running that .sh file from the terminal using $ ./filename.sh
According to this source, from Ubuntu 16.04, you can now just do this to install OpenCV for Python2.7:
pip install opencv-python
or for python3:
pip3 install opencv-python
For more information, see here.
I tested this on my machine and it works, great stuff this :).
This is much easier than all other methods I have come across thus far.
sudo apt-get install build-essential cmake git pkg-config
sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python2.7-dev
sudo pip install numpy
sudo apt-get install python-opencv
Then you can have a try:
$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>> import cv2
If you have more than one opencv installation on your machine, now I tell you the most direct, effective and easy way to choose opencv version in python.
You can type the following command to check the current opencv version in python
import cv2
cv2.__version__
opencv path in python is set in system variable PYTHONPATH, you can echo this variable with echo $PYTHONPATH
If I want to use opencv3.x in python, then using vi or gedit open .bashrc in the home folder, add this content to the end
export PYTHONPATH=/home/ismart/ipa2/devel/lib/python2.7/dist-packages:/home/ismart/catkin_ws/install_isolated/lib/python2.7/dist-packages:/usr/local/opencv3.x/lib/python2.7/dist-packages
Replace the path with yours

Sentry compile fails with " error: command 'gcc' failed with exit status 1"

Been trying to install Sentry on CentOS 6.5. I have installed the prerequisites i.e Python 2.7.9
[root#localhost poduori]# python -V
Python 2.7.9
I used pyenv to change from the pre-installed python version 2.6.6 (pyenv install 2.7.9). When I try to install sentry I get the below output and error;
NB: I had already run it once hence it using cached.
pip2.7 install sentry
The full error output can be found here https://www.dropbox.com/s/64w6b7dswgzs9cb/Sentry_error.txt?dl=0
or
Sentry error txt file
A summary of the error I'm getting is below
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/root/.pyenv/versions/2.7.9/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-PSGsNT/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-UYMAyw-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-PSGsNT/cffi
The output was too long to post here so I used dropbox instead.
libffi is already installed.
root#localhost user]# rpm -qa|grep libffi
libffi-3.0.5-3.2.el6.x86_64
I already installed all the development tools,
yum groupinstall "Development tools" (including gcc compiler) but I still get the same error. Kindly assist.
ERROR: /bin/sh: xslt-config: command not found
** make sure the development packages of libxml2 and libxslt are installed **
c/_cffi_backend.c:13:17: error: ffi.h: No such file or directory
You need to install dev packages first one (it let you out of this w/ pre-built libs) is libxslt-dev, second one is python-dev. Exact names depends on your distro.
Using ubuntu i solved this by:
Installing setuptools with :
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
created a file requisits.sh
inserted the content:
#! /bin/bash
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install python-dev
sudo apt-get install setuptools
sudo apt-get install python-pip
sudo apt-get install libxslt1-dev
sudo apt-get install libxslt-dev
sudo apt-get install libxml2-dev
sudo apt-get install libz-dev
sudo apt-get install libffi-dev
sudo apt-get install libssl-dev
put execution chmod +x requisits.sh
executed:
./requisits.sh
entered the password and answered y/n when prompted.
and finally :
if using virtualenv:
pip install -U sentry
else
sudo pip install -U sentry

Uninstall boost and install another version

I've installed the boost libraries on Linux Mint 12 using the command sudo apt-get install libboost-dev libboost-doc, which installs the default version available in the repositories. However, the project I have to do needs the 1.44 version of boost. How do I uninstall the default (current) version 1.46 and install 1.44?
I couldn't find the documentation on the boost website to install boost from the .tar.gz package.
Boost can installed by two ways
Deb package
wget and install manually
In some case we might have installed by both type which can cause version error. Lets see how to uninstall both.
sudo apt-get update
# to uninstall deb version
sudo apt-get -y --purge remove libboost-all-dev libboost-doc libboost-dev
# to uninstall the version which we installed from source
sudo rm -f /usr/lib/libboost_*
Then we need to install other dependencies if they are not met
sudo apt-get -y install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev
Lets download the boost version which we need from the link. I am downloading the 1.54 version. Then untar and install it.
# go to home folder
cd
wget http://downloads.sourceforge.net/project/boost/boost/1.54.0/boost_1_54_0.tar.gz
tar -zxvf boost_1_54_0.tar.gz
cd boost_1_54_0
# get the no of cpucores to make faster
cpuCores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
echo "Available CPU cores: "$cpuCores
./bootstrap.sh # this will generate ./b2
sudo ./b2 --with=all -j $cpuCores install
Now let's check the installed version
cat /usr/local/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
You will see something like below
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_54"
Version 1.54 of boost is installed
That's it, it worked for me. Let me know if you face any issues.
You can uninstall with
apt-get --purge remove libboost-dev libboost-doc
Download the package you need from boost website, extract and follow "getting started" instructions found inside index.html in the extracted directory.
Tested working Ubuntu 20.04 Use my script to uninstall your older version of boost in ubuntu 20.04 and follow rams instructions above
#!/bin/bash
sudo apt-get -y --purge remove libboost-all-dev libboost-doc libboost-dev
echo "clear boost dir"
sudo rm -r /usr/local/lib/libboost*
sudo rm -r /usr/local/include/boost
sudo rm -r /usr/local/lib/cmake/*
sudo rm -f /usr/lib/libboost_*
sudo rm -r /usr/include/boost
Downgrade your boost version. I'm not familiar with Mint, but assuming it is deb-based, you can do:
apt-cache show libboost-dev
to see all installable version and install a specific version with
sudo apt-get install libboost-dev=1.42.0.1
There are also convenience packages for the major boost versions:
sudo apt-get install libboost1.44-dev
As #savamane wrote you can uninstall it with
apt-get --purge remove libboost-dev libboost-doc
Another suggestion to install the .deb packages as suggested here. (Download the one fitted for your architecture though).
For still supported distros, you can simply search for the package at the distributions at http://packages.ubuntu.com/. For example libboost-system1.46.1 can be found in under the precise -> Libraries tab.
For unsupported distros, there is still a chance to find them at
http://archive.ubuntu.com/. For example can libboost-all-dev_1.40.0.1_amd64.deb be found in
http://archive.ubuntu.com/ubuntu/pool/universe/b/boost-defaults/.
This is how you install a specific Boost version:
cd boost_1_54_0/
./bootstrap.sh --with-libraries=atomic,date_time,exception,filesystem,iostreams,locale,program_options,regex,signals,system,test,thread,timer,log
sudo ./b2 install