Linux 致命错误:libudev.h:没有那个文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17808084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:20:55  来源:igfitidea点击:

fatal error: libudev.h: No such file or directory

linuxlinux-device-driver

提问by WWJ

I compile with g++/gcc on ubuntu12.04 and it is "OK" but I cannot cross compile using raspberry pi tools master

我在 ubuntu12.04 上用 g++/gcc 编译,它“OK”,但我不能使用 raspberry pi tools master 进行交叉编译

toolsmaster 
CC := /home/Desktop/Simple_Linux_Driver/tools-master/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-g++
GCC := /home/Desktop/Simple_Linux_Driver/tools-master/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-gcc

I had install the following item:

我已经安装了以下项目:

-sudo apt-get install libusb-1.0-0-dev
-sudo apt-get install libudev-dev

raspberry pi kernel version 3.2.27 (izzit I need to enable "how" and rebuilt again)?

树莓派内核版本 3.2.27(我需要启用“如何”并再次重建)?

采纳答案by WWJ

Its works!!! i need to cross compile and cp .h .so inside raspberry pi cross toolsmaster Below is what i try: Do let me know if i miss out anythings Thanks^^ download libusb latest version tar file.

其作品!!!我需要在 raspberry pi cross toolsmaster 中交叉编译和 cp .h .so 下面是我尝试的:如果我错过了什么,请告诉我谢谢^^ 下载 libusb 最新版本的 tar 文件。

version 1.0.8

版本 1.0.8

$ TOOLCHAIN=/opt/FriendlyArm/toolchain/4.4.3/arm-none-linux-gnueabi
$ PATH=$PATH:$TOOLCHAIN/bin
$ CC='arm-none-linux-gnueabi-gcc -march=armv4t -mtune=arm920t'
$ CROSS_COMPILE=arm-none-linux-gnueabi-
$ export CC CROSS_COMPILE
$ tar xfv libusb-1.0.8.tar
$ cd libusb-1.0.8
$ ./configure --host arm-linux
$ make
$ cd libusb
$ cp libusb.h $TOOLCHAIN/arm-none-linux-gnueabi/include/
$ cp libusb.h $TOOLCHAIN/arm-none-linux-gnueabi/sysroot/include/
$ cp .libs/libusb-1.0.so $TOOLCHAIN/arm-none-linux-gnueabi/lib/
$ cp .libs/libusb-1.0.so $TOOLCHAIN/arm-none-linux-gnueabi/sysroot/lib/

THE TOOLCHAIN IS SET. for writing programs: add #include to use he library. compile using following:

工具链已设置。用于编写程序:添加 #include 以使用他的库。使用以下编译:

$arm-linux-g++ myprog.cpp -o myapp -lusb-1.0

NOTE: DON'T MISSOUT ON "-lusb-1.0"

注意:不要错过“-lusb-1.0”

回答by vinay hunachyal

If you do above it will install libraries that is for x86. The above libraries should be in raspberry cross-tool chain. if its not present then you need cross-compile it for arm architecture. Then you have to export it by follwing cmd

如果您这样做,它将安装适用于 x86 的库。上述库应该在树莓跨工具链中。如果它不存在,那么你需要为 arm 架构交叉编译它。然后你必须通过以下cmd导出它

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path to library

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path to library

First export the tools using exportcommand.

首先使用export命令导出工具。

export PATH=$PATH:/path to tool chain

export PATH=$PATH:/path to tool chain

Before doing above 1st try the following

在做上述第一次之前尝试以下

e.g export PATH=$PATH:/home/Desktop/Simple_Linux_Driver/tools-master/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/

例如 export PATH=$PATH:/home/Desktop/Simple_Linux_Driver/tools-master/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/

if you want to export it everytime in every terminal then .

如果您想每次都在每个终端中导出它,那么 .

vi .bashrc

vi .bashrc

At the end of file just add below command .

在文件末尾添加下面的命令。

export PATH=/path to tool chain bin:$PATH

export PATH=/path to tool chain bin:$PATH

e.g export PATH=/opt/Arm_tool_chain/bin:$PATH

例如 export PATH=/opt/Arm_tool_chain/bin:$PATH