- Remove From My Forums
-
Question
-
Hi,
I am getting below errors while building source code with Visual studio 2015 RC:
fatal error C1083: Cannot open include file: ‘stddef.h’: No such file or directory
fatal error C1083: Cannot open include file: ‘string.h’: No such file or directory
fatal error C1083: Cannot open include file: ‘ctype.h’: No such file or directory
I have installed Visual studio 2015 on my local drive, and did not find the above header files under «F:VS_2015VCinclude» installed path.
Can you please guide me from where do i need to include this files to my project?
Regards,
Amol Gaikwad.
Regards, Amol Gaikwad.
Answers
-
I am getting below errors while building source code with Visual studio 2015 RC:
fatal error C1083: Cannot open include file: ‘stddef.h’: No such file or directory
fatal error C1083: Cannot open include file: ‘string.h’: No such file or directory
fatal error C1083: Cannot open include file: ‘ctype.h’: No such file or directory
I have installed Visual studio 2015 on my local drive, and did not find the above header files under «F:VS_2015VCinclude» installed path.
Can you please guide me from where do i need to include this files to my project?
-
Proposed as answer by
Thursday, July 16, 2015 9:22 AM
-
Marked as answer by
AMOLNGAIKWAD
Thursday, July 16, 2015 9:51 AM
-
Proposed as answer by
| Author | Message | |||
|---|---|---|---|---|
|
Post subject: fatal error: stddef.h: No such file or directory
|
||||
|
Hi, I’m working through the UEFI App Bare Bones tutorial https://wiki.osdev.org/UEFI_Bare_Bones I’m at the first step. Developers will need a GCC Cross-Compiler targeting the x86_64-w64-mingw32 I managed to run make all-gcc without any errors but when running make all-target-libgcc I get the following error:
1 | #include_next <stddef.h> | ^~~~~~~~~~ compilation terminated. make[3]: *** [Makefile:498: _muldi3.o] Error 1 make[3]: Leaving directory ‘/home/yaakov/osdev/build-gcc-x86_64-w64-mingw32/x86_64-w64-mingw32/32/libgcc’ make[2]: *** [Makefile:1210: multi-do] Error 1 Is this something to do with the versions I am using? I am compiling gcc-9.3.0 My compiler version is gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 |
|||
| Top |
|
|||
|
Octocontrabass |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
Why are you building GCC instead of using Ubuntu’s prebuilt Mingw-w64 package or Clang? |
| Top |
|
|
Solar |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
…because our Wiki page says so? |
| Top |
|
|
jamesread |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
Octocontrabass wrote: Why are you building GCC instead of using Ubuntu’s prebuilt Mingw-w64 package or Clang? I’ve installed both packages as you suggested. How do I now invoke the use of the new gcc version and ld also? |
| Top |
|
|
nexos |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
For mingw, it is either x86_64-w64-mingw32-gcc or i686-w64-mingw32-gcc |
| Top |
|
|
jamesread |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
nexos wrote: For mingw, it is either x86_64-w64-mingw32-gcc or i686-w64-mingw32-gcc OK. Both of those are invocable from my CLI. Just as a side thought. Why do we need a mingw cross compiler? We are not compiling for windows. |
| Top |
|
|
nexos |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
EFI apps are Windows apps with a different subsystem. EFI firmware was very much influenced by MS, hence it uses the same ABI, executable format, function naming style, and so on as MS stuff. |
| Top |
|
|
bzt |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
Using a cross-compiler with GNU-EFI is generally a bad idea. The complexity demonstrated on that UEFI Bare Bones page showcases that well (uses some source files directly instead of a library for example). I’ve added an explanation and linked https://wiki.osdev.org/GNU-EFI page which describes the preferred way how GNU-EFI should be used. On the other hand I’ve also linked the UEFI Bare Bones page on the GNU-EFI page for those who insist to use a cross-compiler. Cheers, |
| Top |
|
|
jamesread |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
bzt wrote: Using a cross-compiler with GNU-EFI is generally a bad idea. The complexity demonstrated on that UEFI Bare Bones page showcases that well (uses some source files directly instead of a library for example). I’ve added an explanation and linked https://wiki.osdev.org/GNU-EFI page which describes the preferred way how GNU-EFI should be used. On the other hand I’ve also linked the UEFI Bare Bones page on the GNU-EFI page for those who insist to use a cross-compiler. Cheers, I have successfully (I think) followed the steps up to Code: objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc —target efi-app-x86_64 —subsystem=10 main.so main.efi Then I am bit confused as to what to do next. The tutorial says Quote: Now you can copy main.efi to your EFI System Partition, and after boot run it from the EFI Shell. Or you can rename it to EFIBOOTBOOTX64.EFI and it should be executed automatically on boot. I’m not sure what this means. Should I continue with the UEFI App Bare Bones from Quote: Creating the FAT image dd if=/dev/zero of=fat.img bs=1k count=1440 |
| Top |
|
|
bzt |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
jamesread wrote: Then I am bit confused as to what to do next. The tutorial says Quote: Now you can copy main.efi to your EFI System Partition, and after boot run it from the EFI Shell. Or you can rename it to EFIBOOTBOOTX64.EFI and it should be executed automatically on boot. I’m not sure what this means. Should I continue with the UEFI App Bare Bones from Creating the FAT image This only means you have to copy your compiled file (main.efi) to the ESP partition (as EFI/BOOT/BOOTX64.EFI) so that the UEFI firmware could find it in boot-time. You can follow that tutorial, follow the steps on wiki UEFI page, follow the Bootable Disk tutorial, or use an existing image and replace that one file as I wrote here. The point is, you have to copy your loader to the ESP somehow, but it doesn’t matter how you do it. Cheers, |
| Top |
|
|
Octocontrabass |
Post subject: Re: fatal error: stddef.h: No such file or directory
|
|
|
bzt wrote: Using a cross-compiler with GNU-EFI is generally a bad idea. The example on the wiki only uses GNU-EFI for its UEFI headers and doesn’t link against it or use its build system. It won’t work correctly if you follow the typical GNU-EFI build process anyway, since it doesn’t use InitializeLib() or uefi_call_wrapper(). |
| Top |
|
(Existing answers do not address this particular situation)
Currently the error message is:
In file included from /usr/include/stdio.h:33:0,
from pngquant.c:37:
/usr/src/linux-aws-headers-4.4.0-1075/include/linux/stddef.h:4:31: fatal error: uapi/linux/stddef.h: No such file or directory
Full Background
I am trying to compile pngquant from source and I am trying to put the output files to an alternative location.
pngquant has a dependency on libimagequant. Here is the way I build the code:
# Required dependency
apt-get install libpng16-dev
cd libimagequant-2.12.1
./configure --prefix=/usr/local/alt-location
make and sudo make install
Now it is pngquant‘s turn
cd pngquant-2.12.1
./configure --prefix=/usr/local/alt-location --with-libimagequant=/src/to/libimagequant
If I compile it on a ubuntu distribution, it will run to the end and a binary is generated.
$ make && sudo make install
make: Nothing to be done for 'all'.
mkdir -p '/usr/local/alt-location/bin'
mkdir -p '/usr/local/alt-location/share/man/man1'
install -m 0755 -p 'pngquant' '/usr/local/alt-location/bin/pngquant'
install -m 0644 -p 'pngquant.1' '/usr/local/alt-location/share/man/man1/'
Smoke test:
[10:20:13] sde:pngquant-2.12.1$ /usr/local/alt-location/bin/pngquant --version
2.12.0 (January 2018)
However if I repeat the same process on an AWS ec2 instance (with xenial) I got this error:
$ make
gcc -fno-math-errno -funroll-loops -fomit-frame-pointer -Wall -std=c99 -I. -O3 -DNDEBUG -DUSE_SSE=1 -msse -mfpmath=sse -Wno-unknown-pragmas -I/usr/local/alt-location/include -I/usr/include/libpng16 -I/usr/src/linux-aws-headers-4.4.0-1075/include/linux -fexcess-precision=fast -c -o pngquant.o pngquant.c
In file included from /usr/include/stdio.h:33:0,
from pngquant.c:37:
/usr/src/linux-aws-headers-4.4.0-1075/include/linux/stddef.h:4:31: fatal error: uapi/linux/stddef.h: No such file or directory
compilation terminated.
<builtin>: recipe for target 'pngquant.o' failed
make: *** [pngquant.o] Error 1
My question:
How can I fix this issue? Does it has anything to do with the fact that this linux version is actually customised by aws?
Edit
Trying to install missed header as suggested but it seems the headers are already installed.
sudo apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree
Reading state information... Done
linux-headers-4.4.0-1081-aws is already the newest version (4.4.0-1081.91).
linux-headers-4.4.0-1081-aws set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
Когда я включил библиотеку программного обеспечения, написанную на C, в существующий демонстрационный проект (использовала библиотеку С++ mbed), я столкнулся с этой проблемой. Демо-проект будет компилироваться просто отлично, но после того, как я заменил существующий основной файл самостоятельно, произошла эта ошибка.
В этот момент я еще не думал о том, что библиотека mbed, в которой я нуждалась, была написана на С++. Мой собственный основной файл был .c файлом, который #include mbed заголовочный файл. В результате я использовал свой обычный источник C, как если бы это был источник С++. Поэтому компилятором, который использовался для компиляции моего основного файла, был компилятор C.
Затем этот компилятор C встретил #include модуля который на самом деле не существует (в пределах его области действия), поскольку он не является компилятором С++.
Только после того, как я проверил вывод журнала построения, я понял, что различные исходные файлы C и С++ были скомпилированы более чем одним компилятором (компилятором С++). В проекте использовались компиляторы arm-none-eabi-С++ и arm-none-eabi-gcc (для встроенных систем), как показано ниже.
Скомпилировать журнал:
Building file: ../anyfile.cpp
Invoking: MCU C++ Compiler
arm-none-eabi-c++ <A lot of arguments> "../anyfile.cpp"
Finished building: ../anyfile.cpp
Building file: ../main.c
Invoking: MCU C Compiler
arm-none-eabi-gcc <A lot of arguments> "../main.c"
In file included from <Project directory>mbed/mbed.h:21:0,
from ../main.c:16:
<Project directory>mbed/platform.h:25:19: fatal error: cstddef: No such file or directory
compilation terminated.
Конечно, в среде С++ cstddef существует, но в среде C cstddef не существует, вместо того, чтобы просто реализовать C stddef.
Другими словами, cstddef не существует в компиляторе C.
Я решил эту проблему, переименовав файл main.c в main.cpp, а остальная часть кода тоже была скомпилирована.
TL;DR/Заключение. При создании проекта на С++ избегайте смешивания файлов C с файлами С++ (источники и заголовки). Если возможно, переименуйте файлы .c в файлы .cpp, чтобы использовать компилятор С++ вместо компилятора C, где это необходимо.

