Skip to content

Instantly share code, notes, and snippets.

@paullaffitte
Last active June 4, 2023 08:46
Show Gist options
  • Save paullaffitte/c3f028dc64a55e920fa8afabff70673e to your computer and use it in GitHub Desktop.
Save paullaffitte/c3f028dc64a55e920fa8afabff70673e to your computer and use it in GitHub Desktop.
CSFML installer for Ubuntu
#!/usr/bin/env bash
set -e
SFML_VERSION='2.2'
GLEW_VERSION='1.10.0'
get_file()
{
local file_to_get="$1"
local mirror="$2"
local filename=$(echo $file_to_get | sed -e 's/.*\///')
if ! [[ -f $filename ]]; then
if [[ -z $mirror ]]; then
wget "$file_to_get"
else
wget "$file_to_get" || wget "$mirror"
fi
else
echo "-------- $filename already exists locally, skipping..."
fi
extract_archive $filename
}
extract_archive()
{
local file_to_extract="$1"
echo "extracting $file_to_extract..."
tar -xf $file_to_extract
}
cd /tmp
get_file "https://"{www,mirror2}".sfml-dev.org/files/CSFML-$SFML_VERSION-linux-gcc-64-bit.tar.bz2"
get_file "https://"{www,mirror2}".sfml-dev.org/files/SFML-$SFML_VERSION-linux-gcc-64-bit.tar.gz"
get_file "https://sourceforge.net/projects/glew/files/glew/$GLEW_VERSION/glew-$GLEW_VERSION.tgz"
sudo apt install libx11-dev libxmu-dev libxi-dev libgl-dev libopenal-dev
cd /tmp/"glew-$GLEW_VERSION"
make
sudo rm -rfv /usr/local/include/{SFML,GL} /usr/local/lib/lib{*sfml*,GLEW*}
sudo cp -vr /tmp/{"CSFML-$SFML_VERSION","SFML-$SFML_VERSION","glew-$GLEW_VERSION"}/{include,lib} /usr/local
sudo rm -v /usr/local/lib/libcsfml*".$SFML_VERSION" # Avoid ldconfig warning on identical files with different filenames (/sbin/ldconfig.real: /usr/local/lib/libcsfml-xxx.so.2.2 is not a symbolic link)
sudo ldconfig
echo -e "\n\n"
echo "CSFML $SFML_VERSION has been installed"
echo "Please remember to add -lcsfml-graphics -lcsfml-audio -lcsfml-window -lcsfml-system -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system in your Makefile"
echo
echo "2017 - Paul Laffitte - Epitech Montpellier Promo 2021"
@kayofeld
Copy link

fish configuration file is not located in the home folder.
path is:
/home/$USER/.config/fish/config.fish

@paullaffitte
Copy link
Author

paullaffitte commented Nov 10, 2018

I'm not proud of the way the different shells are supported. But thanks for the advice, I didn't know it when I wrote this script, and now I don't use fish, so without this notice I could never now.

Moreover, this script install an old version of CSFML (2.2), to compile the latest version easily, please consider using this one : Compile SFML 2.4.2. Currently the latest version is 2.5.1, so you just have to change the variable "version". (edit: sorry, the linked script is for C++ only)

EDIT: It should be fixed now, I didn't checked but the path that I output is the one you said for fish.

@yoansj
Copy link

yoansj commented Jan 17, 2020

Dude, if the CPATH variable is empty you add the f*cking cwd to it and your preprocessor is going to search in it for your system includes .....

@paullaffitte
Copy link
Author

paullaffitte commented Jan 22, 2020

Thanks for the f*cking advice dude, you should write a f*cking tutorial about it.

@AmosNimos
Copy link

That's a great f*cking reply dude. it made me laugh. XD

@paullaffitte
Copy link
Author

Haha, I'm glad that you liked it. A bit of humour is always a good thing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment