Simple Make File Error - c

I am trying to create a simple make file and using it to build a simple c program. The environment is in virtual box using the newest version of ubuntu. I have already downloaded the linux headers for ubuntu but still getting the error.
Hello.c
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void) {
printk(KERN_ALERT "TEST: Hello world, this is soliducode\n");
return 0;
}
static void hello_exit(void) {
printk(KERN_ALERT "TEST: Good byte, from soliduscode");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile
obj-m += Hello.o
KDIR = /usr/src/linux-headers-4.2.0-16-generic
all:
$(MAKE) -C $(KDIR) SUBSIRS=$ modules
clean:
rm -rf *.o *.ko *.mod.* *.symvers *.order
Error
make -C /usr/src/linux-headers-4.2.0-16-generic SUBSIRS=modules
make[1]: Entering directory '/usr/src/linux-headers-4.2.0-16-generic'
arch/x86/Makefile:138: CONFIG_X86_X32 enabled but no binutils support
Makefile:669: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:462:1: fatal error: opening dependency file scripts/basic/.fixdep.d: Permission denied
}
^
compilation terminated.
scripts/Makefile.host:91: recipe for target 'scripts/basic/fixdep' failed
make[3]: *** [scripts/basic/fixdep] Error 1
Makefile:449: recipe for target 'scripts_basic' failed
make[2]: *** [scripts_basic] Error 2
make[2]: *** No rule to make target 'arch/x86/entry/syscalls/syscall_32.tbl', needed by 'arch/x86/entry/syscalls/../../include/generated/asm/syscalls_32.h'. Stop.
arch/x86/Makefile:184: recipe for target 'archheaders' failed
make[1]: *** [archheaders] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-16-generic'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2

It looks like your kernel config is invalid.
There is documentation how to build your own kernel on Ubuntu, e.g.
https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

Try using in M=${PWD} option in your Makefile.
Command:
make -C /lib/modules/`uname -r`/build M=${PWD} modules

#Manish Dharanenthiran solved the problem for me.
I was on this problem for about 2 days.
compiled a new kernel, download another one from https://www.kali.org/downloads/, and still got those errors.
To help with that kind of problem I suggest the path below -
first check the kernel you running on with
uname -r
check if you got your current kernel linux-headers inside /usr/src
ls -a /usr/src
if you don't, you need to install them but old version of linux-headers doesn't available by apt-get check if yours available in the list that received by
apt-cache search linux-headers
if your current version is there jump to 3.
if your current version doesn't available you need to: apt-get update & apt-get upgrade / install a newer machine / compile a new kernel
NOTICE - from my experience (I did them all) the update & upgrade is the fastest.
apt-get update
apt-get upgrade
reboot
When booting choose the new kernel in the grub menu
You can edit this file with bigger GRUB_TIMEOUT value if you can't see/catch the menu in boot time
Download the needed linux-headers
apt-get install linux-headers-$(uname -r)
If the problem didn't solve yet, try using in M=${PWD} instead of M=$(PWD) in your Makefile as mentioned by #Manish Dharanenthiran.

Related

"fatal error: bits/libc-header-start.h: No such file or directory" while compiling HTK

I'm getting the following issue when trying to run make on the HTK library:
(cd HTKLib && make HTKLib.a) \
|| case "" in *k*) fail=yes;; *) exit 1;; esac;
make[1]: Entering directory '/home/william/speech/htk/HTK-3.4.1/htk/HTKLib'
gcc -m32 -ansi -D_SVID_SOURCE -DOSS_AUDIO -D'ARCH="x86_64"' -Wall -Wno-switch -g -O2 -I. -DPHNALG -c -o HGraf.o HGraf.c
In file included from HShell.h:40:0,
from HGraf.c:54:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
#include <bits/libc-header-start.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
<builtin>: recipe for target 'HGraf.o' failed
make[1]: *** [HGraf.o] Error 1
make[1]: Leaving directory '/home/william/speech/htk/HTK-3.4.1/htk/HTKLib'
Makefile:96: recipe for target 'HTKLib/HTKLib.a' failed
make: *** [HTKLib/HTKLib.a] Error 1
I'm unsure what to do about this error. The libc-header-start.h file is present on my system:
$ find /usr -name libc-header-start.h
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h
Running gcc -H -fsyntax-only /usr/include/stdio.h appropriately returns
. /usr/include/x86_64-linux-gnu/bits/libc-header-start.h
.. /usr/include/features.h
... /usr/include/x86_64-linux-gnu/sys/cdefs.h
etc.
Also, compiling and running a sanity-check C file works fine (simply executing printf("hello!"); in its main method).
Apologies if this is a well-known error - my experience with C libraries stops at compiling and installing them using make.
UPDATE
Per the accepted answer below I executed sudo apt-get install gcc-multilib to install the missing 32 bit libraries.
Afterwards I got an error with a similar cause: "/usr/bin/ld: cannot find -lX11" error when installing htk. I resolved this by executing sudo apt-get install libx11-dev:i386 libx11-dev to retrieve the missing 32 bit library.
The -m32 is telling gcc to compile for a 32-bit platform. On a 64-bit machine, gcc normally only comes with 64-bit libraries. You have two options:
Install 32-bit headers and libraries. Here's how you'd do this on Ubuntu.
Run this command:
sudo apt-get install gcc-multilib
Compile for 64-bit instead. Modify this line in the file named configure:
CFLAGS="-m32 -ansi -D_SVID_SOURCE -DOSS_AUDIO -D'ARCH=\"$host_cpu\"' $CFLAGS"
Delete -m32, giving you:
CFLAGS="-ansi -D_SVID_SOURCE -DOSS_AUDIO -D'ARCH=\"$host_cpu\"' $CFLAGS"
Run ./configure, then make clean, then make
However, I would recommend against this approach. The library authors went out of their way to make this build for 32 bits on a 64 bit system, and I can't guarantee that it will work correctly if you do this. (It does compile, though.)
Below is one way to debug and fix this issue. Since most linux installations differ in one way or another, YMMV.
Find which package installed libc-header-start.h.
$ dpkg -S libc-header-start.h
libc6-dev:amd64: /usr/include/x86_64-linux-gnu/bits/libc-header-start.h
On a working system, /usr/include/bits is a symlink to /usr/include/x86_64-linux-gnu/bits. Running dpkg search gives us:
$ dpkg -S /usr/include/bits
libc6-dev-i386: /usr/include/bits
Installing libc6-dev-i386 creates the symlink and the error is addressed.
However, subsequently I ran into a linker error with the linker not being able to find libgcc (-lgcc). Apparently Linux default linker needs libgcc in most cases. Further debugging the issue with linker verbosity enabled lead me to missing lib32gcc-10-dev package.
In short, unless a very controlled build environment is desired, just install gcc-multilib package when using -m32 (needed for gcc or clang). For C++, g++-multilib is also required.

HAWQ installation on Redhat

I am installing HAWQ on RedHat servers provisioned on Amazon EC2. I already have HDP 2.3 setup on the cluster.
I have cloned HAWQ from Github.
First I run ./configure --prefix=/opt/hawq.
In the second step, I run make.
The dependencies are compiling correctly when I run make from the root folder of incubator-hawq. The following error occours when make moves to compiling from src folder in the root directory (incubator-hawq):
make[2]: Entering directory `/root/incubator-hawq/src/port'
gcc -O3 -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -I/usr/include/libxml2 -I../../src/port -DFRONTEND -I../../src/include -D_GNU_SOURCE -I/root/incubator-hawq/depends/libhdfs3/build/install/usr/local/hawq/include -I/root/incubator-hawq/depends/libyarn/build/install/usr/local/hawq/include -c -o copydir.o copydir.c
In file included from copydir.c:25:0:
../../src/include/storage/fd.h:61:23: fatal error: hdfs/hdfs.h: No such file or directory
#include "hdfs/hdfs.h"
^
compilation terminated.
make[2]: *** [copydir.o] Error 1
make[2]: Leaving directory `/root/incubator-hawq/src/port'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/root/incubator-hawq/src'
make: *** [all] Error 2
I know the compiler cannot find hdfs/hdfs.h, but as the dependencies (libhdfs3) compiled successfully, I don't understand why the particular file isn't found. Please help if somebody has come across the same problem as I am pretty much stuck here.
Could you check file /root/incubator-hawq/depends/libhdfs3/build/install/usr/local/hawq/include/hdfs/hdfs.h exists?
If not, then it should be build defect, please open defect to hawq team or email to: dev#hawq.incubator.apache.org. Thanks.
Do you have a folder in incubator-hawq/depends/libhdfs3/build/installafter make?
The problem seems that libhdfs3 dependency is not successfully built. There are some possible reasons for that: using a old version gcc(<4.7), configuration error of libhdfs3.
To test my words, you could try this:
cd incubator-hawq/depends/libhdfs3
mkdir build_debug && cd build_debug
cmake ..
make
If you could successfully do that, I think there is another reason for your problem. In this case, could you paste the information with more building lines?
Another possible reason is that you use different configuration prefix. In this case, you should run make distclean before another configuration.

cannot find the library `/usr/lib64/libexpat.la' when building httpd-2.4.7 RPM for CentOS 6.5

I am following up the instruction from http://httpd.apache.org/docs/2.4/platform/rpm.html
to build httpd-2.4.7 RPM for CentOS6.5. But I got the following errors - cannot find the library `/usr/lib64/libexpat.la'.
rpmbuild -tb httpd-2.4.7.tar.bz2
.....
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -std=gnu99 -pthread -O2 -g -pie -o htpasswd htpasswd.lo passwd_common.lo /usr/lib64/libaprutil-1.la -ldb-4.3 -lexpat -ldb-4.3 /usr/lib64/libapr-1.la -lpthread -ldl -lcrypt
libtool: link: cannot find the library /usr/lib64/libexpat.la' or unhandled argument/usr/lib64/libexpat.la'
make[2]: * [htpasswd] Error 1
make[2]: Leaving directory /root/rpmbuild/BUILD/httpd-2.4.7/support'<br>
make[1]: *** [all-recursive] Error 1<br>
make[1]: Leaving directory/root/rpmbuild/BUILD/httpd-2.4.7/support'
make: * [all-recursive] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.iSxbcs (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.iSxbcs (%build)
I ran yum search libexpat, the package has been installed.
[root#localhost Downloads]# yum search libexpat
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.les.net
* extras: mirror.its.sfu.ca
* updates: mirror.csclub.uwaterloo.ca
======= Matched: libexpat ==========================
compat-expat1.i686 : A library for parsing XML documents
compat-expat1.x86_64 : A library for parsing XML documents
expat.i686 : An XML parser library
expat.x86_64 : An XML parser library
expat-devel.i686 : Libraries and header files to develop applications using expat
expat-devel.x86_64 : Libraries and header files to develop applications using expat
mingw32-expat.noarch : MinGW Windows port of expat XML parser library
Anyone knows how to solve this issue. Thanks in advance.
Steve
The INSTALL doc states that you can:
./configure --with-included-apr
to use APR and APR-util libraries which include libexpat.la and come with httpd.
A .la file is for libtool to know how to link a library. It's probably in expat-devel, and should be added to the .spec file as a BuildRequires.
Install apr and apr-util before installing apache.
libexpat.la comes along with the source code of apr-util.
Try copying source code directory of apr and apr-util into srclib directory of apache and use ./configure --with-included-apr. This solved my issue.
cp -r /path/of/apr /path/of/apache/srclib/
cp -r /path/of/apr-util /path/of/apache/srclib/
./configure --with-included-apr

u-boot cross compile, fatal error: stdint.h

There is a strange error here, trying to cross compile for ARM on Linux Mint. I used:
make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} am335x_evm_config
make ARCH=arm CROSS_COMPILE=${CC}
make[1]: Leaving directory `/root/bbb/u-boot/arch/arm/cpu/armv7'
make[1]: Entering directory `/root/bbb/u-boot/board/ti/am335x'
make[1]: Nothing to be done for `_depend'.
make[1]: Leaving directory `/root/bbb/u-boot/board/ti/am335x'
make -C tools all
make[1]: Entering directory `/root/bbb/u-boot/tools'
gcc -g -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -include /root/bbb/u-boot/include/libfdt_env.h -idirafter /root/bbb/u-boot/include -idirafter /root/bbb/u-boot/include2 -idirafter /root/bbb/u-boot/include -I /root/bbb/u-boot/lib/libfdt -I /root/bbb/u-boot/tools -DCONFIG_SYS_TEXT_BASE=0x80800000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -D_GNU_SOURCE -pedantic -c -o crc32.o /root/bbb/u-boot/lib/crc32.c
In file included from /root/bbb/u-boot/include/compiler.h:19:0,
from /root/bbb/u-boot/include/libfdt_env.h:12,
from <command-line>:0:
/usr/lib/gcc/i686-linux-gnu/4.8/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
^
compilation terminated.
I also have exported ARCH and CROSS_COMPILE but I compiled u_boot without last week on other machine without a problem Seems to be a cross compiler problem but it is the same Linaro un-tar-ed in some location.
Any idea? Thanks very much.
Why is your u-boot source tree in /root/ ? Are you logged as root when executing make?
Are you sure you want to compile u-boot as a root ? because you don't need to.
As I was trying to understand what is going wrong here, I recognized some lines here http://eewiki.net/display/linuxonarm/BeagleBone#BeagleBone-ARMCrossCompiler:GCC
I hope you understood each line you executed because you need to execute them one after the other to have the compilation working.
Regarding the wiki, try this way :
export CROSS_COMPILE=/path/to/the/directory/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-
Then you can just :
make ARCH=arm distclean
make ARCH=arm am335x_evm_config
make ARCH=arm
Note that you will have to export the CROSS_COMPILE variable each time you open a new console.
I hope I helped you.
Try installing libc6-dev with all dependency. It solved the problem for me.
$ sudo apt-get install libc6-dev
sudo apt-get install libnewlib-arm-none-eabi

Building binutils with debugging mode

I'm trying to build binutils 2.21 source code with debugging on. My main aim is to debug objdump actually. But in order to build it I think I have to build whole package.
Unfortunately there is no debugging option on the configure file. I tried adding -g and -ggdb to CFLAGS before I configure it. However the error was:
Configuring in ./intl
configure: loading cache ./config.cache
configure: error: `CFLAGS' has changed since the previous run:
configure: former value: `-g -O2 -D__USE_MINGW_ACCESS'
configure: current value: `-g -D__USE_MINGW_ACCESS'
configure: error: in `/c/binutils-2.21/intl':
configure: error: changes in the environment can compromise the build
configure: error: run `make distclean' and/or `rm ./config.cache' and start over
make[1]: *** [configure-intl] Error 1
make[1]: Leaving directory `/c/binutils-2.21'
make: *** [all] Error 2
I tried "make clean" and "make distclean" but I'm receiving the same error. Actually according to former CFLAGS it had -g option on before but when I try to open objdump.exe in gdb it says
Reading symbols from c:\binutils-2.21\binutils/objdump.exe...
(no debugging symbols found)...done.
Thank you in advance.
Yes I've tried a lot. As I said -g tag was on to gcc. However makefile saves all debugging enabled binaries to binutils.libs\ directory. So when I run binutils.libs\objdump.exe under gdb it was fine. Thanks for your answer though.

Resources