Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cstddef: No such file or directory #3725

Closed
Darker opened this issue Feb 8, 2017 · 18 comments
Closed

cstddef: No such file or directory #3725

Darker opened this issue Feb 8, 2017 · 18 comments

Comments

@Darker
Copy link

Darker commented Feb 8, 2017

Description

  • Type: Question

mbed-os/platform/platform.h:22:19: fatal error: cstddef: No such file or directory

I cloned this repository and tried to compile this program:

/**
 * Nucleo program that does not do anything. Test of basic compilation. 
**/

#include <mbed.h>
void main()
{

}

With this command:

arm-none-eabi-gcc main.c --specs=nosys.specs -I../../software/mbed-os/

Where ../../software/mbed-os/ is path to the root of this repository. The error I get:

In file included from ../../software/mbed-os/mbed.h:51:0,
                 from main.c:5:
../../software/mbed-os/platform/platform.h:22:19: fatal error: cstddef: No such file or directory
compilation terminated.

The version of my compiler:

>arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 5.4.1 20160919 (release) [ARM/embedded-5-branch revision 240496]

I'm running this all on Windws 7 x64 and Debian 8 Jessiex64 with same result. I found some vague mentions of something called private_settings.py in some forum threads, but nobody really bothered to explain what is that supposed to do.

@theotherjimmy
Copy link
Contributor

@Darker We have a hal that includes code and header files for many targets, and many features in the code that can be turned on and off. Further, we have a few more arguments to gcc than just --specs=nosys.specs. As such we have a bunch of tools that run the compiler for us. Please use the pip package mbed-cli to compile.

Further, we use GCC version 4.9.3.

Finally, it looks like you are missing system header files. But I'm not sure this is even the real problem here. Could you try changing your GCC version and using mbed-cli first?

@toyowata
Copy link
Contributor

toyowata commented Feb 9, 2017

@Darker The cstddef is C++ header file. Can you rename your source file from main.c to main.cpp?

@ghost
Copy link

ghost commented Oct 27, 2017

GitHib issue review: Closed due to inactivity. Please re-file if critical issues found.

@ghost ghost closed this as completed Oct 27, 2017
@bkht
Copy link

bkht commented Jan 11, 2018

Hi, I do have this problem:

$ mbed new mbed-os-program
$ cd mbed-os-program
$ mbed compile -t GCC_ARM -m NUCLEO_F746ZG -v
[Fatal Error] platform.h@22,19: cstddef: No such file or directory

$ sudo mbed config --list
[mbed] Global config:
GCC_ARM_PATH=/usr/bin
ARM_PATH=/home/jack/apps/gcc-arm-none-eabi-7-2017-q4-major

[mbed] Local config (/home/jack/mbed/mbed-os-program):
No local configuration is set

cstddef: No such file or directory
How can I solve this?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 12, 2018

GCC_ARM_PATH=/usr/bin

what gcc is there ? the ARM path points to gcc (use GCC 6 as that one is supported). T hus I would fix GCC_ARM_PATH to point to GCC ARM 6 version

@bkht
Copy link

bkht commented Jan 12, 2018

Hi, thank you very much for helping me!
I now have
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
So, I need to install arm-none-eabi-gcc v6 better?

I looking where to download v6.... and update once I know...

@pan-
Copy link
Member

pan- commented Jan 12, 2018

@bkht what type of file triggers the error ? C or C++ ?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 12, 2018

On
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
Only version 7 is listed...
Where can I get v6?

scroll down more, 6 is there

@bkht
Copy link

bkht commented Jan 12, 2018

Many thanks!!!

@bkht
Copy link

bkht commented Jan 12, 2018

Hi, I just installed gcc 6.3.1

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437]

$ sudo mbed config -G ARM_PATH "/home/jack/apps/gcc-arm-none-eabi-6-2017-q2-update-linux"
$ sudo cp /home/jack/apps/gcc-arm-none-eabi-6-2017-q2-update-linux/bin/arm-none-eabi-gcc /usr/bin/.
$ sudo mbed config -G GCC_ARM_PATH "/usr/bin"

$ arm-none-eabi-gcc --version
6.3.1

$ sudo mbed config --list
[mbed] Global config:
GCC_ARM_PATH=/usr/bin
ARM_PATH=/home/jack/apps/gcc-arm-none-eabi-6_2-2016q4

[mbed] Local config (/home/jack/mbed/mbed-os-program):
TOOLCHAIN=GCC_ARM
TARGET=NUCLEO_F746ZG

But the result is the same:

$ mbed compile -v
[Fatal Error] platform.h@22,19: cstddef: No such file or directory

I also tried 6.2.1
What else can I verify to correct the problem?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 12, 2018

@bkht what type of file triggers the error ? C or C++ ?

If you can answer this question, where is the error coming from (not only what header file).

@bkht
Copy link

bkht commented Jan 12, 2018

Hi, this is the complete output, hope that helps (unfortunately, it's not clear to me):

$ mbed-cli --version
1.2.2
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437]
$ mbed new mbed-os-program
$ cd mbed-os-program
$ mbed toolchain GCC_ARM
$ mbed target NUCLEO_F746ZG
$ mbed compile -v
[mbed] Working path "/home/jack/mbed/mbed-os-program" (program)

[mbed] Exec "/usr/bin/python -u /home/jack/mbed/mbed-os-program/mbed-os/tools/make.py -t GCC_ARM -m NUCLEO_F746ZG --source . --build ./BUILD/NUCLEO_F746ZG/GCC_ARM -v" in /home/jack/mbed/mbed-os-program
Building project mbed-os-program (NUCLEO_F746ZG, GCC_ARM)
Scan: .
Scan: env
Scan: mbed
Scan: FEATURE_LWIP
[DEBUG] Macros: -DTARGET_STM32F746xG -DFEATURE_LWIP=1 -D__MBED__=1 -DDEVICE_I2CSLAVE=1 -D__FPU_PRESENT=1 -DDEVICE_PORTOUT=1 -DUSBHOST_OTHER -DDEVICE_PORTINOUT=1 -D__MBED_CMSIS_RTOS_CM -DDEVICE_LOWPOWERTIMER=1 -DTARGET_STM32F7 -DTOOLCHAIN_object -DDEVICE_SERIAL_ASYNCH=1 -D__CMSIS_RTOS -DDEVICE_ANALOGOUT=1 -DTARGET_STM32F746ZG -DTOOLCHAIN_GCC -DDEVICE_CAN=1 -DARM_MATH_CM7 -DTARGET_CORTEX_M -DTARGET_LIKE_CORTEX_M7 -DDEVICE_RTC=1 -DDEVICE_TRNG=1 -DTARGET_UVISOR_UNSUPPORTED -DTARGET_M7 -DDEVICE_SPI_ASYNCH=1 -DDEVICE_PWMOUT=1 -DDEVICE_INTERRUPTIN=1 -DTARGET_CORTEX -DDEVICE_I2C=1 -DTRANSACTION_QUEUE_SIZE_SPI=2 -DDEVICE_STDIO_MESSAGES=1 -D__CORTEX_M7 -DTARGET_STM32F746 -DTARGET_FAMILY_STM32 -DTARGET_FF_ARDUINO -DDEVICE_PORTIN=1 -DTARGET_RELEASE -DTARGET_STM -DTARGET_NUCLEO_F746ZG -DTARGET_LIKE_MBED -DTARGET_RTOS_M4_M7 -DDEVICE_SLEEP=1 -DTOOLCHAIN_GCC_ARM -DDEVICE_SPI=1 -DMBED_BUILD_TIMESTAMP=1515771245.08 -DDEVICE_SPISLAVE=1 -DDEVICE_ANALOGIN=1 -DDEVICE_SERIAL=1 -DDEVICE_FLASH=1 -DDEVICE_I2C_ASYNCH=1
Compile [  0.5%]: AnalogIn.cpp
[DEBUG] Compile: /usr/bin/arm-none-eabi-g++ -std=gnu++98 -fno-rtti -Wvla -c -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections -funsigned-char -MMD -fno-delete-null-pointer-checks -fomit-frame-pointer -Os -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=softfp -DTARGET_STM32F746xG -DFEATURE_LWIP=1 -D__MBED__=1 -DDEVICE_I2CSLAVE=1 -D__FPU_PRESENT=1 -DDEVICE_PORTOUT=1 -DUSBHOST_OTHER -DDEVICE_PORTINOUT=1 -D__MBED_CMSIS_RTOS_CM -DDEVICE_LOWPOWERTIMER=1 -DTARGET_STM32F7 -DTOOLCHAIN_object -DDEVICE_SERIAL_ASYNCH=1 -D__CMSIS_RTOS -DDEVICE_ANALOGOUT=1 -DTARGET_STM32F746ZG -DTOOLCHAIN_GCC -DDEVICE_CAN=1 -DARM_MATH_CM7 -DTARGET_CORTEX_M -DTARGET_LIKE_CORTEX_M7 -DDEVICE_RTC=1 -DDEVICE_TRNG=1 -DTARGET_UVISOR_UNSUPPORTED -DTARGET_M7 -DDEVICE_SPI_ASYNCH=1 -DDEVICE_PWMOUT=1 -DDEVICE_INTERRUPTIN=1 -DTARGET_CORTEX -DDEVICE_I2C=1 -DTRANSACTION_QUEUE_SIZE_SPI=2 -DDEVICE_STDIO_MESSAGES=1 -D__CORTEX_M7 -DTARGET_STM32F746 -DTARGET_FAMILY_STM32 -DTARGET_FF_ARDUINO -DDEVICE_PORTIN=1 -DTARGET_RELEASE -DTARGET_STM -DTARGET_NUCLEO_F746ZG -DTARGET_LIKE_MBED -DTARGET_RTOS_M4_M7 -DDEVICE_SLEEP=1 -DTOOLCHAIN_GCC_ARM -DDEVICE_SPI=1 -DMBED_BUILD_TIMESTAMP=1515771245.08 -DDEVICE_SPISLAVE=1 -DDEVICE_ANALOGIN=1 -DDEVICE_SERIAL=1 -DDEVICE_FLASH=1 -DDEVICE_I2C_ASYNCH=1 @./BUILD/NUCLEO_F746ZG/GCC_ARM/.includes_5fa684d087529e8cf7d6ff863af0a169.txt -include ./BUILD/NUCLEO_F746ZG/GCC_ARM/mbed_config.h -MD -MF BUILD/NUCLEO_F746ZG/GCC_ARM/mbed-os/drivers/AnalogIn.d -o BUILD/NUCLEO_F746ZG/GCC_ARM/mbed-os/drivers/AnalogIn.o ./mbed-os/drivers/AnalogIn.cpp
[Fatal Error] platform.h@22,19: cstddef: No such file or directory
[DEBUG] Return: 1
[DEBUG] Output: In file included from ./mbed-os/drivers/AnalogIn.h:19:0,
[DEBUG] Output:                  from ./mbed-os/drivers/AnalogIn.cpp:17:
[DEBUG] Output: ./mbed-os/platform/platform.h:22:19: fatal error: cstddef: No such file or directory
[DEBUG] Output:  #include <cstddef>
[DEBUG] Output:                    ^
[DEBUG] Output: compilation terminated.
Traceback (most recent call last):
File "/home/jack/mbed/mbed-os-program/mbed-os/tools/make.py", line 296, in <module>
    stats_depth=options.stats_depth)
File "/home/jack/mbed/mbed-os-program/mbed-os/tools/build_api.py", line 533, in build_project
    objects = toolchain.compile_sources(resources, resources.inc_dirs)
File "/home/jack/mbed/mbed-os-program/mbed-os/tools/toolchains/__init__.py", line 928, in compile_sources
    return self.compile_queue(queue, objects)
File "/home/jack/mbed/mbed-os-program/mbed-os/tools/toolchains/__init__.py", line 991, in compile_queue
    raise ToolException(err)
ToolException: In file included from ./mbed-os/drivers/AnalogIn.h:19:0,
                from ./mbed-os/drivers/AnalogIn.cpp:17:
./mbed-os/platform/platform.h:22:19: fatal error: cstddef: No such file or directory
#include <cstddef>
                ^
compilation terminated.

[mbed] ERROR: "/usr/bin/python" returned error code 1.
[mbed] ERROR: Command "/usr/bin/python -u /home/jack/mbed/mbed-os-program/mbed-os/tools/make.py -t GCC_ARM -m NUCLEO_F746ZG --source . --build ./BUILD/NUCLEO_F746ZG/GCC_ARM -v" in "/home/jack/mbed/mbed-os-program"
---

@theotherjimmy
Copy link
Contributor

@bkht You may need arm-none-eabi-newlib or similar to get the c std lib.

@theotherjimmy theotherjimmy reopened this Jan 12, 2018
@bkht
Copy link

bkht commented Jan 13, 2018

I use Linux Mint 18.1
$ uname -a
Linux GS72 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
How do I install 'arm-none-eabi-newlib'? I searched, but no luck.

@pan-
Copy link
Member

pan- commented Jan 15, 2018

@bkht The following lines are suspicious:

$ sudo cp /home/jack/apps/gcc-arm-none-eabi-6-2017-q2-update-linux/bin/arm-none-eabi-gcc /usr/bin/.
$ sudo mbed config -G GCC_ARM_PATH "/usr/bin"

Why do you copy manually arm-none-eabi-gcc into /usr/bin/ ? A compiler is not just a binary, it come with a linker, headers files, object files, library files, ...

If you have extracted GCC in /home/jack/apps/gcc-arm-none-eabi-6-2017-q2-update-linux/ then you can set GCC_ARM_PATH to /home/jack/apps/gcc-arm-none-eabi-6-2017-q2-update-linux/bin:

sudo mbed config -G GCC_ARM_PATH "/home/jack/apps/gcc-arm-none-eabi-6-2017-q2-update-linux/bin"

@bkht
Copy link

bkht commented Jan 15, 2018

Thank you! That actually works better. I still have problems, but I will first try different versions of the compiler.

[DEBUG] Errors: BUILD/NUCLEO_F746ZG/GCC_ARM/mbed-os/rtos/TARGET_CORTEX/mbed_boot.o: In function `__wrap_main':
[DEBUG] Errors: mbed_boot.c:(.text.__wrap_main+0xa): undefined reference to `main'
[DEBUG] Errors: collect2: error: ld returned 1 exit status
Traceback (most recent call last):
  File "/home/jack/mbed/mbed-os-program/mbed-os/tools/make.py", line 296, in <module>
    stats_depth=options.stats_depth)
  File "/home/jack/mbed/mbed-os-program/mbed-os/tools/build_api.py", line 545, in build_project
    res, _ = toolchain.link_program(resources, build_path, name)
  File "/home/jack/mbed/mbed-os-program/mbed-os/tools/toolchains/__init__.py", line 1141, in link_program
    self.link(elf, r.objects, r.libraries, r.lib_dirs, r.linker_script)
  File "/home/jack/mbed/mbed-os-program/mbed-os/tools/hooks.py", line 34, in wrapper
    res = function(t_self, *args, **kwargs)
  File "/home/jack/mbed/mbed-os-program/mbed-os/tools/toolchains/gcc.py", line 240, in link
    self.default_cmd(cmd)
  File "/home/jack/mbed/mbed-os-program/mbed-os/tools/toolchains/__init__.py", line 1170, in default_cmd
    raise ToolException(_stderr)
ToolException: BUILD/NUCLEO_F746ZG/GCC_ARM/mbed-os/rtos/TARGET_CORTEX/mbed_boot.o: In function `__wrap_main':
mbed_boot.c:(.text.__wrap_main+0xa): undefined reference to `main'
collect2: error: ld returned 1 exit status

[mbed] ERROR: "/usr/bin/python" returned error code 1.
[mbed] ERROR: Command "/usr/bin/python -u /home/jack/mbed/mbed-os-program/mbed-os/tools/make.py -t GCC_ARM -m NUCLEO_F746ZG --source . --build ./BUILD/NUCLEO_F746ZG/GCC_ARM -v" in "/home/jack/mbed/mbed-os-program"
---

@pan-
Copy link
Member

pan- commented Jan 15, 2018

@bkht the main function is not defined by mbed OS; it shall be defined by your application. Add the following code in a file named main.cpp in the root or your project:

#include "mbed.h"

DigitalOut led1(LED1);

// main() runs in its own thread in the OS
int main() {
    while (true) {
        led1 = !led1;
        wait(0.5);
    }
}

This application should blink your board LED every 500ms.

@bkht
Copy link

bkht commented Jan 16, 2018

Thank you very much!, Now it all works!
I didn't even notice main.ccp was not in there, as I was trying to test my toolchain installation. :-)
Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants