Comment 16 for bug 1299217

Revision history for this message
Nils Peter Hesse (nphesse) wrote :

Hi,

quick fix for being able to launch pcbnew properly using the KiCAD GUI (this is for Ubuntu using sudo. If you're not on Ubuntu you may have to adapt the paths and/or the usage of the sudo command):

$ PCBNEW="$(which pcbnew)"
$ sudo mv ${PCBNEW} ${PCBNEW}.bin
$ sudo gedit $PCBNEW
Replace "gedit" with your preferred text editor.
Paste the following snippet into the editor and save (please make sure the first line in the file reads "#!/bin/bash"!):

#!/bin/bash

if [ "$(uname -p)" == "x86_64" ]; then
    LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpython2.7.so.1 pcbnew.bin
else
    LD_PRELOAD=/usr/lib/libpython2.7.so.1 pcbnew
fi

# END OF SNIPPET

$ sudo chmod +x $PCBNEW

What does this do?
First, you get the full path to the current "pcbnew" executable (which pcbnew) and save it into a variable called "PCBNEW".
Then the executable is renamed to pcbnew.bin within the same directory ("mv $PCBNEW ${PCBNEW}.bin").
After that you create a new file with the same path & name as the original pcbnew executable and write a small bash script to it which does nothing else than to execute the pcbnew.bin file (which, if you remember, is the renamed original executable) using the LD_PRELOAD environment variable to make sure the shared library gets loaded.
The last command sets the executable flag on the newly created script which enables one to execute the script as if it were a binary executable program.

After that you've renamed the original pcbnew executable and replaced it with a small script which spawns the original executable with LD_PRELOAD.

Please remember upon the next update that you may have to re-do these steps - or remove the old pcbnew.bin if the issue was fixed.