Cannot build package due to missing GCC headers in Buildroot (stdio.h) - gcc

Recently, I updated the Buildroot directory from 2019.11 to 2022.2 in order to build for a new board (RPi4B Rev1.5) and access the updated Linux kernel and headers. Unfortunately, I have been unable to build due to missing headers for the SWUpdate package.
An extract of the error is below. The full log can be found at this link (as it is long).
CC tools/swupdate-client.o
ipc/network_ipc-if.c:8:10: fatal error: stdio.h: No such file or directory
8 | #include <stdio.h>
| ^~~~~~~~~
ipc/network_ipc.c:9:10: fatal error: stdio.h: No such file or directory
9 | #include <stdio.h>
| ^~~~~~~~~
compilation terminated.
In file included from /home/haelyons/project_folder/buildroot/output/host/lib/gcc/arm-
buildroot-linux-gnueabihf/10.3.0/include-fixed/syslimits.h:7,
from /home/haelyons/project_folder/buildroot/output/host/lib/gcc/arm-buildroot-
linux-gnueabihf/10.3.0/include-fixed/limits.h:34,
from parser/parse_external.c:10:
/home/haelyons/project_folder/buildroot/output/host/lib/gcc/arm-buildroot-linux-
gnueabihf/10.3.0/include-fixed/limits.h:195:15: fatal error: limits.h: No such file or
directory
Essentially, as this is a package included with Buildroot, I am not sure if the issue is with my installation of GCC, or with the package itself referencing the incorrect folder. If possible, I would greatly appreciate some pointers in the right direction such as more tests that I could perform to diagnose this. Thanks, H.

After more research, it turns out this was an issue with the configuration path assigned within the Buildroot config. It was referring to the RPi3 configuration, which required a different kernel and GCC version. The fix involved the following:
make nconfig
# Navigate to: Target Packages > System Tools > SWUpdate Config Path
# Update the patch to the new board's config - BR2_EXTERNAL=<path>
make -C savedefconfig BR2_DEFCONFIG=../<config path>

Related

How do I correctly set up WXWidgets on Ubuntu? My editor tells me the header files are incorrect

I wanted to try out the WXWidgets Hello World example (https://docs.wxwidgets.org/latest/overview_helloworld.html) so I followed the recommended practice on the Downloads page and installed the WXGTK package for my distribution, Ubuntu, which appears to be libwxgtk3.0-gtk3-dev. After doing this, and copying the example code, g++ (installed from build-essentials) throws an error when I attempt to compile the program:
wxtest.cpp:4:10: fatal error: wx/wxprec.h: No such file or directory
4 | #include <wx/wxprec.h>
| ^~~~~~~~~~~~~
compilation terminated.
My editor (VSCode) also shows me an error: cannot open source file "wx/wxprec.h".
This appears to be related to the fact that the WXWidgets header files are installed to the folder wx-3.0/wx instead of wx, but after changing #include <wx/wxprec.h> to #include <wx-3.0/wx/wxprec.h> I still get an error:
In file included from wxtest.cpp:4:
/usr/include/wx-3.0/wx/wxprec.h:12:10: fatal error: wx/defs.h: No such file or directory
12 | #include "wx/defs.h"
| ^~~~~~~~~~~
compilation terminated.
What am I doing wrong? How can these files be put in the right place?
See the building your project section of the docs.

Yocto SDK Kernel Source make scripts fails

I am trying to compile my kernel module using the Yocto SDK I generated via bitbake.
The SDK builds without issue, but when I try to run make scripts ARCH=arm64 in the kernel source directory of my target's sysroot, I get an issue regarding a missing header file:
...
HOSTCC scripts/conmakehash
HOSTCC scripts/sortextable
HOSTCC scripts/asn1_compiler
HOSTCC scripts/extract-cert
scripts/extract-cert.c:21:10: fatal error: openssl/bio.h: No such file or directory
21 | #include <openssl/bio.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [scripts/Makefile.host:107: scripts/extract-cert] Error 1
make: *** [Makefile:1096: scripts] Error 2
I have TOOLCHAIN_TARGET_TASK_append = " kernel-devsrc openssl-dev alsa-dev" in my image .bb file, which I believe should provide the missing openssl/bio.h file, but this does not seem to be the case.
The only way I have been able to solve this issue is to install libssl-dev on my SDK machine, but this feels like a workaround, and not the proper solution. My expectation is that when you source the environment from the SDK, it should provide the necessary headers for the kernel.
Since scripts/extract-cert.c is compiled for the host environment, I'd rather try appending TOOLCHAIN_HOST_TASK variable with " openssl-dev ".
See this question: TOOLCHAIN_HOST_TASK Vs TOOLCHAIN_TARGET_TASK

"'glib.h' file not found" when I make source project in mac OS

I created MakeFile using Autoconf. When I run "make" in my source project, errors like below occur. But glib is installed. Does anyone have a solution to this problem? I'm using thrift library in my project.
/usr/local/include/thrift/c_glib/thrift.h:27:10: fatal error: 'glib.h' file not found
#include <glib.h>
^~~~~~~~
1 error generated.
I tried this command but it didn't fix this problem.
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

Bazel failed to include a external static library .a

-- Question solved --
This question is solved. Thanks for all the help!
The problem and the reason is briefly stated as following for other readers in the future:
[Environment]
Ubuntu 14.04, Bazel, C++
[Question]
I want to include an external library. So I download the source file and make it as as a static lib .a.
I correctly set the BUILD, WORKSPACE and related files. However, when compile, it alerts the error:
Linking of rule '//main' failed (Exit 1)
main: error: undefined reference to 'void ex_lib::compute(double*, double const*, double const*)'
collect2: error: ld returned 1 exit status
I tried with the .lo and alwayslink method here but doesn't work.
Alternate to "`--whole-archive`" in bazel
[Reason]
It is because that the external library source files contains duplicate header files. So I fix the header file problem. Make the .a again. Then everything works.
So nothing wrong with the bazel. It is the library itself that cause the problem. But the error information is confusing and I think it is caused by bazel.
What you can do to investigate further is to run the clean bazel build with --subcommands to see individual command lines of actions executed. Then you can cd into the sandbox, and execute the same gcc command as bazel does and debug what's wrong. Or you can try to get linking to work by handwriting gcc command, and pasting here both the command bazel generated, and your desired command. Is it possible that you have multiple liegroups libs installed on the system and gcc is getting one that's incompatible with headers you're including?
The problem is solved. Special thanks to mhlopko.
It is mainly because there is errors with the lib source file. Thus .a file I use contains errors. Now the bazel works fine with the new lib file.
By the way, now bazel works fine with both .a or .so file that I generated.

cross-compiling with gcc, got storage size of ... isn't known error when it is defined in an include file under sysroot

I have a question very simliar to Cross compiler default include path setup but there wasn't the answer I was looking for.
I built a cross-compiler for openrisc. I have it in ~/openrisck/toolchain/
under there, I have bin(or32-linux-* excutables are here), include, lib, lib64, libexec, or32-linux, share.
under or32-linux, I have bin, include, lib, sys-root.
When I build busybox, I gave CONFIG_CROSS_COMPILER_PREFIX as "or32-linux-".
and CONFIG_SYSROOT as "$SYSROOT" which is ~/openrisk/toolchain/or32-linux/sys-root.
then I run 'make install' in buxybox source. Since the path includes the cross-compiler directory, it compiles for or32-linux-. But I have an error below
ckim : srctree = /home/ckim/openrisc/busybox
CC applets/applets.o
In file included from /home/ckim/openrisc/toolchain/bin/../lib/gcc/or32-linux/4.5.1-or32-1.0rc1/include-fixed/syslimits.h:7:0,
from /home/ckim/openrisc/toolchain/bin/../lib/gcc/or32-linux/4.5.1-or32-1.0rc1/include-fixed/limits.h:34,
from include/platform.h:141,
from include/libbb.h:13,
from include/busybox.h:8,
from applets/applets.c:9:
/home/ckim/openrisc/toolchain/bin/../lib/gcc/or32-linux/4.5.1-or32-1.0rc1/include-fixed/limits.h:169:61: fatal error: limits.h: No such file or directory
compilation terminated.
make[1]: *** [applets/applets.o] Error 1
make: *** [applets_dir] Error 2
which makes me thinks that Ah! the cross-compiler uses the include path relative to the executable. (see above bin/../lib/gcc/or32-linux/version/include-fixed)
So the include limits.h goes to the gcc's limits.h correctly. The last file syslimits.h has #include_next when the limits.h file have already been included. and the compiler complains that the file cannot be found.
Can somebody tell me how to solve this problem? (limits.h includes syslimits.h and syslimits.h includes limits.h .. )
EDIT : I ran 'make CROSS_COMPILE=or32-linux- CONFIG_PREFIX=$SYSROOT install'
then I got 'lutimes undeclared in coreutil/touch.c' error. Assuming the limit.h problem is gone, this means I should give these command line arguments because CROSS_COMPILE for make is different from CONFIG_CROSS_COMPILER_PREFIX in busybox configuration and make's CONFIG_PREFIX is different from CONFIG_SYSROOT for busybox configuration. so to remove the lutimes error, I ran 'make menuconfig' and removed CONFIG_TOUCH. Then I reran the make(make CROSS_COMPILE=or32-linux- CONFIG_PREFIX=$SYSROOT install), and this time got
procps/free.c: In function 'free_main':
procps/free.c:51:17: error: storage size of 'info' isn't known
procps/free.c:77:2: warning: implicit declaration of function 'sysinfo'
I found that in $SYSROOT/usr/include/sys/sysinfo.h, struct sysinfo is defined. I don't know why it says it's not defined. Any help would be deeply appreciated. Thanks!
For anyone who might be facing the same problem I had..
I tried about 3 times with the old toolchain but failed.
Yesterday, I got help from IRC (openrisc) and someone told me there is an updated toolchain for or1k. (not or32 which is old. I should have read the opencore page first..)
The page is
http://opencores.org/or1k/OpenRISC_GNU_tool_chain#Linux_.28uClibc.29_toolchain_.28or1k-linux-uclibc.29 (read from Linux (uClibc) toolchain (or1k-linux-uclibc))

Resources