specifying a kernel header dependency in dpkg for module build - kernel-module

I have a dpkg that is dependent upon the having the kernel headers to compile a dkms based kernel module. I know I can get the proper headers installed by executing
apt-get install linux-headers-$(uname -r) but that I can not do this within the preinst or postinst scripts. Nor can I list linux-headers-$(uname -r) as a dependency in the control Depends entry.
Is there any way of declaring a dpkg dependency that is dependent of the kernel version?
I am using fakeroot dh binary to do the packaging.

I found an answer. I am compiling on a raspberrypi and by adding raspberrypi-kernel-headers to the Depends: line of the debian/control file it picks up the proper headers.

Related

Including Linux Headers returns No such file or directory

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

error when compiling testfiles from installed c-algorithms library

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.

library path for Tcl extension in C

I use Tcl_CreateObjCommand to build a Tcl extension in C called libA.so, the C code call the function from an external C library called libext.so, where should I put libext.so, so that the tcl could find and load it when it load libA.so
Use a package installer
If you have a package manager you should install tcl/tk with it.
sudo apt-get install tk
or you might want also tk-dev (which is sometimes called tk-devel):
sudo apt-get install tk tk-dev
Install manually
You can put so's manually in /usr/local (libraraies in /usr/local/lib/ and include files in /usr/local/include/), But remember to avoid installing them under /usr if you do have a packaging system.
There's also an option of putting them under your project directory, but you'll have to help the dynamic linker find them (using LD_LIBRARY_PATH or ld.so.conf). Also, you'll have to update your project's include paths and library paths.

How to install without make?

I am working with a BeagleBoard and I have already compiled ZMQ library with arm-linux-gnueabi gcc compiler. The problem is I don't know where to copy all that files because I don't have make command nor I am able to install it.
If I run:
uname -mrs
I get:
Linux 3.2.8-mg01.3 armv7l
Thanks in advance!
Build & install required library on your build machine:
./configure --prefix=/custom/location
make && make install
And then just copy /custom/location from your build machine to the target machine's root /.
You need to check that no stuff are being overwritten (or at least that no dependencies got lost).
Another, correct way, would be to create an installable package (i.e., deb or rpm), but that is a different question.

sql.h header file missing though unixODBC is installed

I am on an up-to-date Ubuntu 12.04 system. I have unixodbc (v2.2.14 from ubuntu repos), MySQL and its relevant drivers installed. Also connected to a valid DSN. Verified by issuing isql DBName UName passwd.
I am trying to compile a C application that interacts with the database using ODBC. Almost everywhere I searched seemed to indicate that I should have "sql.h" installed somewhere. A find / -iname sql.h -print showed I don't have it.
So my question is: where is it? Did something go wrong with the install (no errors were reported though)? And what steps do you recommend? Reinstallation? Compilation from source code (the latest version?)?
You need to install the unixodbc-dev package to get the development header files.
sudo apt-get install unixodbc-dev
The -dev packages contain the require header files required to compile and build programs using these headers to make calls to the library. The library files themselves would be part of the regular package i.e. unixodbc in your case.
If you want to know which package provides a certain file, you could use apt-file:
sudo apt-file update
sudo apt-file find sql.h

Resources