How to install SDL2 on linux RHEL in other directories? - c++

I can't install SDL2 on my uni lab computers running Red Hat linux OS due to insufficient permissions when I tried to install them the normal way, probably because I cant install to system files. Can someone guide me on how to install the SDL libraries on other directories(desktop etc) where I have permission and then link my files to them (makefiles etc)?
Using g++ compiler.

Look for auto install SDL2 on a CentOS (RHEL) system:
https://gist.github.com/JPEGtheDev/91369e571069f0db38c2
Auto install SDL2 on a CentOS system:
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
cd /tmp
hg clone https://hg.libsdl.org/SDL SDL;
cd SDL;
mkdir build;
cd build;
../configure
make;
make install;
sudo ln -s /usr/local/lib/libSDL2-2.0.so.0 /usr/lib64/libSDL2-2.0.so.0

Related

installation error: 'Unable to locate package g++-4.8'

I am trying to install gcc and g++ version 4.8 to run a specific software in Ubuntu 22.04.1
when I perform
sudo apt-get install g++-4.8
it says
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package g++-4.8
E: Couldn't find any package by glob 'g++-4.8'
E: Couldn't find any package by regex 'g++-4.8'
and When I perform
sudo apt-get install gcc-4.8
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'gcc-4.8-hppa64' for regex 'gcc-4.8'
The following packages were automatically installed and are no longer required:
chromium-codecs-ffmpeg-extra gstreamer1.0-vaapi i965-va-driver intel-media-va-driver libaacs0 libaom3 libass9 libavcodec58 libavformat58 libavutil56 libbdplus0 libbluray2
libbs2b0 libchromaprint1 libcodec2-1.0 libdav1d5 libflashrom1 libflite1 libftdi1-2 libgme0 libgsm1 libgstreamer-plugins-bad1.0-0 libigdgmm12 liblilv-0-0 libmfx1 libmysofa1
libnorm1 libopenmpt0 libpgm-5.3-0 libpostproc55 librabbitmq4 librubberband2 libserd-0-0 libshine3 libsnappy1v5 libsord-0-0 libsratom-0-0 libsrt1.4-gnutls libssh-gcrypt-4
libswresample3 libswscale5 libudfread0 libva-drm2 libva-wayland2 libva-x11-2 libva2 libvdpau1 libvidstab1.1 libx265-199 libxvidcore4 libzimg2 libzmq5 libzvbi-common libzvbi0
mesa-va-drivers mesa-vdpau-drivers pocketsphinx-en-us va-driver-all vdpau-driver-all
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
What could be done?
You could possibly recompile gcc 4.8.5 with the following script. However there is a lot that can go wrong depending on the machine that you are compiling it since the compiler itself depends on a large set of utilities - called the toolchain and they are tightly coupled with the machine's own system libraries, in particular the C standard library.
sudo dpkg --add-architecture i386
sudo apt update
sudo apt upgrade
sudo apt-get install gcc-multilib libstdc++6:i386
wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.bz2 --no-check-certificate
tar xf gcc-4.8.5.tar.bz2
cd gcc-4.8.5
./contrib/download_prerequisites
cd ..
sed -i -e 's/__attribute__/\/\/__attribute__/g' gcc-4.8.5/gcc/cp/cfns.h
sed -i 's/struct ucontext/ucontext_t/g' gcc-4.8.5/libgcc/config/i386/linux-unwind.h
mkdir xgcc-4.8.5
pushd xgcc-4.8.5
$PWD/../gcc-4.8.5/configure --enable-languages=c,c++ --prefix=/usr --enable-shared --enable-plugin --program-suffix=-4.8.5
make MAKEINFO="makeinfo --force" -j
sudo make install -j

How to build and install dpdk v.18.08 on Centos 7.6 with gcc?

I am trying to build and install dpdk v.18.08 on Centos 7.6 with gcc 4.8.5.
This is what I have done:
$ tar xvfz /opt/dpdk/dpdk-18.08/tar.gz
$ cd /opt/dpdk/dpdk-18.08
$ make -j T=x86_64-native-linuxapp-gcc install
<snip>
Build complete [x86_64-native-linuxapp-gcc]
Installation cannot run with T defined and DESTDIR undefined
How can I fix this failure to install?
If you want a specific folder to house current binaries and library, 'make config T=x86_64-native-linuxapp-gcc O=x86_64-native-linuxapp-gcc'.
This will create a folder 'x86_64-native-linuxapp-gcc'. You have set RTE_TARGET as x86_64-native-linuxapp-gcc. Then build by 'cd x86_64-native-linuxapp-gcc; make -j 10'
Edit: O in 'make config' is the target folder.

mingw-64 - Install package

I am using mingw_64 and CLion in Windows 10 to try to use a library (https://github.com/libtrading/libtrading) in a simple project, but the library requires some packages to be installed prior the use of the library. The thing is that the installing instructions are for Linux environment as follows:
# Debian
$ apt-get install pkg-config libxml2-dev libglib2.0-dev libncurses5-dev \
python-yaml libevent-dev
# Fedora
$ yum install zlib-devel libxml2-devel glib2-devel vim-common ncurses-devel \
python-yaml libevent-devel
# OSX
$ brew install libevent glib pkgconfig
$ pip install pyyaml
So, how do I install these pre-requisites in my mingw_64 and CLion in Windows 10 environment?
If you installed MinGW through MSYS2, you can use the MSYS2 pacman package manager to install additional packages:
The MSYS2 software distribution uses a port of pacman from Arch Linux to manage (install, remove and update) binary packages and also to build those packages in the first place.
Finding package
pacman -Ss <name or part of the name of the package>
Installing a package
pacman -S <name of the package>
Example:
$ pacman -Ss libxml2
mingw64/mingw-w64-x86_64-libxml2 2.9.8-1
XML parsing library, version 2 (mingw-w64)
. . .
$ pacman -S mingw64/mingw-w64-x86_64-libxml2
resolving dependencies...
looking for conflicting packages...
Total Download Size: 1.37 MiB
Total Installed Size: 11.06 MiB
:: Proceed with installation? [Y/n]
:: Retrieving packages...
:: Processing package changes...
(1/1) installing mingw-w64-x86_64-libxml2 [##################################] 100%
A shorter version of pacman is pacboy. For example, you can specify the :x suffix to install a mingw64 package:
$ pacboy -S libxml2:x
MinGW does not have any package management, so installing dependencies usually means building them yourself from source. For those self-built packages I have a Unix-like directory structure (with the usual bin, lib, include, etc. directories) apart from the MinGW installation.
Before I expand on that, please check if libTrading supports Windows at all. A quick glance over the libTrading GitHub shows no mention of Windows anywhere. That may mean that the project does not support Windows at all. But then we’re no more talking about configuring a build environment, but adding support for a whole new operating sytem to that project.
Here is the way I used
$ cat /usr/bin/install
# How to use
# install rsync
cd /
echo $1
# echo $2
URL=http://repo.msys2.org/msys/x86_64
FILE=`wget -O - -o /dev/null $URL | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep -E ^$1 | egrep -v '.sig$' | sort | tail -1f`
echo $FILE
# wget -qO- $URL/$FILE | tar -I zstd -xvf - -C /
# wget -qO- $URL/$FILE | tar xJvf - -C /
if [[ $FILE == *.zst ]] # * is used for pattern matching
then
wget -qO- $URL/$FILE | tar -I zstd -xvf - -C /
elif [[ $FILE == *.xz ]]
then
wget -qO- $URL/$FILE | tar xJvf - -C /
else
echo "$FILE is not extracted"
fi
$ install whois
whois
whois-5.5.9-1-x86_64.pkg.tar.zst
.BUILDINFO
.MTREE
.PKGINFO
etc/
etc/whois.conf
usr/
usr/bin/
usr/bin/whois.exe
usr/share/
usr/share/man/
usr/share/man/man1/
usr/share/man/man1/whois.1.gz
usr/share/man/man5/
usr/share/man/man5/whois.conf.5.gz

Where can I find the real arm-none-linux-gnueabi?

Some time before I installed arm-none-linux-gnueabi-gcc compiler collection and compiled embedded applications for IGEP board. I have many Eclipse projects which has double build configurations (one for UBUNTU based desktop, the other for ARM based IGEPv2 board).
Now, I formatted my drive (I use Ubuntu 12.04) , I rescued my projects and what I see? "arm-none-linux-gnueabi-gcc" is not available? I can download it nowhere.. Instead, all the links go to another download by "Mentor Graphics", which is named "arm-none-eabi-gcc". I do not know the difference between. I setup this package and correct all my .../CodeSourcery/... type of paths to /MentorGraphics/..., but when I compile I have the following error:
/home/fercis/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/include/termios.h:4:25:
fatal error: sys/termios.h: No such file or directory
Then I looked at the include file of the arm compiler collection under "/home/fercis/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/arm-none-eabi/include" and what I see was a termios.h under the .../include directory, which only includes .../include/sys/termios.h
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/termios.h>
#ifdef __cplusplus
}
#endif
And, There is no "/sys/termios.h". Something must be terribly wrong! Help please?
You can build your own toolchain for the IGEPv2 following these steps:
Install dependencies:
$ sudo apt-get install diffstat
$ sudo apt-get install texi2html
$ sudo apt-get install texinfo
$ sudo apt-get install gawk
$ sudo apt-get install chrpath
$ sudo apt-get install gnupg
$ sudo apt-get install libcurl3
$ sudo apt-get install libcurl3-gnutls
$ sudo apt-get install python-pycurl
Clone IGEPv2 repo:
$ git clone -b denzil git://git.isee.biz/pub/scm/poky.git
Download isee layer:
$ cd poky
$ git clone -b denzil git://git.isee.biz/pub/scm/meta-isee.git
Setup bitbake environment:
$ source oe-init-build-env
Add isee layer on conf/bblayers.conf file:
BBLAYERS ?= " \
/path/to/poky/meta \
/path/to/poky/meta-yocto \
/path/to/poky/meta-isee \
"
Change MACHINE on conf/local.conf file:
MACHINE ??= "igep00x0"
This command generates toolchain:
$ bitbake meta-toolchain-sdk
This is a good time to take a long coffee...
At the end of process, SDK will be available here:
build/tmp/deploy/sdk/igep-sdk-yocto-toolchain-1.2.1-2.tar.bz2
Install SDK in your host machine:
$ tar xvfz igep-sdk-yocto-toolchain-1.2.1-2.tar.bz2 -C /
Enjoy it! :)

library not found for -lgomp [duplicate]

I'm trying to get openmp to run in my program on Mavericks, however when I try to compile using the flag -fopenmp I get the following error:
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The command I am running is:
gcc myProgram.cpp -fopenmp -o myProgram
Also, when I run gcc I get Clang warnings which I find to be very strange. And looking into /usr/bin/gcc it does not appear to link to Clang.
Any suggestions on how to fix my Clang errors and get openmp to compile?
The gcc command in the latest Xcode suite is no longer the GCC frontend to LLVM (based on the very old GCC 4.2.1) but rather a symlink to clang. Clang does not (yet) support OpenMP. You have to install separately another version of GCC, e.g. by following this tutorial or by using any of the available software package management systems like MacPorts and Homebrew.
I just recently attacked this problem and have scripted the process of getting everything working based on the official instructions.
The script will download everything into ~/code for easy maintenance and will append the correct environment variables to your ~/.profile file. For advanced users, pick a nice location you want the lib, bin and include installed and move them manually. The script depends on knowing the latest OpenMP runtime from Intel, which can be altered at the top of the script.
The script should work out of the box with vanilla Mavericks, except for one small problem. In the OpenML runtime make script, it does not reliably accept clang when specified and continues with the default GCC. As such, if you don't have GCC installed (which is not normal on out of the box Mavericks), it will fail to build. To fix this, you must comment out two lines (as noted in the script) based on the libomp_20131209_oss.tgz build of OpenMP. Newer builds of OpenML might break this script, so use at your own peril on newer versions.
Simply save this script into a file, run 'chmod +x filename.sh', and run './filename.sh' from terminal. It will take a while to build LLVM and Clang, so be patient.
EDIT: This script will most likely fail on Yosemite and I am having issues using the built clang2 after the update to the dev builds of OSX 10.10.
INTEL_OPENMP_LATEST_BUILD_LINK=https://www.openmprtl.org/sites/default/files/libomp_20131209_oss.tgz
DEST_FOLDER = ~/code
CLANG_INCLUDE=${DEST_FOLDER}/llvm/include
CLANG_BIN=${DEST_FOLDER}/llvm/build/Debug+Asserts/bin
CLANG_LIB=${DEST_FOLDER}/llvm/build/Debug+Asserts/lib
OPENMP_INCLUDE=${DEST_FOLDER}/libomp_oss/exports/common/include
OPENMP_LIB=${DEST_FOLDER}/libomp_oss/exports/mac_32e/lib.thin
mkdir ${DEST_FOLDER}
cd ${DEST_FOLDER}
git clone https://github.com/clang-omp/llvm
git clone https://github.com/clang-omp/compiler-rt llvm/projects/compiler-rt
git clone -b clang-omp https://github.com/clang-omp/clang llvm/tools/clang
cd llvm
mkdir build
cd build
../configure
make
cd Debug+Asserts/bin
mv clang clang2
rm -rf clang++
ln -s clang2 clang2++
echo "LLVM+Clang+OpenMP Include Path : " ${CLANG_INCLUDE}
echo "LLVM+Clang+OpenMP Bin Path : " ${CLANG_BIN}
echo "LLVM+Clang+OpenMP Lib Path : " ${CLANG_LIB}
cd ${DEST_FOLDER}
curl ${INTEL_OPENMP_LATEST_BUILD_LINK} -o libomp_oss_temp.tgz
gunzip -c libomp_oss_temp.tgz | tar xopf -
rm -rf libomp_oss_temp.tgz
cd libomp_oss
echo "You need to do one or two things:"
echo "1.) [Required] Comment out line 433 from libomp_oss/src/makefile.mk"
echo "2.) [Optional] If you do not have GCC installed (not normal on vanilla Mavericks), you must comment out lines 450-451 in libomp_oss/tools/check-tools.pl. Have you done this or want to compile anyway?"
select yn in "Yes" "No"; do
case $yn in
Yes ) make compiler=clang; break;;
No ) exit;;
esac
done
echo "OpenMP Runtime Include Path : " ${OPENMP_INCLUDE}
echo "OpenMP Runtime Lib Path : " ${OPENMP_LIB}
(echo 'export PATH='${CLANG_BIN}':$PATH';
echo 'export C_INCLUDE_PATH='${CLANG_INCLUDE}':'${OPENMP_INCLUDE}':$C_INCLUDE_PATH';
echo 'export CPLUS_INCLUDE_PATH='${CLANG_INCLUDE}':'${OPENMP_INCLUDE}':$CPLUS_INCLUDE_PATH';
echo 'export LIBRARY_PATH='${CLANG_LIB}':'${OPENMP_LIB}':$LIBRARY_PATH';
echo 'export DYLD_LIBRARY_PATH='${CLANG_LIB}':'${OPENMP_LIB}':$DYLD_LIBRARY_PATH}') >> ~/.profile
source ~/.profile
echo "LLVM+Clang+OpenMP is now accessible through [ clang2 ] via terminal and does not conflict with Apple's clang"
If you are running homebrew you can fix this problem by calling:
brew install clang-omp
The compiler will be available under clang-omp++ name
Just worked through this problem. Here's the answer plus how to get it worked with Xcode.
Grab the latest version of openMP runtime library from
https://www.openmprtl.org/download
unzip and compile it by
mkdir build && cd build && cmake .. && make && sudo make install
install it by
sudo cp ./libiomp5.dylib /usr/lib/
sudo cp ./omp.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/
Grab openmp/clang from Git following the instructions on http://clang-omp.github.io/
compile openmp/clang
cd llvm && mkdir build && cd build && ../configure --enable-optimized && make -j
sudo make install
normally it would install clang/clang++ into /usr/local/bin, we need replace the Apple clang with our version
cd /usr/bin
sudo mv clang clang-apple
sudo mv clang++ clang++-apple
sudo ln -s /usr/local/bin/clang ./clang
sudo ln -s /usr/local/bin/clang++ ./clang++
cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
sudo mv clang clang-apple
sudo mv clang++ clang++-apple
sudo ln -s /usr/local/bin/clang ./clang
sudo ln -s /usr/local/bin/clang++ ./clang++
cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
sudo mv -f * ../../
Create a project in Xcode, using the Hello World code on clang-openmp website for test. After created, add "-fopenmp" to Custom Compiler Flags -> Other C Flags in project settings; add /usr/lib/libiomp5.dylib to the build phases of project (project settings -> Build Phases -> Drag /usr/lib/libiomp5.dylib into Link Binary with Libraries)
It should work. Yosemite + Xcode 6 is tested.
Note: the custom clang is NOT as stable as Apple's. Switch back if you meet strange instruction error after compiled.