0

需要您的指导,我正在借助本机代码在 android 中编写一个应用程序,它将与 CAN(控制器局域网)端口进行通信;为此,在我的 C 代码中,我使用了 linux/can.h 头文件。我正在关注“http://mobilepearls.com/labs/ndk-builder-in-eclipse/”这个链接来构建我的应用程序。但是我在eclipse控制台框中设置了我得到的所有东西

Compile thumb : can_port <= cansend.c
jni/cansend.c:14:23: fatal error: linux/can.h: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi/objs/can_port/cansend.o] Error 1

还有一件事,我正在研究windows环境。但我不认为这可能是原因。

4

1 回答 1

2

It is correct that it is not a Windows/Linux problem. The simple problem is that compiler is unable to find the file can.h. Now, for your info, when the compiler starts compiling, it searches for its header files in the folder

C:\(path to NDK folder)\platforms\(android-version)\(arch)\usr\include\linux

Now, if there isn't a can.h there, the compiler will flag an error. So the best way is

  1. Either copy can.h to the above path (not tested)
  2. Modify your Makefile to path to the correct directory where this header file is kept

Hope this helps!

于 2012-10-10T05:59:14.433 回答