- Как установить заголовочные файлы ядра в Linux
- Установка заголовочных файлов ядра в Debian, Ubuntu или Linux Mint
- Установка заголовочных файлов ядра в Fedora, CentOS или RHEL
- Adding a directory for the headers in a Makefile
- 2 Answers 2
- Include Linux header file
- 3 Answers 3
- Not the answer you’re looking for? Browse other questions tagged c++ linux or ask your own question.
- Related
- Hot Network Questions
- Subscribe to RSS
- compile and run c++ program with own header files in linux
- 3 Answers 3
- Not the answer you’re looking for? Browse other questions tagged c++ linux header-files or ask your own question.
- Related
- Hot Network Questions
- Subscribe to RSS
- Linux-Headers Reinstall
- 4 Answers 4
- Find linux-headers-4.4.0-98
- Install linux-headers-4.4.0-98
- Remove linux-headers-4.4.0-98
- Cleanup leftover garbage
Как установить заголовочные файлы ядра в Linux
Когда вы компилируете драйвер устройства как модуль ядра, вам необходимы установленные заголовочные файлы ядра. Также они требуются, если вы собираете пользовательское приложение, которое взаимодействует напрямую с ядром. При установке заголовочных файлов ядра, необходимо убедиться, что их версия совпадает с версией ядра установленного в системе.
Если версия вашего ядра не менялась после установки дистрибутива, или вы обновляли его с использованием системного менеджера пакетов (то есть apt-get, aptitude или yum) из системных репозиториев, то заголовочные файлы вы также можете установить с помощью пакетного менеджера. Однако если вы скачивали исходный код ядра и компилировали его самостоятельно, то заголовочные файлы необходимо устанавливать с помощью команды make.
Здесь мы предполагаем, что ваше ядро установлено из основного системного репозитория вашего дистрибутива, и вы хотите установить соответствующие заголовочные файлы ядра.
Установка заголовочных файлов ядра в Debian, Ubuntu или Linux Mint
Если вы не компилировали ядро вручную, то можете установить соответствующие заголовочные файлы ядра с помощью команды apt-get.
Сначала проверьте, не установлены ли уже требуемые заголовочные файлы с помощью команды:
Теперь установите заголовочные файлы, как показано ниже.
Проверьте, что установка прошла успешно.
По умолчанию в Debian, Ubuntu или Linux Mint заголовочные файлы находятся в /usr/src.
Установка заголовочных файлов ядра в Fedora, CentOS или RHEL
Если вы не обновляли ядро вручную, то можете установить соответствующие заголовочные файлы ядра с помощью команды yum.
Сначала проверьте, не установлены ли уже требуемые заголовочные файлы. По умолчанию заголовочные файлы ядра расположены в /usr/src/kernels/.
Если подходящих заголовочных файлов не установлено, вы можете установить их с помощью команды yum. Она автоматически найдет подходящий пакет.
Если заголовочные файлы ядра, установленные с помощью вышеприведенной команды, не соответствуют установленному в системе ядре, значит оно устарело. В этом случае обновите ядро системы до последней версии с помощью приведенной ниже команды. После обновления необходимо перезагрузить систему.
Теперь проверьте, что установлены заголовочные файлы соответствующей версии с помощью команды:
Источник
Adding a directory for the headers in a Makefile
Hello I would like to ask you, If someone knows how can I add a directory for the header files in the Makefile to avoid the error *.h not found, I have tried this option but does not work:
2 Answers 2
At least for GNU make, try the implicit variable CFLAGS , as in:
Although the goal is ultimately to affect the value of CFLAGS (as suggested by @unwind), it is often not a good idea to simply set the value of CFLAGS as it is often built out of many pieces. You have to understand the structure of the makefile, and the set of macros used.
Eduardo asked: Can you post macros to do the same?
Yes, but whether they are helpful depends on how your makefiles are structured. Here’s a moderately complex example from one of my makefiles.
This a makefile for a program of mine called sqlcmd (a name chosen a decade and more before Microsoft created a command of the same name). I assume that the make program has a rule for compiling C code to object like:
and that the rule for linking a program from a set of object files listed in the macro OBJECTS looks like:
As you can see, there are separately settable macros for the ESQLC_VERSION (the version of Informix ESQL/C in use, derived by default by runing a script esqlcver ), then the include directories via INC1 to INC5 and INCFLAGS (there can be quite a lot of these, depending on platform), and optimizer flags (OFLAGS), extra flags (CFLAGS), user-defined flags (UFLAGS — an idiom I use in most of my makefiles; it allows the user to set UFLAGS on the make command line and add an extra flag to the build), and a bunch of library-related macros. This is what it takes for my development makefile to be tunable with minimal fuss to my development platform, which can be Linux, Solaris or MacOS X. For consumers of the program, there is a configure script generated by autoconf , so they don’t have to worry about getting those bits right. However, that has a strong genetic resemblance to this code, including the UFLAGS option.
Note that many systems for makefile building have a mechanism for setting CFLAGS faintly similar to this — and simply assigning to CFLAGS undoes the good work done by the system. But you have to understand your makefile to be able to modify it sanely.
Источник
Include Linux header file
How could I include a linux header file? I read from the web that the header file is in /usr/include . However, the header file I need is not in that directory; it is in /usr/src/kernels/2.6.32. /include/linux/ .
I tried to include the file using the full path. However, the file itself includes other header files as well. Hence, the compiler couldn’t find the other header files when I compile.
How could I include the header file in my program and compile the program?
3 Answers 3
If you are on Ubuntu, install libcpufreq-dev . This will give you the cpufreq.h header at /usr/include/cpufreq.h , which you can include from your code with #include .
By default, gcc searches the following directories for header files:
and the following directories for libraries:
The compiler options -I and -L add new directories to the beginning of the include path and library search path respectively.
You may add to your gcc command line -I (for «includes») options which specify other directories to search for include files (besides or actually even instead of the normal ones like /usr/include , though it’s so long since I last needed the «instead of» that I don’t recall how that’s done == man gcc should tell you in 5 minutes if you need to find out;-).
Not the answer you’re looking for? Browse other questions tagged c++ linux or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.10.8.40416
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Источник
compile and run c++ program with own header files in linux
This is my first go at making my own header file. I am trying to make a simple Hello World program in C++ on Ubuntu. made 3 files as follows :
to compile header file and this command worked.
then, while doing
I am ending up with following error:
Please suggest whether changes need to be made in any file or in any command in the terminal?
3 Answers 3
You don’t link to hello.o in the command below:
Or for such simple program, just issue the command below:
For ease of use, create a makefile, then you just run make:
A simple makefile:
Put hello.h in Path2Hello;
ps: -I option to specify an alternate include directory (for header files).
To compile and run a C language program, you need a C compiler. To setup a C language compiler in your Computer/laptop, there are two ways:
Download a full fledged IDE like Turbo C or Microsoft Visual C++, which comes along with a C language compiler. Or, you use any text editor to edit the program files and download the C compiler separately.
Not the answer you’re looking for? Browse other questions tagged c++ linux header-files or ask your own question.
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.10.8.40416
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Источник
Linux-Headers Reinstall
I’m trying upgrade firefox but says that i need to reinstall linux-headers 4.4.0-98.I tried to install but that’s it’s what happens ‘the package linux-headers needs to be reinstalled, but i can’t find an archive for it’.
4 Answers 4
First try the fix-missing feature
Second, try to install headers from the command line:
Maybe you just need these specific headers (linux-headers-4.4.0-98-generic):
If that doesn’t work, see what kernel type you are using (generic, lowlatency, etc.):
This will return something like «4.15.0-30-generic» or «4.15.0-30-lowlatency». Install/Reinstall the headers that correspond to your kernel type. Eg if it is the generic kernel (most likely):
This will cause the current headers for your current kernel to be automatically installed and upgraded.
If above doesn’t work, try the following:
Update to latest kernel:
Reboot to ensure you are using latest kernel.
Purge out old headers and removed unused apps/kernels:
Reinstall the headers:
These commands worked for me.
Find linux-headers-4.4.0-98
Install linux-headers-4.4.0-98
For your reinstall you will type:
But for myself it’s a new package so I’ll use:
Remove linux-headers-4.4.0-98
Because this was a test and I don’t need them on my machine:
Cleanup leftover garbage
I see there is left over garbage in the last line so I’ll manually clean it up:
Now 4.4.0-98 is almost removed. It is completely removed with:
If you have internet connection.
Run software-properties-gtk . In Ubuntu Software tab, notice the Download from field. What do you have there? (I use «ubuntu.trumpetti.atm.tut.fi/ubuntu» as I live in Finland; at least that server has linux-headers-4.4.0-98 currently.) Try to change the setting in the field. In Updates tab see that you have «Important security updates» checked. Do what the dialog asks. And close it. Then do the following in terminal (but stop, if there are errors and please report them in comments.):
and run update-manager to install further updates.
If you do not have internet connnection.
If the problem is that you do not have internet connection, but you have Ubuntu CD-ROM/DVD installation media, you can use it as a software source, see here. If you do not have optical media, but USB one, trye this.
Check if the media contains some other kernel:
If it contains different version, you had better purge the 4.4.0-98 headers:
Источник