I have been trying for hours to recompile Linux kernel of https://github.com/torvalds/linux from my MacBook Pro and at the end, still stuck. Hard to find a tutorial to understand how to recompile it, headers missing, bla bla bla.
http://www.howardism.org/Technical/Linux/Rebuilding_Kernel.html
https://medium.com/#ssreehari/implementing-a-system-call-in-linux-kernel-4-7-1-6f98250a8c38
https://tssurya.wordpress.com/2014/08/19/adding-a-hello-world-system-call-to-linux-kernel-3-16-0/ (but useless since I have the v4.17)
PS: I tried first adding a syscall website because that's what I'm trying to do at first.
At the begining, I got a .config not found.
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target `include/config/auto.conf', needed by`include/config/kernel.release'. Stop.
Unlike in some web-links, the conf used doesn't exist or something else is wrong, so I'm creating a new .config from "make menuconfig" (as some answers on the web).
Then, I try to compile again. There is some command I tried:
- make
emixam23#Maximes-MBP:~/Workspace/linux-kernel$ make
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
/bin/sh: scripts/basic/modules.order: Permission denied
make[1]: *** [scripts/basic/modules.order] Error 1
make: *** [scripts_basic] Error 2
- sudo make
emixam23#Maximes-MBP:~/Workspace/linux-kernel$ sudo make
Password:
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
HOSTCC arch/x86/tools/relocs_32.o
In file included from arch/x86/tools/relocs_32.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
1 error generated.
make[1]: *** [arch/x86/tools/relocs_32.o] Error 1
make: *** [archscripts] Error 2
After that, I begin to search if the mistake was coming from my make command and I found this:
- sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
emixam23#Maximes-MBP:~/Workspace/linux-kernel$ sudo make -j 4 && sudo make modules_install -j 4 && sudo make install -j 4
getconf: no such configuration parameter `LFS_CFLAGS'
getconf: no such configuration parameter `LFS_LDFLAGS'
getconf: no such configuration parameter `LFS_LIBS'
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
In file included from arch/x86/tools/relocs_common.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
In file included from arch/x86/tools/relocs_32.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
In file included from arch/x86/tools/relocs_64.c:2:
arch/x86/tools/relocs.h:13:10: fatal error: 'elf.h' file not found
#include <elf.h>
^~~~~~~
1 error generated.
make[1]: *** [arch/x86/tools/relocs_common.o] Error 1
make[1]: *** Waiting for unfinished jobs....
1 error generated.
1 error generated.
make[1]: *** [arch/x86/tools/relocs_32.o] Error 1
make[1]: *** [arch/x86/tools/relocs_64.o] Error 1
make: *** [archscripts] Error 2
make: INTERNAL: Exiting with 5 jobserver tokens available; should be 4!
So, based on the errors I got, I searched about <elf.h> and it seems to be something about Android. To me, it doesn't have any links, I mean, I feel like this.
The thing is, I just downloaded a Linux kernel (Torvalds), I added my syscall, now I'm trying to recompile it and use it with vagrant. That's it. Why does it seem so complicated? I will be honest, I feel completely lost... Do you have any idea if I'm right but I just missunderstood something, or I'm totally out of the good way?
I am working from a MacBook Pro:
MacBook Pro (Retina, 15-inch, Mid 2015)
macOS High Sierra
Version 10.13.1
Thanks for any hints/help
Max
PS: Edit 1: Add of my edits: https://github.com/Emixam23/linux-kernel/commit/d7d7b66cc6513e7b69fd2122b880c259628c438a
Vagrant
I found a workaround which is vagrant :) With vragrant you can recompile the kernel from a Mac OS. You just have to vagrant init then you connect yourself to the vagrant VM vagrant ssh. Once your inside the vagrant VM, run cd / and you will arrive to the root of your machin, which is also where you created the VM, so you can do whatever you want from Mac OS and compile from the terminal make -j 4 :)
Check your tool-chain. It is not just android thing. https://linux.die.net/man/5/elf.
Please go ahead if you like being challenged. cause this will not be straight forward.
If your task is just compiling code use virtual machine / other linux machine it will be quicker.
But if you are curious to check how things work and getting them work on mac for future compilations without vm. then continue.try adding those header files. in /usr/include as per this
Related
Hi I am trying to install systemC on WSL2, when I run sudo make I seem to be getting this error
Making all in src
make[1]: Entering directory '/home/ryans/systemc-2.3.4/src'
Makefile:77: *** missing separator. Stop.
make[1]: Leaving directory '/home/ryans/systemc-2.3.4/src'
make: *** [Makefile:557: all-recursive] Error 1
I have looked at answers, solution 1 and solution2 but they don't seem to apply to my case because the file in question do not have a space or a tab at line 77.
Seems like the right way to install systemC on WSL is the run the following commands in the uncompressed .tar folder,
sudo aclocal
sudo automake --add-missing
sudo autoupdate
before making the objdir with the other instructions can be followed here.
I'm an inexperienced programmer so bear with me if this little sense. I'm trying to run a basic "hello world" kind of program in CLion, except I'm trying to print out a value in the main.cpp file from a header and cpp file. I'm using MacOS and everything is update in terms of software. When I try to build or run the program, it gives me these errors:
====================[ Build | untitled1 | Debug ]===============================
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/anshuldaga/untitled1/cmake-build-debug --target untitled1 -- -j 2
[ 33%] Building CXX object CMakeFiles/untitled1.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/untitled1.dir/test.cpp.o
make[3]: /Library/Developer/CommandLineTools/usr/bin/c++: Permission denied
make[3]: /Library/Developer/CommandLineTools/usr/bin/c++: Permission denied
make[3]: *** [CMakeFiles/untitled1.dir/main.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [CMakeFiles/untitled1.dir/test.cpp.o] Error 1
make[2]: *** [CMakeFiles/untitled1.dir/all] Error 2
make[1]: *** [CMakeFiles/untitled1.dir/rule] Error 2
make: *** [untitled1] Error 2
I've already tried running the sudo g++ main.cpp command and it gives me this error:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Based off my research, I know that clang is the compiler for c++ and a linker error is basically when something can't find the right files or library.
I've uninstalled and reinstalled Xcode, did the
sudo xcode-select -switch /Library/Developer/CommandLineTools/
command. I'm not sure what to do at this point. Any help would be greatly appreciated, thank you!
According to this(archive.org) old post from the CLion forum, the xcode license agreement might be the issue. Try to start xcode and agree to the license, or run sudo xcodebuild -license.
I am new to compiling.
I am trying to compile iperf3 for Windows 10 because there is no official Windows distribution of iperf3 and for the learning experience. I am trying to do so on the new Windows Subsystem for Linux feature via Bash on Ubuntu on Windows, also for the learning experience.
I installed mingw-w64, which should give me the proper compiler and environment necessary for cross-compiling:
sudo apt-get install mingw-w64
This put two directories into my /usr directory:
i686-w64-mingw32
x86_64-w64-mingw32
It also put a bunch of things that look like compilers into /usr/bin.
I unzipped the .tar.gz file from iperf3 and navigated into it. Then, I run ./configure --host=i686-w64-mingw32.static and it completes without errors.
I note that the output of the command has a worrisome line: checking for i686-w64-mingw32.static-gcc... no
I note that the Makefile's CC variable is set to gcc, which doesn't sound like the proper compiler.
Then, I run make. It fails with errors:
collect2: error: ld returned 1 exit status
make[2]: *** [iperf3] Error 1
make[2]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make: *** [all-recursive] Error 1
I also see the line: libtool: warning: undefined symbols not allowed in i686-w64-mingw32.static shared libraries; building static only
I think that the ./configure is not working correctly since it appears to have not found the right compiler for my --host argument and put it in the Makefile.
What am I doing wrong?
EDIT:
I changed the command to ./configure --host=i686-w64-mingw32 per comments and it completes without error. But no makefile is created so make yields make: *** No targets specified and no makefile found. Stop.
What am I doing wrong, now?
EDIT 2:
Looks like the ./configure actually is failing. Last line of its output is nanosleep() required for timing operations., which seems to mean that its missing a library for nanosleep.
How do I get nanosleep?
mingw doesn't support nanosleep. So programs using it cannot be compiled using mingw-w64.
I am trying to compile GCC for Cygwin with support for targeting i386-elf so I can compile some simple OSes (search Benu, by l30nard0, on Github). I've successfully compiled the binutils for i386-elf, and compiled all of GCC's floating-point numbers dependencies.
Problem is, it says windows.h can not be found. I do have w32api successfully installed, and tried including each of those one at a time in the include path for GCC, but none of them work. If I try any of them, I get so many errors and warnings that not all will show up in the Cygwin console. The dozens upon dozens of warnings are most if not all unused parameter.
Does anyone know where the problem might lie?
I've wasted the last three entire days of my life trying to get Linux Mint set up with everything I want, but for reasons I shan't go into I gave up on that. I'd love to be able to get just one thing to work so I can enjoy my life again. :) Thanks!
BTW: The configure arguments I used were --target=i386-elf --enable-threads=win32 --enable-languages=c,c++ Was I supposed to use --enable-targets instead?
And here's part of the log:
In file included from ../../../gcc/libgcc/gthr.h:150:0,
from ../../../gcc/libgcc/unwind-dw2.c:38:
./gthr-default.h:541:21: fatal error: windows.h: No such file or directory
compilation terminated.
../../../gcc/libgcc/static-object.mk:17: recipe for target 'unwind-dw2.o' failed
make[2]: *** [unwind-dw2.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from ../../../gcc/libgcc/gthr.h:150:0,
from ../../../gcc/libgcc/unwind-dw2-fde.c:38:
./gthr-default.h:541:21: fatal error: windows.h: No such file or directory
compilation terminated.
../../../gcc/libgcc/static-object.mk:17: recipe for target 'unwind-dw2-fde.o' failed
make[2]: *** [unwind-dw2-fde.o] Error 1
make[2]: Leaving directory '/home/Sean/gccbuild/i386-elf/libgcc'
Makefile:10055: recipe for target 'all-target-libgcc' failed
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory '/home/Sean/gccbuild'
Makefile:870: recipe for target 'all' failed
make: *** [all] Error 2
Remove the --enable-threads=win32 flag; it is intended to specify thread support on the target system, not the build system.
I want to to build QEMU arm for windows. For that I execute the following command:
/configure –target-list=arm-softmmu and make.
when I executing make command I get the following error.
Makefile:24: no file name for `-include'
make[1]: *** No rule to make target `vl.o', needed by `all'. Stop.
make: *** [subdir-libhw32] Error 2
How I can resolve this issue? Please help me.