ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi gurus
I am trying to compile coreutils for studying purposes. I downloaded package (exact version which target system already contains) and tried following:
Code:
./configure
make
but compiling ands with some header file dependency problem. Then I tried compile particular binary
maybe further more header files I dont know - but the result is the same header file problem.
I tried the metioned procedure on Archbang and Fedora (on both the coreutils was the same version whih is already installed and is working properly)
It's been several years since I dealt with coreutils (version 6.9) when I was building a Linux system based on CLFS (cross-compiled linux from scratch). From what I can recall, to build coreutils, these steps were performed:
1. Untar the package;
2. Change directory into coreutils-<version>;
3. Patch any source modules as necessary (check if your version of coreutils has any available patches);
4. ./configure
5. make
The CLFS cookbook required that the following packages be built in this order:
I don't think the "testsuite" and man-pages packages are relevant for your needs, however you should make sure that you have the other ones preceding coreutils.
Last edited by dwhitney67; 03-08-2011 at 08:43 AM.
When I scan through many of the config.h files on the system I'm writing this from, I see in most of them:
Code:
/* config.h. Generated from config.h.in by configure. */
This begs the question of whether your configure script is running successfully, or if it bugs out due to something it didn't like or couldn't do.
Also, it looks like you are trying to run gcc independently, whereas there should be a properly configured Makefile that will let you just build everything.
This command cannot be run as a separate command, it seems.
You have headers in lib/ and src/, some includes a header from the other folder.
( Unless you already have run 'make' with no errors in the top directory.
But then again : As the uniq.o already is present : Nothing will be created.)
The 'gcc -std=..' command will however work, if make has been run, and uniq.o deleted:
Then a new different uniq.o is created.
EDIT : I wrote the above, while theNbomr was posting.
..
[root@localhost coreutils-8.5]# tar -xvzf coreutils-8.5.tar.gz
[root@localhost coreutils-8.5]# cd coreutils-8.5
[root@localhost coreutils-8.5]# ./configure
long output
long output
long output
configure: WARNING: libgmp development library was not found or not usable.
configure: WARNING: GNU coreutils will be built without GMP support.
long output
long output
[root@localhost coreutils-8.5]# echo $0
0
[root@localhost coreutils-8.5]# make
long utput
long utput
long utput
make[4]: Entering directory `/root/coreutils-8.5/gnulib-tests'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory `/root/coreutils-8.5/gnulib-tests'
make[3]: Leaving directory `/root/coreutils-8.5/gnulib-tests'
make[2]: Leaving directory `/root/coreutils-8.5/gnulib-tests'
make[2]: Entering directory `/root/coreutils-8.5'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/root/coreutils-8.5'
make[1]: Leaving directory `/root/coreutils-8.5'
[root@localhost coreutils-8.5]# echo $?
0
[root@localhost coreutils-8.5]# src/whoami
root
Seems make works. This package has been installed since last post.
Also two questions
- is it possible to compile only specific binary ? (id.c uniq.c cat.c etc) and not whole package ?
- where to find another packages that I can compile from source ? for example passwd command ?
I tried to search for passwd-0.78-1.fc14.i686 tar gz but no luck
Thank you that makes sense that i686 is binary but id did not comes to my mind before.
And is possible to compile only particular binary not whole package ?
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518
Rep:
Quote:
Is it possible to compile only specific binary ? (id.c uniq.c cat.c)
No. Not directly.
You will have to use lots of time to rewrite files to do so. Makefile ?
Then better compile the whole package : A few minutes.
When coreutils-<version>/lib/configmake.h and ///src/version.h are generated,
just then it is possible to compile a standalone object, like :
gcc -std=gnu99 -I../lib -static -O2 -g -MT uniq.o -MD -MP -MF .deps/uniq.Tpo -c -o uniq.o uniq.c
But you can of course do make in the top directory, then you have the two files :
configmake.h, version.h, which you can use in another coreutils-<version>, same version.
You should be able to find source tarballs for all Gnu software. To build these packages, the usual steps are (after unpacking the tarball, and making the source code package directory you current working directory), as a normal user:
Code:
./configure
make
sudo make install
## ... or...
su -c 'make install'
Note that only the installation step requires root privileges.
Yes you can compile individual bins from coreutils. Jzs run configure, then cd into the various subdirs in the right order !-search the Makefile for the string 'subdir' to find the order. Probably po m4 etc, the main ones are 'lib' which needs to be done before 'src'. Once lib and all other required ones are done, cd into src and run 'make stat(or whichever pro you want). This is not always the case, but coreutils does have a separate Makefile rule for each binary.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.