I downloaded the official ls.c source code and tried to compile it with gcc. The problem was that the gcc showed me a lot of errors.
$ gcc ls.c -o ls
ls.c:38:20: fatal error: config.h:I did fix a lot of those errors by searching with the find command into my dictonarys
$ find /usr/src/ -name "nameofthelibary" 2> /dev/nullfor some libarys i found the correct path, so for example i could place them into the #include <config.h> => #include </usr/src/linuxheader.../config.h>as i mentioned this method worked for some libarys but not for the header for example #include "die.h"
so my question is now: is there any way to compile this ls.c ? cz i want to learn how it works by modifying it
21 Answer
ls is part of the coreutils package and as such depends on both other files within coreutils, and the configuration steps. You probably could spend a long time unravelling it from the library but unless you're planning on compiling this a few hundred times a day, I don't think it's worth it.
As pim said in the comments, you can learn about the full build process from the README.hacking file in the root of the git tree. I ran the following without really paying that much heed but this is what worked for me.
sudo apt install git build-essential
sudo apt build-dep coreutils
git clone git://
cd coreutils
./bootstrap # grabs submodules, sets up configuration
./configure # does actual compiler configuration
make clean # remove old attempts
make -j8 # compile using 8 threads (you might want to alter this)That will compile everything in the src directory and leave the binaries in there. You can run your newly compiled ls with ./src/ls. You can make changes and as long as they're lightweight, you can re-compile them with just the make steps.