LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-13-2012, 12:20 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Problem compiling gcc4.2.7 on CentOS 5.4


I'm trying to make a clean development environment. To do so, I've made a jail shell (using chroot & a few rpm commands) which appears to be working well. I need to get gcc into that jail shell, but don't want to use the one supplied by yum - I need something newer for Qt.

I'm trying to compile gcc 4.2.7 outside of the jail shell with a prefix that's inside the jail shell. This is the only way I know how to compile as it appears you need a compiler to make the compiler. There's no compiler in the jail shell, so I'm doing it outside of the jail shell, using the CentOS 5.4 supplied 4.1.2 to make 4.2.7.

4.2.7 requires more recent versions of gmp, mpfr, and mpc. I've compiled all of those (again with a target of the new root's usr dir) & all seems to go well. My configure line:

Code:
../configure --prefix=/home/briank/jaildev/usr --with-gmp=/home/briank/jaildev/usr --with-mpfr=/home/briank/jaildev/usr --with-mpc=/home/briank/jaildev/usr --with-mpc-lib=/home/briank/jaildev/usr/lib
The configure for gcc completes now that I point it at the new locations of gmp, etc, however, the build fails. If I look at the configure.log in the offending directory, I see a few errors:

Code:
configure:3407: /home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/xgcc -B/home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/ -B/home/briank/jaildev/usr/x86_64-unknown-linux-gnu/bin/ -B/home/briank/jaildev/usr/x86_64-unknown-linux-gnu/lib/ -isystem /home/briank/jaildev/usr/x86_64-unknown-linux-gnu/include -isystem /home/briank/jaildev/usr/x86_64-unknown-linux-gnu/sys-include    -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3418: $? = 1
configure:3407: /home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/xgcc -B/home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/ -B/home/briank/jaildev/usr/x86_64-unknown-linux-gnu/bin/ -B/home/briank/jaildev/usr/x86_64-unknown-linux-gnu/lib/ -isystem /home/briank/jaildev/usr/x86_64-unknown-linux-gnu/include -isystem /home/briank/jaildev/usr/x86_64-unknown-linux-gnu/sys-include    -qversion >&5
xgcc: error: unrecognized command line option '-qversion'
xgcc: fatal error: no input files
compilation terminated.
configure:3418: $? = 1
configure:3434: /home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/xgcc -B/home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/ -B/home/briank/jaildev/usr/x86_64-unknown-linux-gnu/bin/ -B/home/briank/jaildev/usr/x86_64-unknown-linux-gnu/lib/ -isystem /home/briank/jaildev/usr/x86_64-unknown-linux-gnu/include -isystem /home/briank/jaildev/usr/x86_64-unknown-linux-gnu/sys-include    -o conftest -g -O2   conftest.c  >&5
/home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/cc1: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
configure:3437: $? = 1
configure:3625: checking for suffix of object files
configure:3647: /home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/xgcc -B/home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/ -B/home/briank/jaildev/usr/x86_64-unknown-linux-gnu/bin/ -B/home/briank/jaildev/usr/x86_64-unknown-linux-gnu/lib/ -isystem /home/briank/jaildev/usr/x86_64-unknown-linux-gnu/include -isystem /home/briank/jaildev/usr/x86_64-unknown-linux-gnu/sys-include    -c -g -O2  conftest.c >&5
/home/briank/jaildev/home/briank/install/gcc-4.7.0/gcc-build/./gcc/cc1: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
configure:3651: $? = 1
It looks like xgcc is getting a '-V', but if I run xgcc --help, I don't see that '-V' is an option ('-v' is, but not '-V').

I also see that it mentions is can't find libmpc.so.2, but libmpc.so.2 lives in the given mpc-lib dir:

Code:
ls -l /home/briank/jaildev/usr/lib/libmpc*
-rw-r--r-- 1 root root 209806 Apr 12 15:22 /home/briank/jaildev/usr/lib/libmpc.a
-rwxr-xr-x 1 root root   1064 Apr 12 15:22 /home/briank/jaildev/usr/lib/libmpc.la
lrwxrwxrwx 1 root root     15 Apr 12 15:22 /home/briank/jaildev/usr/lib/libmpc.so -> libmpc.so.2.0.0
lrwxrwxrwx 1 root root     15 Apr 12 15:22 /home/briank/jaildev/usr/lib/libmpc.so.2 -> libmpc.so.2.0.0
-rwxr-xr-x 1 root root  98011 Apr 12 15:22 /home/briank/jaildev/usr/lib/libmpc.so.2.0.0
I've tried setting:
LDFLAGS='-L /home/briank/jaildev/usr/lib'
LD_LIBRARY_PATH=/home/briank/jaildev/usr/lib

I've tried running ldconfig (with no arguments).

... and now I'm at a loss. Any ideas?
 
Old 04-14-2012, 11:33 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
CentOS5, build prerequisites for gcc-4.7.0 :
ppl(-0.11.2), libmpdclient(-2.7), cloog-ppl(-0.15.11) :
( I have those installed --prefix=/usr/ ).

No gmp, mpfr, mpc needs to be installed for the gcc build.
The sources gmp, mpfr, mpc, unpacked to gcc-4.7.0/ will do.
>>> Rename gmp-5.0.2/, mpfr-3.10/, mpc-0.9/ to gmp/ mpfr/ mpc/.

A valid configure line :
../gcc-4.7.0/configure --prefix=<prefix> --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++,fortran --disable-multilib --with-mpfr-include=$(pwd)/../gcc-4.7.0/mpfr/src --with-mpfr-lib=$(pwd)/mpfr/src/.libs
( You will probably not want "gcc java", ada, etc.)

$ make : No errors on the 32 bits CentOS 5.8.

.

Last edited by knudfl; 04-14-2012 at 02:59 PM.
 
Old 04-15-2012, 07:19 AM   #3
qux
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Rep: Reputation: Disabled
Have same for gcc 4.7.1pre at fedora 16 x64, but without shared library errors.
I try to build a cross-compiler:

Code:
../../gcc/configure  --target=mips-elf --prefix=/home/build/gcc && make
and get errors listed below.
Shared libraries errors seems common, but current case contains just errors for xgcc and exec command line options.
As BrianK mentioned, there is no -V option in `xgcc --help` output.

Code:
configure:3398: checking for C compiler version
configure:3408: /mnt/tmp/gcc-obj/./gcc/xgcc -B/mnt/tmp/gcc-obj/./gcc/ -B/home/build/gcc/mips-elf/bin/ -B/home/build/gcc/mips-elf/lib/ -isystem /home/build/gcc/mips-elf/include -isystem /home/build/gcc/mips-elf/sys-include    --version >&5
xgcc (GCC) 4.7.1 20120415 (prerelease)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3421: $? = 0
configure:3408: /mnt/tmp/gcc-obj/./gcc/xgcc -B/mnt/tmp/gcc-obj/./gcc/ -B/home/build/gcc/mips-elf/bin/ -B/home/build/gcc/mips-elf/lib/ -isystem /home/build/gcc/mips-elf/include -isystem /home/build/gcc/mips-elf/sys-include    -v >&5
Reading specs from /mnt/tmp/gcc-obj/./gcc/specs
COLLECT_GCC=/mnt/tmp/gcc-obj/./gcc/xgcc
COLLECT_LTO_WRAPPER=/mnt/tmp/gcc-obj/./gcc/lto-wrapper
Target: mips-elf
Configured with: ../../gcc/configure --target=mips-elf --prefix=/home/build/gcc
Thread model: single
gcc version 4.7.1 20120415 (prerelease) (GCC) 
configure:3421: $? = 0
configure:3408: /mnt/tmp/gcc-obj/./gcc/xgcc -B/mnt/tmp/gcc-obj/./gcc/ -B/home/build/gcc/mips-elf/bin/ -B/home/build/gcc/mips-elf/lib/ -isystem /home/build/gcc/mips-elf/include -isystem /home/build/gcc/mips-elf/sys-include    -V >&5
xgcc: error: unrecognized command line option '-V'
xgcc: fatal error: no input files
compilation terminated.
configure:3421: $? = 1
configure:3408: /mnt/tmp/gcc-obj/./gcc/xgcc -B/mnt/tmp/gcc-obj/./gcc/ -B/home/build/gcc/mips-elf/bin/ -B/home/build/gcc/mips-elf/lib/ -isystem /home/build/gcc/mips-elf/include -isystem /home/build/gcc/mips-elf/sys-include    -qversion >&5
xgcc: error: unrecognized command line option '-qversion'
xgcc: fatal error: no input files
compilation terminated.
configure:3421: $? = 1
configure:3437: /mnt/tmp/gcc-obj/./gcc/xgcc -B/mnt/tmp/gcc-obj/./gcc/ -B/home/build/gcc/mips-elf/bin/ -B/home/build/gcc/mips-elf/lib/ -isystem /home/build/gcc/mips-elf/include -isystem /home/build/gcc/mips-elf/sys-include    -o conftest -g -O2   conftest.c  >&5
/mnt/tmp/gcc-obj/./gcc/as: line 87: exec: -E: invalid option
exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
configure:3440: $? = 1
configure:3628: checking for suffix of object files
configure:3650: /mnt/tmp/gcc-obj/./gcc/xgcc -B/mnt/tmp/gcc-obj/./gcc/ -B/home/build/gcc/mips-elf/bin/ -B/home/build/gcc/mips-elf/lib/ -isystem /home/build/gcc/mips-elf/include -isystem /home/build/gcc/mips-elf/sys-include    -c -g -O2  conftest.c >&5
/mnt/tmp/gcc-obj/./gcc/as: line 87: exec: -E: invalid option
exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
configure:3654: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgcc/"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3668: error: in `/mnt/tmp/gcc-obj/mips-elf/libgcc':
configure:3671: error: cannot compute suffix of object files: cannot compile

Last edited by qux; 04-15-2012 at 12:47 PM.
 
Old 04-15-2012, 12:49 PM   #4
qux
LQ Newbie
 
Registered: Apr 2012
Posts: 3

Rep: Reputation: Disabled
xgcc "unrecognized command line option" errors don't really break the build. I've fixed exec problem with "--with-as" option to configure.
 
Old 05-01-2012, 12:07 PM   #5
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Solved....

For the short attention span. LD_LIBRARY_PATH, by default, is not seen when you run make as sudo.

Longer...

First off, qux is right, the "unrecognized command line option" was a red hearing. In fact, when looking through the configure script that made this message, you can see that it tried several different options - -v, -V, -qversion (maybe a couple others). One might think it short-circuits on success, but it doesn't seem to, so you will probably *always* get a few unrecognized option error messages, but they are benign.

The more important error was further down in the log file where it mentioned that it couldn't load one of the required-for-compile libs (mpc, gmp, mpfr), which was surprising as they existed in the path defined by LD_LIBRARY_PATH. This was my biggest head scratcher as it seemed everything it needed was there. I made a little bit of headway by forcibly moving a lib or two into the actual compile dir & realized it must be a pathing issue.

Long story less long... I was building this for a jail shell. I initially planned on building *in* the jail shell but found that to be more difficult than it was worth (the jail shell had *no* compiler), so I build outside the jail shell with a prefix in the jail shell. Being that the source was in the jail shell, I couldn't write to the build directory unless I ran configure & make as sudo. Because I was using new mpc, mpfr, gmp, (that were installed to non-standard locations) I needed to set an LD_LIBRARY_PATH. By default, LD_LIBRARY_PATH is not transfered to a sudo session, so when I was actually compiling, LD_LIB... wasn't set (even though it was set in my shell)... and that's why the compile couldn't see the new libs. The solution was to move the gcc source outside of the jail shell & compile with a target inside the jail shell so that the only thing that needed sudo was the make install.

Lastly, to correct knudfl, mpc, mpfr, and gmp *are* required to build newer gcc (in fact, configure will fail if you don't have newer versions than are supplied by CentOS 5.4). Mpc must be compiled against the newer versions of gmp & mpfr. (edited to change: knudfl said that those libs didn't need to be installed, which is correct. They just need to be made available to the compilation of gcc - which is what knudfl said. My mistake in correcting)

Last edited by BrianK; 05-01-2012 at 02:03 PM.
 
  


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
error while compiling gcc4.5.3 on rhel x86_64 pix9 Linux - Software 30 09-07-2011 02:18 PM
Problem compiling mod_security on a CentOS server havok1977 Linux - Software 1 12-11-2008 07:02 PM
Problem compiling ivtv-0.10.6 against 2.6.18-92.1.18.el5.centos.plus treimers Linux - Software 2 12-06-2008 12:44 PM
problem with iptables afer compiling 2.6.24.2 from www.kernel.org on centos 5.1 tanch Linux - Newbie 4 03-03-2008 12:22 AM
RH9.3 install gcc4.2.2 ,libstdc++.so.6 problem bangqian.chen Linux - Software 4 12-11-2007 08:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:44 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