Installing SDL2 on Linux - linux

I try to run simple test.cpp from Twinklebar SDL tutorial, I get this error:
test.cpp:2:10: fatal error: 'SDL2/SDL.h' file not found
So I look up the sdl development package in Ubuntu/Mint:
aptitude search sdl | grep 2
All I can find is this:
libsdl1.2-dev
Does this mean my only option is to install from sources?

It depends which Ubuntu version you are running but yes, there is a libsdl2 package for Ubuntu: http://packages.ubuntu.com/search?keywords=sdl2
The package you want is called libsdl2-dev.
Also, about the #include <SDL/SDL.h> line, it seems the recommended way doing it is by adjusting your compiler flags to add SDL's include pah and use #include "SDL.h". See https://forums.libsdl.org/viewtopic.php?t=5997 for more details on that.

Related

Rust import PAM C functions

I'm trying to figure out how to write a Linux PAM in Rust and I've started with this repo. When I compile it with --features libpam (which enables #[link(name="pam")] that imports external C functions), the compiler complains:
error: linking with `cc` failed: exit status: 1
...
note: /usr/bin/ld: cannot find -lpam: No such file or directory
Looking around SO, I've realized that the pam library was not found to be linked. However, I just cannot figure out how to either install it (I can find many libpam-something packages, but no libpam) or locate it such that I can indicate to the compiler/linker where to find it.
When I look into other crates that also work with PAM, they all import the C functions using #[link(name="pam")], and none specifies how to make it work.
I'm using Ubuntu 22.04.
The necessary headers for PAM library can be installed on Ubuntu as part of libpam0g-dev package (link for jammy):
sudo apt install libpam0g-dev
Debian package has the same name (so sudo apt-get install libpam0g-dev), CentOS uses pam-devel package for that (sudo yum install pam-devel).
Alternatively, on any platform you can use the source code from github and follow the installation instructions from README.

Header files are not found by GCC

Working with embedded C-projects. There are libraries, include files and so on - for micro controllers. No need for me to use GCC for a host machine and OS (Linux Mint 64 bit). As a rule...
But now I'm trying to compile mspdebug project from a Github - with a GCC of course. And I get an error at the very begin of make:
mspdebug$ make
cc -DUSE_READLINE -O1 -Wall -Wno-char-subscripts -ggdb -I. -Isimio -Iformats -Itransport -Idrivers -Iutil -Iui -DLIB_DIR=\"/usr/local/lib/\" -o util/btree.o -c util/btree.c
util/btree.c:19:20: fatal error: assert.h: No such file or directory
#include <assert.h>
^
compilation terminated.
I search for the includes in all possible paths (I've got the list of them via gcc -v command) - there are no assert.h file, as well, as stdio.h and so on. Except virtual box directories there is only one place (where GCC does not search includes): /usr/lib/syslinux/com32/include
AFAIK, all standard libs and includes are installed with the GCC. So I try to reinstall GCC (4.8.4) - nothing changes.
What is the normal way to give GCC all standard environment it needs?
Thanks to the right direction set by Sam Varshavchik I found the info in the stackoverflow. So I did the following:
1) installed build-essential:
sudo apt-get install build-essential
2) installed libusb (since my try to build the package revealed the absence of usb.h):
sudo apt-get install libusb-dev
And it is OK! The mspdebug (v.023) is compiled and successfully tested!
So, Linux Mint 17.2 (at least) requires installing some libs to a GCC, the most basic is build-essential.
assert.h is not part of gcc, it's a part of glibc.
Most likely, your Linux distribution puts the system headers into a separate package that you need to install.
Fedora, for examples, puts the header files in the glibc-headers package. However, you can't be using Fedora, because Fedora's gcc package has a dependency on glibc-headers, to make sure that it gets pulled in.
Whatever Linux distribution you're using, you need to research which distribution package will install the system header files you need to build stuff with.

How to install Open MPI with Cuda-Aware MPI in Linux Debian

I am installing Open MPI v1.8.8 with CUDA v7.5 on my Linux Debian.
I have tested CUDA and it works, tested OpenMPI and it works too. But when i try to combine them into a program, i meet an error: cannot find cuda.h file . This is my scenario:
My program source code include these .h file
include "cuda.h"
include "mpi.h"
I run command:
mpicc <filePath> -o test
And error appear:cuda.h: No such file or directory
#include "cuda.h"`
omp_info give me : mca:mpi:base:param:mpi_built_with_cuda_support:value:false
I have googled , and i followed some methods i found:
./configure --with-cuda
./configure --with-cuda=/usr/local/cuda-7.5
( source link : http://mirror.its.dal.ca/openmpi/faq/?category=buildcuda)
After that, i remake all , remake install Open Mpi. I run: mpicc or mpirun, the compiler give me error : mpirun error mca: base: component find: unable to open /usr/local/lib/openmpi/mca_mpool_sm
I set up soft link : ln -s /usr/local/cuda/include /usr/include ( describe in link : Building CUDA-aware openMPI on Ubuntu 12.04 cannot find cuda.h).
But it cannot fix my issue.
Does anyone successfully install it? Please help me or share your experience.
Thanks.
I think you are confusing installation problems with incorrect compiler options. It will be necessary to explicity specify the include paths, library paths, and libraries for CUDA when compiling and linking host code with your mpi wrapped host compiler.
Something like:
mpicc -I/usr/local/cuda-7.5/include -L/usr/local/cuda-7.5/lib -o test <filePath> -lcuda
would be the normal way to build a simple MPI program which call the cuda driver APIs. You will need to add nvcc compilation for device code and host code which uses the runtime API.
The apparent lack of CUDA support in your MPI flavour is a separate question and one you should probably take up in another forum (like the user mailing list of the MPI flavour you use).

How to make GCC detect standard C library?

my problem is the following :
In order to build some specific library I have to install GCC on a red hat without access to Internet and no way to use yum.
For now I did :
1)I installed gcc-x86_64-linux-gnu (and it's dependencies)
2) I created symbolic links in /usr/bin for the following installed executables : /usr/bin/x86_64-linux-gnu-cpp, /usr/bin/x86_64-linux-gnu-gcc, /usr/bin/x86_64-linux-gnu-gcov
using sudo ln -s /usr/bin/x86_64-linux-gnu-<end> <end>
So I have functional gcc cpp and gcov command.
3) I tested a ./configure on my library to build and get GCC saying that the C compiler isn't able to create C executable. I so tested to create a simple hello world C program.
#include<stdio.h>
int main(void){
printf("hello world!\n");
return 0;
}
when running gcc ./hello.c -o helloI got the this error : "fatal error : stdio.h : no such file or directory".
4) I did a ls /usr/include | grep .h but found nothing. Conclusion : standard C libs aren't installed.
5) I so installed glibc-devel to import the standard C library, and now the same command show numerous C files, including the stdio.h file.
But my GCC still raising the same fatal error.
Any idea about what should I do make to make it work ?
I don't think the problem here is related to x86 / x64 problem as it is suggested in this question
From your post i assume that this is related to improper installation, before installing a package make sure you use the proper package to the proper distribution as compatibility issues may arise with 32 Bit or 64 Bit OS package. You could try the below method by using a Red Hat Boot CD.
Install rpm from CDROM/DVD
Mount your RHEL Linux CD/DVD and install the following packages using rpm command:
$rpm -ivh gcc*

manual installation of gcc

i dont have internet connection, so i installed gcc on my linux system manually through its debian package. but i am not able to compile any c code.
here is my sample c code.
#include <stdio.h>
main()
{
printf("Hellp world");
return 0;
}
the error that it shows:
ocpe#blrkec241972d:~$ gcc -o hello hello.c
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function âmainâ:
hello.c:4: warning: incompatible implicit declaration of built-in function âprintfâ
I think i have not installed all the dependencies of compiler. Plz suggest me descriptive way to install it correctly..
Assuming by "installed manually", you mean "using dpkg -i", then you need to also install libc6-dev. I suggest further installing, at very minimum, build-essential and everything it depends on.
Debian actually has a few programs to help with offline package installation. One option is of course to use CD/DVD images. Another is to use something like apt-offline.
On my Debian system, the header files are in another package libc6-dev. You're probably missing that (and some others as well, I would guess).
What about this gcc -Wall hello.c -o hello -I/usr/include/stdio.h?
You can see your include search path by using:
echo | gcc -v -x c -E -
On my Ubuntu Linux machine i can see this output for the previous command:
#include \"...\" search starts here:
/usr/lib/gcc/i686-linux-gnu/4.6.1/include
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed
/usr/include/i386-linux-gnu
/usr/include
EDIT :
Install build-essential
Download from here : http://packages.debian.org/squeeze/i386/build-essential/download (assume you are 32 bits), and install dowloaded package like this:
dpkg -i build-essential.deb

Resources