Fix for qcad linux script so that qcad command can be symlinked

Post your question about installing or upgrading QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Post one question per topic.

Post Reply
reikred
Registered Member
Posts: 1
Joined: Tue Dec 28, 2021 5:00 am

Fix for qcad linux script so that qcad command can be symlinked

Post by reikred » Tue Dec 28, 2021 5:09 am

Below is a quick fix to the qcad script (linux, maybe mac also), so that it will work if the qcad command is symlinked to (say) /usr/local/bin or some such location. The short story is to fix as follows:

#OLD
#DIR=${BASH_SOURCE%/*}
#echo DIR=$DIR

#NEW:
FILE=$(readlink -f ${BASH_SOURCE})
DIR=${FILE%/*}
#DEBUG: echo FILE=$FILE DIR=$DIR

Version: qcad-3.27.1
OS: linux ubuntu-21.04, but should apply to any linux

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

The long story:

Installed from .tar file:

cd /usr/local
tar -ztvf /local/loc1/rpm/qcad-3.27.1-trial-linux-x86_64.tar.gz
tar -zxvf /local/loc1/rpm/qcad-3.27.1-trial-linux-x86_64.tar.gz
/usr/local/qcad-3.27.1-trial-linux-x86_64/qcad WORKS

# Try to link qcad into /usr/local/bin
# the below symlinks do not work
% ln -s /usr/local/qcad-3.27.1-trial-linux-x86_64/qcad /usr/local/bin
% qcad
/usr/local/bin/qcad: line 11: /usr/local/bin/qcad-bin: No such file or directory
# does not help:
ln -s /usr/local/qcad-3.27.1-trial-linux-x86_64/qcad-bin /usr/local/bin
Fatal: This application failed to start because it could not find or load the Qt platform plugin "xcb"
Also tried using hardlink, that does not work either. Try to fix in the qcad script:

#OLD
#DIR=${BASH_SOURCE%/*}
#echo DIR=$DIR

#NEW:
FILE=$(readlink -f ${BASH_SOURCE})
DIR=${FILE%/*}
#DEBUG: echo FILE=$FILE DIR=$DIR

With these changes, the symlink
ln -s /usr/local/qcad-3.27.1-trial-linux-x86_64/qcad /usr/local/bin
will run properly.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

User avatar
lphilpot
Senior Member
Posts: 119
Joined: Mon Oct 30, 2017 4:03 am
Location: Deep South USA

Re: Fix for qcad linux script so that qcad command can be symlinked

Post by lphilpot » Tue Dec 28, 2021 4:07 pm

What I've done on Xubuntu 18.04 is to install from a Deb package, which installs to /opt/qcad<version>. I symlinked /opt/<qcad>version to just /opt/qcad, which is where my desktop files point. So when I upgrade, I just remove the existing symlink and re-link the new directory. Having version-specific install directories allows simultaneous installation of multiple versions, but it does add a little complexity to in-place upgrades.

I never start QCAD from a command line, but I appended /opt/qcad to my path for the command line utilities that ship with QCAD, should I ever need them. For me, the ./qcad symlink is a reasonable compromise but your needs may be different.
Len
QCAD Pro

Post Reply

Return to “QCAD Installation and Upgrades”