Linux usb h no such file

GCC не видит linux/usb.h и linux/backlight.h

Здравствуйте! Во время написания драйвера возникла проблема с тем, что при компиляции gcc не находит linux/usb.h и linux/backlight.h. Подскажите, пожалуйста, что с этим делать.

Ты путь к этим инклудам-то задал?

А где они лежат? Я их смог найти у себя только в исходниках ядра.

Так ты при компиляции задал правильный адрес к ним через -I ?

dm3ch@Dm3Ch-Asus-UX31A ~/Workspace/usb-pkk-backlight_driver $ gcc usb-pkk-backlight.c -I/usr/src/linux/include In file included from /usr/src/linux/include/linux/device.h:16:0, from /usr/src/linux/include/linux/backlight.h:11, from usb-pkk-backlight.c:1: /usr/src/linux/include/linux/ioport.h:200:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘check_region’ In file included from /usr/src/linux/include/linux/kernel.h:6:0, from /usr/src/linux/include/linux/cache.h:4, from /usr/src/linux/include/linux/time.h:4, from /usr/src/linux/include/linux/stat.h:18, from /usr/src/linux/include/linux/sysfs.h:20, from /usr/src/linux/include/linux/kobject.h:21, from /usr/src/linux/include/linux/device.h:17, from /usr/src/linux/include/linux/backlight.h:11, from usb-pkk-backlight.c:1: /usr/src/linux/include/linux/linkage.h:7:25: fatal error: asm/linkage.h: No such file or directory compilation terminated. 

Мальчик, ты баклажан. У тебя сырцы ядра в /usr/src хотя бы сконфигурированы? В любом случае, марш читать доки по ссылке выше!

Да, исходники сконфигурированны. Именно из этих исходников и было собранно ядро, которое у меня сейчас работает.

Меня беспокоит один момент у меня нет папки /usr/src/linux/include/asm, но есть /usr/src/linux/include/asm-generic, а в ней есть файл /usr/src/linux/include/asm-generic/linkage.h.

dm3ch@Dm3Ch-Asus-UX31A ~/Workspace/usb-pkk-backlight_driver $ gcc usb-pkk-backlight.c -I/usr/src/linux/include In file included from /usr/src/linux/include/linux/device.h:16:0, from /usr/src/linux/include/linux/backlight.h:11, from usb-pkk-backlight.c:1: /usr/src/linux/include/linux/ioport.h:200:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘check_region’ In file included from /usr/src/linux/include/linux/kernel.h:6:0, from /usr/src/linux/include/linux/cache.h:4, from /usr/src/linux/include/linux/time.h:4, from /usr/src/linux/include/linux/stat.h:18, from /usr/src/linux/include/linux/sysfs.h:20, from /usr/src/linux/include/linux/kobject.h:21, from /usr/src/linux/include/linux/device.h:17, from /usr/src/linux/include/linux/backlight.h:11, from usb-pkk-backlight.c:1: /usr/src/linux/include/linux/linkage.h:7:25: fatal error: asm/linkage.h: No such file or directory compilation terminated. 

Это должен быть симлинк в arch/`uname -m`/asm. Опять же повторюсь: используй KBuild для сборки модуля. Доки выше по ссылке.

Разобрался с kbuild, но есть иная проблема — не даёт на выходе файлов.

make: Entering directory `/usr/src/linux-3.13.1' Building modules, stage 2. MODPOST 0 modules make: Leaving directory `/usr/src/linux-3.13.1' 

Моего личного телепата сожрали людоеды. Покажи Makefile.

Я переделал Makefile от другово внешнего модуля. И теперь мой Makefile такой.

Читайте также:  Linux как зайти администратором

Но теперь он плюётся таким списком ошибок.

Модуль пока только декларирует себя. Состоит из 2х файлов: usb-pkk-backlight.c и usb-pkk-backlight.h.

 CC [M] /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.o /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:3:2: error: invalid preprocessing directive #incluce 

Ну чувааааак, ну ты издеваешься, да?

Извините за такую тупую ошибку. Исправил, но всё равно не компилится.

Извините за такую тупую ошибку. Исправил, но всё равно не компилится.

Опять я должен угадывать как оно у тебя не компилится?

dm3ch@Dm3Ch-Asus-UX31A ~/Workspace/usb-pkk-backlight_driver $ make make -C /lib/modules/3.13.1/build SUBDIRS=/home/dm3ch/Workspace/usb-pkk-backlight_driver modules make[1]: Entering directory `/usr/src/linux-3.13.1' CC [M] /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.o In file included from /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:5:0: /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.h:1:26: warning: missing whitespace after the macro name [enabled by default] /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.h:2:26: warning: missing whitespace after the macro name [enabled by default] /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:7:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:13:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c: In function ‘__inittest’: /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: error: ‘pkk’ undeclared (first use in this function) /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: note: each undeclared identifier is reported only once for each function it appears in /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: error: ‘bl_driver_init’ undeclared (first use in this function) /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c: At top level: /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘-’ token /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c: In function ‘__exittest’: /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: error: ‘pkk’ undeclared (first use in this function) /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: error: ‘bl_driver_exit’ undeclared (first use in this function) /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c: At top level: /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:21:19: error: expected declaration specifiers or ‘. ’ before string constant /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:11:1: error: ‘__mod_usb_device_table’ aliased to undefined symbol ‘pkk-bl_device’ /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: error: ‘init_module’ aliased to undefined symbol ‘pkk-bl_driver_init’ /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:19:1: error: ‘cleanup_module’ aliased to undefined symbol ‘pkk-bl_driver_exit’ make[2]: *** [/home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.o] Error 1 make[1]: *** [_module_/home/dm3ch/Workspace/usb-pkk-backlight_driver] Error 2 make[1]: Leaving directory `/usr/src/linux-3.13.1' make: *** [default] Error 2 

Это всё исключительно твои косяки из-за невнимательности. Курни маны и исправь их. Они очевидны.

Да, почитал, ошибки понял и исправил. Но осталось 2 ошибки, не могу понять, что не так. Всё, как в модуле с которого беру пример.

dm3ch@Dm3Ch-Asus-UX31A ~/Workspace/usb-pkk-backlight_driver $ make make -C /lib/modules/3.13.1/build SUBDIRS=/home/dm3ch/Workspace/usb-pkk-backlight_driver modules make[1]: Entering directory `/usr/src/linux-3.13.1' CC [M] /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.o /home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.c:11:1: error: ‘__mod_usb_device_table’ aliased to undefined symbol ‘pkk_bl_device’ make[2]: *** [/home/dm3ch/Workspace/usb-pkk-backlight_driver/usb-pkk-backlight.o] Error 1 make[1]: *** [_module_/home/dm3ch/Workspace/usb-pkk-backlight_driver] Error 2 make[1]: Leaving directory `/usr/src/linux-3.13.1' make: *** [default] Error 2 

P.S. Помогите, пожалуйста, понять, как их исправить.

Читайте также:  Linux скрипт ввести пароль

Источник

Missing ‘usb.h’ file: What is it, where do I get it?

Expansion: Very new to Ubuntu. Working my way through installations of my desired software (GNU-RADIO and GNSS-SDR).
While trying to configure a certain piece of hardware (SiGe GN3S Sampler v2 usb device) as an RF-Front End for the software, I received the following errors:

dsradin@dsradin-HP-Pavilion-dv6-Notebook-PC:~/gnss-sdr/drivers/gr-gn3s/build$ make Scanning dependencies of target gr-gn3s [ 6%] Building CXX object lib/CMakeFiles/gr-gn3s.dir/gn3s_source_cc.cc.o In file included from /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/fusb.h:26:0, from /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/gn3s.h:40, from /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/gn3s_source.h:30, from /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/gn3s_source_cc.h:35, from /home/dsradin/gnss-sdr/drivers/gr-gn3s/lib/gn3s_source_cc.cc:34: /home/dsradin/gnss-sdr/drivers/gr-gn3s/include/libusb_types.h:32:17: fatal error: usb.h: No such file or directory #include ^ compilation terminated. make[2]: *** [lib/CMakeFiles/gr-gn3s.dir/gn3s_source_cc.cc.o] Error 1 make[1]: *** [lib/CMakeFiles/gr-gn3s.dir/all] Error 2 make: *** [all] Error 2 

I tried looking through the system to find the files with no joy:

dsradin@dsradin-HP-Pavilion-dv6-Notebook-PC:~/gnss-sdr/drivers/gr-gn3s/build$ whereis usb.h usb: dsradin@dsradin-HP-Pavilion-dv6-Notebook-PC:~/gnss-sdr/drivers/gr-gn3s/build$ whereis libusb libusb: 

The excerpt from the readme I am following with the instructions say:

Go to GR-GN3S root directory, compile and install the driver: (read the drivers/gr-gn3s/README for more information)

$ cd gnss-sdr/drivers/gr-gn3s $ cd build $ cmake ../ $ make $ sudo make install $ sudo ldconfig 

Set the environment variable GN3S_DRIVER=1 in order to enable the GN3S_Signal_Source in GNSS-SDR (OPTIONAL)

In order to gain access to USB ports, gnss-sdr should be used as root.
In addition, the driver requires access to the GN3S firmware binary file.
It should be available in the same path where the application is called.
GNSS-SDR comes with a pre-compiled custom GN3S firmware available at gnss-sdr/firmware/GN3S_v2/bin/gn3s_firmware.ihx.
Please copy this file to the application path. The GNSS-SDR default path is gnss-sdr/install

(in order to disable the GN3S_Signal_Source compilation, you should remove the GN3S_DRIVER variable and build again GNSS-SDR)

Читайте также:  Linux find размер файла

I have uninstalled all packages related and re-cloned the GIT repositories that house all the relevant source codes and scoured the internet but without more information about what exactly I’m looking for I’m stuck.

Any suggestions?? Thank you for your help!

Источник

How to install libusb in Ubuntu

I have a C program that have #include part in the header. I have download libusb-1.0.0 to my computer. If I simply copy libusb-1.0.0 folder to the folder where my C program is, it will not work. Therefore, I think I have to somehow install libuse-1.-.- to the folder where my C program is. However, I do not how to install it. Could anybody please help me. Thanks!

I need to install it to the folder of my C program. Otherwise, it will not work. sudo apt-get install libusb-1.0-0-dev or # apt-get install libusb-dev can not help.

Don’t understand this. You say you copied libusb to the folder of your C program and it didn’t work. And now you say you need to copy it to the folder of your C program or otherwise it will not work. Can you give a more detailed description of your problem?

@kayahr: thanks for reply. I did not say i need to copy it to the C program folder. I said I need to install it to the C program folder. Copy and install are different. Just like in Windows, you install MS Office to Programs folder, you do not simply copy MS Office file to Programs folder. That is what I mean.

Can you describe what files are expected after «installation»? Do you need the libusb.so and usb.h file in the root of your C program folder? Or must it be installed into «lib» and «include» sub directories? Or any other directory structure?

@kayahr: thanks for trying to help me. I actually solved my problem today. I just extract the libusb.zip file and change the directory of #include in my C program to the extracted folder.

Источник

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