I am on an Ubuntu machine and I want to use python in my C code but when I include the Python.h header file, it shows a warning:
Python.h: No such file or directory
Any method for this. I have already tried to use:
sudo apt-get install python3-dev and;
sudo apt-get install python-dev
But it keeps showing error.
The Python.h file is not in the default compiler include path.
Add the output of pkg-config --cflags python3 to your compiler command line.
Now the compiler will know where to find Python.h (and any dependencies it may have)
Related
I am trying to write a PulseAudio module. To start, first, I wrote the following minimal code for a module as mentioned by this documentation.
#include <pulsecore/module.h>
int pa__init(pa_module *m)
{
return 0;
}
I tried compiling it with this command:
gcc -g -shared -o module-test.so module-test.c
But it gives error:
pulsecore/module.h: No such file or directory
#include <pulsecore/module.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
After searching on the internet, I found that I have to installed libpulse-dev, but I have already installed pulseaudio and libpulse-dev as you can see below.
jyotesh#jyotesh-VM:~$ sudo apt install pulseaudio libpulse-dev
[sudo] password for jyotesh:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libpulse-dev is already the newest version (1:11.1-1ubuntu7.2).
pulseaudio is already the newest version (1:11.1-1ubuntu7.2).
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
I have tried searching for the header file using locate, find, apt-file, etc. I am not able to find where this header file is.
Does anyone know how to compile the PulseAudio module?
I was able to compile the code and build module-test.so file by following the steps from here and here. I will repeat the steps here:
First, I built and installed PulseAudio v12.2 from the source code.
# Clone PulseAudio git repository
git clone https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
# I wanted 12.2 version of PulseAudio, so I checked out that version
cd pulseaudio
git checkout tags/v12.2
# Install the dependencies
sudo apt-get -y build-dep pulseaudio
# Build PulseAudio source code
./bootstrap.sh
make
# Install and configure dynamic linker run-time bindings (so that
# ld can find the libraries that you specify while building your module)
sudo make install
sudo ldconfig
After this, I wrote minimal code for a module.
#include <config.h> // this is required, otherwise you will get compilation errors
#include <pulsecore/module.h>
int pa__init(pa_module *m)
{
return 0;
}
To compile this, I used the command
gcc -g -shared -fPIC -I/home/jyotesh/pulseaudio -I/home/jyotesh/pulseaudio/src -L/home/jyotesh/pulseaudio/.libs -L/usr/local/lib/pulseaudio -o module-test.so module-test.c -lpulsecore-12.2 -lpulsecommon-12.2 -lpulse
So, I'm trying to compile my C code using the command "gcc -o file file.c", but I get "error: libnet.h: No such file or directory" I included libnet.h (#include ) and I also installed libnet. I'm running CentOS 7.
yum install libnet only installs the precompiled library.
You need to install the headers using yum install libnet-devel before you can use it in your own software.
I'm trying to write a C code that will make use of the memory information in Linux kernel (Virtual address space of a process, status of a process and such info.)
I'll need to include the below headers to get these info.
#include<linux/init.h>
#include<linux/module.h>
#include<linux/mm.h>
The actual files exists under the linux folder, but when compiling the file using gcc it returns that
No such file or directory
Can someone please explain why i'm getting this error! and what should i do?
I've already compiled the Kernel and installed all updates available (kernel version 3.16.0)
The answer to your question.
Install the missing package kernel-devel using apt-get
NOTE: I've mentioned apt install package you can use what is supported on your system for example yum.
If you're not able to install kernel-devel then you can try this which install generic Linux headers.
sudo apt-get update && sudo apt-get install linux-headers-`uname -r`
Then you can check where the init.h or module.h using locate utility
and then add the path in your compilation using -I flag.
gcc -g your_file.c -I/usr/path/of/the/kernel/header/include
I'm trying to install and test c library c-algorithms from Github.
https://github.com/fragglet/c-algorithms/blob/master/test/test-queue.c
When I try to test the installation from the generated test folder with:
gcc -o test-arraylist `pkg-config --cflags --libs libcalg-1.0` test-arraylist.c
I get the following error massage:
test-arraylist.c:30:23: fatal error: arraylist.h: No such file or directory
compilation terminated.
I use a Vagrant box: ubuntu/xenial32 with Ubuntu 14.04.5 LTS
Prior to installation of c-algorithms:
sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install pkg-config
To install the library I have done following:
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
Any help would be highly apriciated
The test-arraylist.c has line #include "arraylist.h" but it is under the libcalg subdirectory not directly in the include path.
libcalg subdir should be added to the include path or you have to modify the include like #include "libcalg/arraylist.h"
If you want only run the tests, then run the
sudo make check from the build root (in your case it is the source root)
This is probably going to be stomped on by process-fetishizers.
But.
When you build in a Unix/Linux operating system (and derivatives like RTEMS), you are building off other people's libraries - so you need those libraries and their header files ( just like c-alg... ) installed in locations that your compiler can find.
To find a file that is associated with a package, use dpkg as explained here:
https://askubuntu.com/questions/481/how-do-i-find-the-package-that-provides-a-file
But you have another problem you might not be aware of. You are trying to compile a test program using a gcc command when the software uses GNU autoconf automake and probably libtool to function PROPERLY.
Perhaps you don't understand you need to make sure autoconf, automake, and then libtool find the right configuration from one directory system to another. Fedora puts files in differing spots from Ubuntu distros.
Instead run:
autoreconf -fvi
first in the top level directory and see if this finds your header file.
THEN you run
./configure
and then
make test/check
(whichever it uses, some use recipe "all-tests", etc.)
make all
This would make all if your system is ready to handle them.
I have 64bit ubuntu installed, and I am trying to compile a code with times.h however I keep getting sys/times.h No such file or directory
What I have tried so far
1. installing libc6-dev-i386, g++-multili, and libc6 and libc6-dev (Even though it is already installed)
2. I swapped <sys/times.h> to </usr/include/sys/times.h> and now I am getting features.h No such file or directory error
Question:
It is weird how it accepts </usr/include/sys/times.h> instead of <sys/times.h>, and help?
EDIT: I can access times.h, if it matters
I would recommend running:
$ locate /sys/time.h | grep include
Using the output you can determine what to do next:
If there is a file named /usr/include/<x86_64 or i386>-linux-gnu/sys/time.h, then simply run: $ sudo ln -s /usr/include/<x86_64 or i386>-linux-gnu/sys /usr/include/sys. This will direct the compiler to the right file if it checks . This seems to be what you are doing manually.
If there is no relevant output, then try downloading build-essential. It may be that something else is missing. $ sudo apt-get update; sudo apt-get install build-essential
Let me know if this helps!