arm-none-eabi-gcc can not find header files

Asked by wufucious

Hello, every one. I am working on Ubuntu 14.04. I am porting the ccn-lite(http://www.ccn-lite.net/) to Contiki-OS (http://www.contiki-os.org/). I can use normal gcc to compile and install ccn-lite in my Ubunt.

Then I need arm-none-eabi-gcc to compile the ccn-lite. However, I get this problem:
user@instant-contiki:~/contiki-myTest/examples/cc26xx$ make cc26xx-demo.binusing saved target 'srf06-cc26xx'
mkdir obj_srf06-cc26xx
  CC ../../apps/ccn-lite/ccn-lite-relay.c
In file included from /usr/arm-none-eabi/include/dirent.h:6:0,
                 from ../../apps/ccn-lite/ccn-lite-relay.c:23:
/usr/arm-none-eabi/include/sys/dirent.h:10:2: error: #error "<dirent.h> not supported"
 #error "<dirent.h> not supported"
  ^
In file included from ../../apps/ccn-lite/ccn-lite-relay.c:25:0:
/usr/arm-none-eabi/include/regex.h:43:9: error: unknown type name 'off_t'
 typedef off_t regoff_t;
         ^
In file included from ../../apps/ccn-lite/ccn-lite-relay.c:58:0:
../../apps/ccn-lite/ccnl-os-includes.h:40:24: fatal error: sys/ioctl.h: No such file or directory
 # include <sys/ioctl.h>
                        ^
compilation terminated.

When I try to locate where ioctl.h and dirent.h, I get such results

user@instant-contiki:~$ sudo find / -name "dirent.h"
[sudo] password for user:
/usr/local/lib/cc65/include/dirent.h
/usr/src/linux-headers-3.13.0-74/include/linux/dirent.h
/usr/src/linux-headers-3.13.0-62/include/linux/dirent.h
/usr/src/linux-headers-3.13.0-62-generic/include/linux/dirent.h
/usr/src/linux-headers-3.13.0-74-generic/include/linux/dirent.h
/usr/lib/syslinux/com32/include/sys/dirent.h
/usr/lib/syslinux/com32/include/dirent.h
/usr/arm-none-eabi/include/sys/dirent.h
/usr/arm-none-eabi/include/dirent.h
/usr/include/dirent.h
/usr/include/i386-linux-gnu/bits/dirent.h
user@instant-contiki:~$ sudo find / -name "icotl.h"
user@instant-contiki:~$ sudo find / -name "ioctl.h"
/usr/src/linux-headers-3.13.0-74/arch/mips/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/score/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/mn10300/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/s390/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/ia64/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/microblaze/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/m32r/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/alpha/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/frv/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/powerpc/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/x86/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/parisc/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/sparc/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/arch/cris/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-74/include/uapi/asm-generic/ioctl.h
/usr/src/linux-headers-3.13.0-74/include/uapi/linux/hdlc/ioctl.h
/usr/src/linux-headers-3.13.0-74/include/uapi/linux/mmc/ioctl.h
/usr/src/linux-headers-3.13.0-74/include/uapi/linux/ioctl.h
/usr/src/linux-headers-3.13.0-74/include/asm-generic/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/mips/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/score/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/mn10300/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/s390/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/ia64/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/microblaze/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/m32r/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/alpha/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/frv/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/powerpc/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/x86/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/parisc/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/sparc/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/arch/cris/include/uapi/asm/ioctl.h
/usr/src/linux-headers-3.13.0-62/include/uapi/asm-generic/ioctl.h
/usr/src/linux-headers-3.13.0-62/include/uapi/linux/hdlc/ioctl.h
/usr/src/linux-headers-3.13.0-62/include/uapi/linux/mmc/ioctl.h
/usr/src/linux-headers-3.13.0-62/include/uapi/linux/ioctl.h
/usr/src/linux-headers-3.13.0-62/include/asm-generic/ioctl.h
/usr/include/i386-linux-gnu/asm/ioctl.h
/usr/include/i386-linux-gnu/sys/ioctl.h
/usr/include/asm-generic/ioctl.h
/usr/include/linux/hdlc/ioctl.hRF Digital's Simblee makes it possible for device developers to embed mobile apps in the devices themselves, passing interface information over Bluetooth Low Energy (BLE) to a generic framework.

/usr/include/linux/mmc/ioctl.h
/usr/include/linux/ioctl.h

I find the compiler use the /usr/arm-none-eabi/include/sys/dirent.h and its content is as follows:
/* <dirent.h> includes <sys/dirent.h>, which is this file. On a
   system which supports <dirent.h>, this file is overridden by
   dirent.h in the libc/sys/.../sys directory. On a system which does
   not support <dirent.h>, we will get this file which uses #error to force
   an error. */

#ifdef __cplusplus
extern "C" {
#endif
#error "<dirent.h> not supported"
#ifdef __cplusplus
}
#endif

So the compilation stop. I think the arm compiler should use the dirent.h from the system just as normal gcc does. But obviously it didnt. Why? How to fix it? Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Andre Vieira
Solved:
Last query:
Last reply:
Revision history for this message
Best Andre Vieira (andre-simoesdiasvieira) said :
#1

Hi Wufucius,

So if I understand correctly you are trying to compile cnn-lite for some ARM device running Contiki-OS. First let me point out that this toolchain is meant for bare-metal development and not for compiling binaries to run on top of an OS.

Having said that, if you look at your problem the dirent.h you are supposed to use is the one for the target you want to compile cnn-lite for, i.e. whatever system header files are used for contiki-OS for your device, and __NOT__ the Ubuntu i386 system headers.

Once you have located your target's system header files you can direct gcc to them by using its '-I<dir>' option, see 'man gcc'.

Hope this helps.

Cheers,
Andre

Revision history for this message
wufucious (wonderfulwyqi9300) said :
#2

For Contiki, the app is compiled together with the OS. So using arm-none is fine.
Thanks very for your help.

Revision history for this message
wufucious (wonderfulwyqi9300) said :
#3

Thanks Andre Vieira, that solved my question.

Revision history for this message
Kiran (kirannd1989) said :
#4

Hi.,
I am facing same problem briefed here, in cross compiling OpenCV code in arm platform for RTOS.
I tried adding the dirent.h include path in cmake file, 'm a newbie in linux could not figure out much

Adding more details :

Ubuntu : 16.04
Compiler : gcc-arm-none-eabi-4_9-2015q3

In file included from /home/ti/VISION_SDK_02_12_00_00/ti_components/cg_tools/linux/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/dirent.h:6:0,
                 from /home/ti/opencv/tiopencv/modules/core/src/glob.cpp:134:
/home/ti/VISION_SDK_02_12_00_00/ti_components/cg_tools/linux/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/sys/dirent.h:10:2: error: #error "<dirent.h> not supported"
 #error "<dirent.h> not supported"
  ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:140:43: error: 'DIR' has not been declared
 static bool isDir(const cv::String& path, DIR* dir)
                                           ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp: In function 'void glob_rec(const cv::String&, const cv::String&, std::vector<cv::String>&, bool)':
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:222:5: error: 'DIR' was not declared in this scope
     DIR *dir;
     ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:222:10: error: 'dir' was not declared in this scope
     DIR *dir;
          ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:225:42: error: 'opendir' was not declared in this scope
     if ((dir = opendir (directory.c_str())) != 0)
                                          ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:230:39: error: 'readdir' was not declared in this scope
             while ((ent = readdir (dir)) != 0)
                                       ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:232:39: error: invalid use of incomplete type 'struct glob_rec(const cv::String&, const cv::String&, std::vector<cv::String>&, bool)::dirent'
                 const char* name = ent->d_name;
                                       ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:223:12: error: forward declaration of 'struct glob_rec(const cv::String&, const cv::String&, std::vector<cv::String>&, bool)::dirent'
     struct dirent *ent;
            ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:252:25: error: 'closedir' was not declared in this scope
             closedir(dir);
                         ^
/home/ti/opencv/tiopencv/modules/core/src/glob.cpp:255:21: error: 'closedir' was not declared in this scope
         closedir(dir);

Any inputs to make some progress to solve this would be appreciated.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#5

Hi Kiran,

I would expect that to have a file system you'd need an OS to provide that service. This toolchain is for bare-metal systems, ie. systems without an OS so it makes sense to me not to support file-related APIs. You will need to build a toolchain targeted at the OS you want to deploy your application on (eg. RTEMS, Linux, ...).

Best regards.