Can not find linux/modversions.h - c

I am trying to install the driver for a serial device, and when I run the installation executable I get this error:
cc -DLINUX -c -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -m64 -mcmodel=kernel -I/usr/src/linux-3.8.0-27-generic/include -I/usr/src/linux-2.4/include -I/usr/src/linux/include -D__SMP__ npreal2.c
npreal2.c:40:31: **fatal error: linux/modversions.h: No such file or directory**
compilation terminated.
I don't find any solutions to this after searching the forums. I noticed that there is a modversions.h in the /usr/src/linux-3.8.0-27-generic/include/config , but not in the linux folder.
Please help!

Try passing -I /usr/src/linux-3.8.0-27-generic/include/config as an argument to make?
or
Check if the header is a part of a certain package and update the package.

You can compile modversions on your system by navigating to the linux directory (usually usr/src/linux). Inside the linux source directory, there should be a file called Rules.make. Inside this make file are build commands for making modversions.h. You can make it by running:
make update-modverfile
Now, while this will make the modversions.h library, if you compile it with a newer compiler than the libraries that this file relies on, many times you will get an error when trying to run a program that uses this header. This then turns into a nightmare.

Another method, I tried it successfully with Xubuntu 13.10:
Open /etc/default/grub
Add this Line and save it.
GRUB_CMDLINE_LINUX="CONFIG_MODVERSIONS=true"
reboot
(no, sudo update-grub,ok)
open a terminal window, enjoy.
locate modversions.h
(Please don't forget modversion'S')

Related

Link a makefile for using SDL librarie

I'm learning using the SDL librarie, with a french site.
This is the tuto :
"There may be some of you who have gotten into the habit of compiling by hand under Linux using a Makefile (file controlling compilation).
If this is your case, I invite you to download a Makefile which you can use to compile SDL projects.
The only thing a little special is the addition of the SDL library for the linker (LDFLAGS). You will have to download the Linux version of the SDL and install it in your compiler folder"
I've found my gcc folder in /usr/bin/gcc , but when I want to move the makefile to this folder, the error is :
mv: cannot move 'makefile_sdl' to '../usr/bin/makefile_sdl': Permission denied
There it is my make file, maybe something's wrong or missing (i'm a beginner ahah)
CPP=gcc #compiler command
CFLAGS=-O3 #Option d'optimisation du programme
LDFLAGS=-lSDL -lSDL_mixer #Linker
EXEC=nomProgramme #Nom du programme à modifier
all: ${EXEC}
${EXEC}: ${EXEC}.o
${CPP} $(CFLAGS) -o ${EXEC} ${EXEC}.o ${LDFLAGS}
${EXEC}.o: ${EXEC}.c
${CPP} $(CFLAGS) -o ${EXEC}.o -c ${EXEC}.c
You don't need to (and shouldn't) move the makefile to /usr/bin.
You can put it anywhere, but things will be easier if it's in the same directory as your source code (nomProgramme.c).
You need to name your Makefile Makefile. Case sensitive, make sure to check for spelling errors, etc. You also need to be in the same directory as Makefile when you run make.
You should also just run make without any specified targets. It will automatically build the all target, which will build your program into an executable called nomProgramme.
You'll also need to install libsdl-mixer1.2-dev (sudo apt-get install libsdl-mixer1.2-dev and change EXEC=main back to EXEC=nomProgramme.
Here's a link to the GNU make documentation. It gives a quick overview and then a very detailed explanation of everything you can do with GNU make: https://www.gnu.org/software/make/manual/make.html
to answer the OPs question:
the directory /usr/bin is not writable via user (like yourself).
However, executing a command line that is prefixed with sudo (giving you 'root' privileges) will enable you to write on that directory.
However, /usr/bin is intended for executable files and Makefile_sdl is NOT an executable file
Suggest saving that file 'somewhere' Then when you want to use that makefile, to copy it to the directory where your current project is located (I.E. the directory in which you want to run make
However, Makefile_sdl is not one of the standard file names recognized by make so must run make via:
make -f Makefile_sdl

Cannot link linker.ld

I am currently following the Bare Bones tutorial from OSDev and i have set up everything and compiled the kernel and bootloader into object files, and i have the .ld file. However, when i try to link the files and produce it into a bin using i686-elf-gcc -T linker.ld -o myos.bin -ffreestanding -O2 -nostdlib boot.o kernel.o -lgcc, i get this error:
.../i686/bin/../lib/gcc/i686-elf/4.8.2/../../../../i686-elf/bin/ld.exe: cannot open linker script file linker.ld
collect2.exe: error: ld returned 1 exit status
I am using GCC and using the compiled version of i686-elf-gcc which includes many more compilers and i have added 4 dlls as it was missing (also not related to linker), but i installed MinGW and added them. I am on Windows 10 x64. Many of the solutions or workarounds i find just brings up more errors or does absolutely nothing to the errors (-T doesn't do anything, -noixemul is not a parameter.). I removed multiboot content since i am gonna use a sector-long bootloader which loads the object files.
If i'm not mistaken, your problem is really, really, really simple:
You don't have access to linker.ld. Try running as superuser or changing the permissions.
If this doesn't solve it, you have an actual problem. Try not using the -T flag.
EDIT: Dear god, I didn't expect this to be right. Thanks!

gcc and liboauth - linker can't find oauth.h

I'm trying to use liboauth with a C program, using gcc as my compiler, and no matter what I've tried I keep getting the error "ld: library not found for -loauth" and "clang: error: linker command failed with exit code 1".
I'm including the header via "#include <oauth.h>", and my most-recent call to gcc looked like this:
gcc -Wall -lcurl -loauth -I /usr/local/include -v -o api api.c
Now, oauth.h does exist in /usr/local/include, and there are a handful of liboauth files (including liboauth.a) located in /usr/local/bin, which I'm assuming were placed there when I ran the install. I will admit that I'm not very familiar with gcc and compiling non-trivial C programs, but I was able to get libcurl working on a fresh download in just a few minutes. I just can't figure out what's going on with liboauth.
Thanks in advance
If you are sure liboauth's located in /usr/local/bin use
gcc -Wall -L/usr/local/bin -I /usr/local/include -v -o api api.c -lcurl -loauth
It'd also be better to place libraries in the end of the command as there is some important stuff with them (they may depend on each other, etc).
By the way, it's pretty strange your libraries are in /usr/local/bin as libraries are almost always stored in some path like /usr/*/lib.

How to configure a non-standard linker for an autotooled build?

I wanted to configure an autotooled project to invoke a non-standard
linker (the gold linker),
using the stock autotools of Linux Mint 16/Ubuntu 13.10
I believed I would achieve this by:
libtoolize-ing the project
Running ./configure LD=/path/to/my/linker ... etc.
However this has been ineffective. libtoolize has been successful. After
a standard ./configure; make I now see that libtool is doing the
linking:
/bin/bash ./libtool --tag=CXX --mode=link g++ -g -O2 -o helloworld helloworld.o
But passing LD=/path/to/my/linker to configure makes no difference. Experimentally,
I even ran:
./configure LD=/does/not/exist
expecting to provoke an error, but I didn't. The output contains:
checking if the linker (/does/not/exist -m elf_x86_64) is GNU ld... no
checking whether the g++ linker (/does/not/exist -m elf_x86_64) supports shared libraries... yes
And thereafter a make continues to link, successfully, invoking g++ exactly as before.
What is the right way to configure a non-standard linker?
But passing LD=/path/to/my/linker to configure makes no difference
This is because LD is almost never and should almost never be used to link any user-space program. Correct links are performed by using the appropriate compiler driver (gcc, g++, etc) instead.
What is the right way to configure a non-standard linker?
If you have /some/path/ld and you want gcc to use that ld, pass -B/some/path flag to gcc.
It then follows that you likely want:
./configure CC='gcc -B/some/path' CXX='g++ -B/some/path' ...
I landed on this via a Google search, though my scenario is a bit different from yours; there was no libtool involved. An old open source program's Makefile was hard-coding ld to create an object file with a symbol from binary data.
This is what I ended up doing to work around the lack of $(LD) being recognized when passed to configure:
https://github.com/turboencabulator/tuxnes/commit/bab2747b175ee7f2fc3d9afb28d69d82db054b5e
Basically I added to configure.ac:
AC_CHECK_TOOL([LD], [ld])
Leaving this answer here for if someone else lands via a google search.

OpenCV - C library is not working in my Ubuntu11.10

Resently I'm installed Opencv in my machine. Its working in python well(I just checked it by some eg programs). But due to the lack of tutorials in python I decided to move to c. I just run an Hello world program from http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/
while compiling I got the following error
hello-world.c:4:16: fatal error: cv.h: No such file or directory
compilation terminated.
I'm new in opencv
Qn : Could you please report what may be the problem - and how I run my helloworld program in c?
Your compiler cannot find your cv.h include file. If you installed from your package manager, it is probably in /usr/include/opencv/. You need to add that your include search path. If you are compiling from the command line use -I to specify additional include directories. It will be something like -
gcc -I /usr/include/opencv/ -o helloworld helloworld.c
If you are using Eclipse,
Right click on the project and select properties.
Select C/C++ General -> Path and Symbols.
Select Includes tab.
In Languages list, select 'GNU C' or 'GNU C++' depending on which you are using.
Press 'Add...' button and add /usr/include/opencv/
Save and rebuild.
You need to show compiler path to cv.h file. The quick way to find it is to do (on Ubuntu):
find /usr -name "cv.h"
/usr/local/include/opencv/cv.h
Just add this to the compiler:
gcc -I/usr/local/include/opencv -o helloworld helloworld.c
Since you asking this question your compiler might also have problems linking your program to opencv libraries. Just do the same thing only for library files:
find /usr -iname "libopencv*"
/usr/local/lib/libopencv_flann.so
...
add this folder the same way and specify libraries you want to use:
gcc helloworld.c -I/usr/local/include/opencv -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -o helloworld
that should probably compile. There is a also a short cut you can take and instead of all that steps just use the following command
gcc helloworld.c `pkg-config --cflags --libs opencv` -o helloworld
that should take care of all the work of locating required files for you and let you focus on the fun coding part.
maybe you just installed the opencv package.
But, as you want to use opencv in your C program, you may also install the package named just like opencv-devel. If you haven't, install it and than use it as #iagreen said.
Best wishes to you.

Resources