LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2011, 03:33 AM   #1
wakatana
Member
 
Registered: Jul 2009
Location: Slovakia
Posts: 141

Rep: Reputation: 16
compiling coreutils


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

Code:
cd src
gcc id.c -o id
also tried

Code:
export CFLAGS="-static -02 -g"
./configure
cd src
gcc -std=gnu99 -I../lib -static -O2 -g -MT uniq.o -MD -MP -MF .deps/uniq.Tpo -c -o uniq.o uniq.c
But there was also missing header files problem.

So I tried to find particular file on system and link to /usr/include location for example:
Code:
ln -s /usr/lib/syslinux/com32/include/syslinux/config.h /usr/include/config.h
ln -s /usr/lib/syslinux/com32/include/com32.h /usr/include/com32.h
ln -s /usr/lib/syslinux/com32/include/klibc/compiler.h /usr/include/klibc/compiler.h
ln -s /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/plugin/include/system.h /usr/include/system.h
ln -s /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/plugin/include/safe-ctype.h /usr/include/safe-ctype.h
ln -s /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/plugin/include/hwint.h /usr/include/hwint.h
ln -s /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/plugin/include/filenames.h /usr/include/filenames.h
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)

Thanks a lot
 
Old 03-07-2011, 04:52 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Archbang may be too lightweight. Anyway, you will need a complete glibc.
( May be the headers are omitted, to make it more lightweight ? )

Fedora : # yum install glibc-devel glibc-headers kernel-headers

.. providing /usr/include/*, /usr/include/linux/*, /usr/include/asm/*
 
Old 03-08-2011, 08:19 AM   #3
wakatana
Member
 
Registered: Jul 2009
Location: Slovakia
Posts: 141

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by knudfl View Post
Archbang may be too lightweight. Anyway, you will need a complete glibc.
( May be the headers are omitted, to make it more lightweight ? )

Fedora : # yum install glibc-devel glibc-headers kernel-headers

.. providing /usr/include/*, /usr/include/linux/*, /usr/include/asm/*
Seems they are installed

Code:
[cepido@localhost src]$ yum list installed | grep glibc
glibc.i686          2.13-1          @updates
glibc-common.i686   2.13-1          @updates
glibc-devel.i686    2.13-1          @updates
glibc-headers.i686  2.13-1          @updates
[cepido@localhost src]$ yum list installed | grep headers
glibc-headers.i686  2.13-1          @updates
kernel-headers.i686 2.6.35.11-83.fc14
 
Old 03-08-2011, 08:31 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by wakatana View Post
but compiling ands with some header file dependency problem.
What headers? Please, can you post the relevant lines of the error message (usually the last 20-30 lines are enough)?
 
Old 03-08-2011, 08:42 AM   #5
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
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:
Code:
STAGE1   = tcl-testsuite \
           expect-testsuite \
           file-testsuite \
           dejagnu-testsuite \
           tree-testsuite \
           temp-perl \
           linux-headers \
           man-pages \
           glibc \
           binutils \
           gcc \
           coreutils \
           ...
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.
 
Old 03-08-2011, 09:23 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Fedora 14 : That is coreutils-8.5
http://ftp.gnu.org/gnu/coreutils/coreutils-8.5.tar.gz
> coreutils-8.5.tar.gz

cd coreutils-8.5/ && ./configure && make : No errors.

Version 8.9 : The same, no errors.
( http://ftp.gnu.org/gnu/coreutils/coreutils-8.9.tar.gz )

For the above, glibc* 2.12.90 was used. You have updated to 2.13,
but I don't know why 2.13 should be that different ( or unstable ).

..
 
Old 03-08-2011, 04:09 PM   #7
wakatana
Member
 
Registered: Jul 2009
Location: Slovakia
Posts: 141

Original Poster
Rep: Reputation: 16
Tried that

Code:
ARCHBANG
[cepido@archbang ~]$ pacman -Q | grep coreutils
coreutils 8.10-1
[cepido@archbang ~]$ cd coreutils-8.10/src/
[cepido@archbang src]$ gcc -std=gnu99 -I../lib -static -O2 -g -MT uniq.o -MD -MP -MF .deps/uniq.Tpo -c -o uniq.o uniq.c
In file included from uniq.c:24:0:
system.h:49:24: fatal error: configmake.h: No such file or directory
compilation terminated.
[cepido@archbang src]$ gcc uniq.c -o uniq
uniq.c:19:20: fatal error: config.h: No such file or directory
compilation terminated.


FEDORA
[cepido@localhost /]$ yum list installed | grep core
coreutils.i686      8.5-7.fc14      @updates
coreutils-libs.i686 8.5-7.fc14      @updates
[cepido@localhost ~]$ cd coreutils-8.5/src/
[cepido@localhost src]$ gcc -std=gnu99 -I../lib -static -O2 -g -MT uniq.o -MD -MP -MF .deps/uniq.Tpo -c -o uniq.o uniq.c
uniq.c:19:20: fatal error: config.h: No such file or directory
compilation terminated.
[cepido@localhost src]$ gcc uniq.c -o uniq
uniq.c:19:20: fatal error: config.h: No such file or directory
compilation terminated.
also
./configure
make

has been issued before
 
Old 03-08-2011, 04:56 PM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.

--- rod.

Last edited by theNbomr; 03-08-2011 at 04:58 PM.
 
1 members found this post helpful.
Old 03-08-2011, 05:22 PM   #9
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
cd coreutils-8.5/src/
Are you actually changing directory to src/ ?
Or is that (cd coreutils-8.5/src/) from the output of 'make' ?

I'd guess, that it is a must to run make in the top directory only.

There is no /usr/include/config.h in Fedora 14 :
Anyway coreutils is compiled with no errors. (The locale config.h is used ?)

Code:
gcc -std=gnu99 -I../lib -static -O2 -g -MT uniq.o -MD -MP -MF .deps/uniq.Tpo -c -o uniq.o uniq.c
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.
..

Last edited by knudfl; 03-08-2011 at 05:24 PM.
 
Old 03-13-2011, 05:17 AM   #10
wakatana
Member
 
Registered: Jul 2009
Location: Slovakia
Posts: 141

Original Poster
Rep: Reputation: 16
Hi people - sorry for long response
I tried that:
Code:
[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.

Code:
[root@localhost src]# yum list installed coreutils-debuginfo
Loaded plugins: auto-update-debuginfo
Installed Packages
coreutils-debuginfo.i686                                                    8.5-7.fc14                                                     @updates-debuginfo
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

Last edited by wakatana; 03-13-2011 at 05:34 AM.
 
Old 03-13-2011, 06:25 AM   #11
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
passwd-0.78-1.fc14.i686
"i686" means a binary package.

The "tar package" for passwd-0.78-1.fc14.i686.rpm ( passwd-0.78.tar.bz2 )
It is inside the Fedora 14 source package passwd-0.78-1.fc14.src.rpm
http://download.fedora.redhat.com/pu.../source/SRPMS/
 
Old 03-13-2011, 07:51 AM   #12
wakatana
Member
 
Registered: Jul 2009
Location: Slovakia
Posts: 141

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by knudfl View Post
"i686" means a binary package.

The "tar package" for passwd-0.78-1.fc14.i686.rpm ( passwd-0.78.tar.bz2 )
It is inside the Fedora 14 source package passwd-0.78-1.fc14.src.rpm
http://download.fedora.redhat.com/pu.../source/SRPMS/
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 ?
 
Old 03-13-2011, 08:04 AM   #13
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,518

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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.

..

Last edited by knudfl; 03-13-2011 at 11:21 AM.
 
Old 03-13-2011, 11:36 AM   #14
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.

--- rod.
 
Old 03-13-2011, 02:11 PM   #15
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Should this become part of the coreutils? dpeterson3 General 7 05-26-2010 12:12 PM
Re-install coreutils 3rensho Linux - Software 8 03-14-2010 04:31 AM
5.16 Coreutils-6.12 jpeters Linux From Scratch 1 03-29-2009 03:23 PM
mv (coreutils) 5.2.1 - a bug? BiThian Linux - Desktop 1 09-15-2006 12:28 AM
coreutils-5.0 error rahul_jain_9684 Linux From Scratch 0 09-27-2003 12:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration