Linux make error no such file or directory

How do I handle a «No such file or directory» error for a header file from make?

This typically indicates that you haven’t installed some dependency of the program you are trying to compile. Depending on the header file in question and the program you are trying to compile, you have a couple of options:

Target software exists in the Ubuntu repositories

Sometimes you want to compile from source a package already provided by Ubuntu (to get a different version, perhaps, or to patch it). If the software hasn’t changed too much, you can use apt to get the dependencies:

This should install all the packages needed to build the Ubuntu package of that software (which may have fewer or more packages than what your source package actually needs).

If you only need to make some minor change in the source, or apply a patch, you might even be able to save a significant bit of effort by letting apt and dpkg do the legwork:

sudo apt-get build-dep apt-get source

This will download the source files of the package, including everything needed to make a package of it. The files will be in a directory named — . Enter it, make all the changes you want, and then do:

sudo dpkg-buildpackage -b -us -uc 

This creates unsigned binary package(s) in the parent directory ( cd .. ). You can then use dpkg to install these packages:

Target software is not present in the Ubuntu repositories

You can still try your luck with the specific header file missing. Use either the Ubuntu Packages index (the option to search the contents of packages) or apt-file to search for the file. Sometimes multiple packages may provide similarly named files, in which case, prefer:

  1. Files in /usr/include .
  2. Packages of your architecture (use uname -m to know what your architecture is).
  3. Any specific versions your software depends on (such as Qt4 instead of Qt5) — check the README and INSTALL files in the source (if present).
  4. Packages whose names end in -dev , which typically include headers needed for compiling.
Читайте также:  Setting proxy in terminal linux

Источник

Ошибка при компиляции make «Нет такого файла или каталога»

При выполнении make может возникнуть ошибка вроде следующей:

make all-recursive make[1]: вход в каталог «/root/bin/goaccess» Making all in po make[2]: вход в каталог «/root/bin/goaccess/po» test ! -f ./goaccess.pot || \ test -z "fr.gmo es.gmo zh_CN.gmo ja.gmo" || make fr.gmo es.gmo zh_CN.gmo ja.gmo make[3]: вход в каталог «/root/bin/goaccess/po» rm -f fr.gmo && : -c --statistics --verbose -o fr.gmo fr.po mv: не удалось выполнить stat для 't-fr.gmo': Нет такого файла или каталога make[3]: *** [Makefile:169: fr.gmo] Ошибка 1 make[3]: выход из каталога «/root/bin/goaccess/po» make[2]: *** [Makefile:206: stamp-po] Ошибка 2 make[2]: выход из каталога «/root/bin/goaccess/po» make[1]: *** [Makefile:830: all-recursive] Ошибка 1 make[1]: выход из каталога «/root/bin/goaccess» make: *** [Makefile:532: all] Ошибка 2

На самом деле, имена файлов могут быть различными, но суть ошибки в том, что не найдены файлы или каталоги:

«mv: не удалось выполнить stat для '. ': Нет такого файла или каталога»

Если вы перед компиляцией с make предварительно использовали autoreconf из пакета autoconf, то проблема практически наверняка в отсутствие программы gettext.

Для установки gettext достаточно выполнить команду:

Также проверьте, чтобы у вас была установлена программа autopoint и если она отсутствует, то установите её как показано здесь.

Связанные статьи:

Источник

error: stdio.h: No such file or directory error during make

I’m trying to compile the following program in Ubuntu. But I keep getting the error: «stdio.h: No such file or directory» error.

obj-m += hello.o all: make -I/usr/include -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean 

3 Answers 3

Your way of building your program is the way to build kernel module and not c program application. and stdio.h does not exist in the environment of the kernel development so that’s why you get the error:

error: "stdio.h: No such file or directory" error 

1) If you want to build a linux application then your Makefile is wrong:

Читайте также:  Сервер развертывания windows на linux

You should modify your Makefile

Use the following Makefile:

all: hello test: test.c gcc -o hello hello.c clean: rm -r *.o hello 

2) If you want to build a kernel module then your c code is wrong

  • YOU CAN NOT use stdio.h in the kernel space development. Itdoes not exist in the environment of the kernel development so that’s why you get the error
  • YOU CAN NOT use main() in the kernel module C code
  • YOU CAN NOT use printf() in the kernel module C code

INSTEAD of using stdio.h , you have to use the following include

#include /* Needed by all modules */ #include /* Needed for KERN_INFO */ 

INSTEAD of using int main() < , you have to use

INSTEAD of using printf() use printk()

Use the following hello module instead of your hello code

/* * hello-1.c - The simplest kernel module. */ #include /* Needed by all modules */ #include /* Needed for KERN_INFO */ int init_module(void) < printk(KERN_INFO "Hello world 1.\n"); /* * A non 0 return means init_module failed; module can't be loaded. */ return 0; >void cleanup_module(void)

Please refer to the following link for more detail about kernel module development

Источник

linux/module.h: No such file or directory

i’m a beginner and i’m trying out some basics of kernel programming in linux. Today morning i’ve opened the module.h file in VIM, and closed without saving any changes as well. After that i’m not able to compile any of my codes. I’m getting the following error message

[root@localhost helloworld]# cc helloworld.c helloworld.c:1:25: error: linux/module.h: No such file or directory [root@localhost helloworld]# 
#include #include int init_module(void) < printk("HELLO WORLD"); return 0; >void cleanup_module(void)
[root@localhost usr]# find . -name module.h ./src/kernels/2.6.18-194.el5-i686/include/asm-x86_64/module.h ./src/kernels/2.6.18-194.el5-i686/include/asm-i386/module.h ./src/kernels/2.6.18-194.el5-i686/include/linux/module.h ./include/sepol/policydb/module.h ./include/sepol/module.h ./include/kde/kunittest/module.h [root@localhost usr]# 

3 Answers 3

You’re trying to compile your module with plain gcc with none of the surrounding kbuild framework. You might have gotten something to work in the past with this approach, but it is painful horrible awful to try to maintain a module using anything other than pure-kbuild Makefile approaches. I’ve wasted too much of my life fighting against kbuild and I don’t want the same to happen with you — embrace kbuild and let it help you build your module. Please read Documentation/kbuild/modules.txt before writing another line of code.

Читайте также:  Как посмотреть жесткие диски линукс

What you need to do is create a Makefile for your module. Its contents should look like this:

ifneq ($(KERNELRELEASE),) # kbuild part of makefile obj-m := modulename.o else # normal makefile KDIR ?= /lib/modules/`uname -r`/build default: $(MAKE) -C $(KDIR) M=$$PWD endif 

I know it’s a lot more complicated than most Makefile s you’re used to seeing, but it serves a dual-purpose. If you just run make in your directory, it’ll re-invoke make to use the kbuild mechanism from the currently-running kernel (assumed to at least have a symlink from /lib/modules/. /build to the correct location).

The re-invoked make command ( $(MAKE) ) will properly build your module and save you more time than you can ever appreciate. (Really.)

Keep Documentation/kbuild/modules.txt by your side while making this work.

Note: Documentation/kbuild/modules.txt may be available at your linux system at /usr/share/linux-headers-$(uname -r)/Documentation/kbuild/modules.txt

Источник

Оцените статью
Adblock
detector