Ch 5.9 Binutils Pass 2 Error: Cannot run C compiled programs
Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
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.
Ch 5.9 Binutils Pass 2 Error: Cannot run C compiled programs
Hello everyone,
I am currently trying to get through the Binutils Pass 2 of LFS book version 6.6. I am getting an error stating:
"configure: error: cannot run C compiled programs"
I have tried searching Google for answers, and while I have found similar problems, nothing has seemed to be directly correlating to my problem.
I am attempting to do this on Virtual Box v. 3.1.6, running LFS Live v.6.2-5. The exact output when trying to run:
checking whether the C compiler works.. configure: error: in `/mnt/lfs/sources/binutils-build':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host`.
I have not posted any information from config.log, but if I am told to do so, I will.
Thanks in advance for any help or suggestions posted in reply,
Strungmind
it seems like your cross-compiler did not compile properly or the toolchain adjustment might have gone wrong. The information about the error you provided is a bit sparse. Can you post the last ~20 lines before the error occurred? Also post the output of
Can you post the last ~20 lines before the error occurred?
Code:
CC="$LFS_TGT-gcc -B/$LFS/tools/lib/" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../binutils-2.19.1/configure --prefix=$LFS/tools \
--disable-nls --with-lib-path=$LFS/tools/lib
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for gcc... i686-lfs-linux-gnu-gcc -B/tools/lib/
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
This mostly occurs when glibc didn't build properly. The file crt1.o that you are missing is installed by glibc. I suggest since you are not too far from having started off, try rebuilding. That ways if the error repeats, you'll be able to better isolate it.
Hmm that was strange. I had this same error after having mistakenly decided that I could correctly hand-type the SPECS="..." bit in the glibc section (5.8). I also noted that, after running
Code:
readelf -l a.out | grep ': /tools'
, instead of the desired output
Code:
[Requesting program interpreter: /tools/lib/ld-linux.so.2]
i had something of the form
Code:
[Requesting program interpreter: /tools/usr/lds/lib/ld-linux.so.2]
(I'm sorry I have to go from memory there, the directory mysteriously disappeared.)
After simply re-running the SPECS='...' command (pasted this time), I was able to enter CC="..." and it ran fine.
I'm now continuing with 5.9 (CC="...") without observable error, though I'll repost if this f***s something up further down the track.
@strungmind :I have this same problem . the dummy.c file compiled without a problem but it appears for some reason it will not compile this file.Did you solve the problem now?
@duskxiv :I re-running the
Quote:
SPECS=`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/specs
$LFS_TGT-gcc -dumpspecs | sed \
-e 's@/lib\(64\)\?/ld@/tools&@g' \
-e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS
echo "New specs file is: $SPECS"
unset SPECS
and re-running CC="..." but it didn't run fine.with the same error:
Quote:
checking whether the C compiler works.. configure: error: in `/mnt/lfs/sources/binutils-build':
configure: error: cannot run C compiled programs.
Ch 5.9 Binutils Pass 2 Error: configure is WRONG.. DO THIS!
Ch 5.9 Binutils Pass 2 Error: Cannot run C compiled programs ## CONFIGURE SCRIPT IS WRONG
after beating my head against the wall for 3 days I finally figured out HOW to get the ./configure script to make a Makefile that will use a newly compiled gcc.. ie: the new cross-compiled gcc built from directions at the Linux From Scratch website..
I got hung up on Binutils (2nd pass).. at this point you MUST get the compiler to use the new gcc.. your new gcc should be here: /tools/bin/i686-lfs-linux-gnu=gcc
trying to do the configure as Linux From Scratch (on the Binutils 2nd pass) says WON'T WORK.. trust me! I have tried everything..
... sorry, but I am still have problems.. will post as soon as I work the issues out..
sorry, Bob
Last edited by linux_tales; 07-23-2011 at 09:39 PM.
Can you start a new thread when you have an LFS issue. This one is rather old and I doubt you are trying to build LFS 6.6.
Quote:
trying to do the configure as Linux From Scratch (on the Binutils 2nd pass) says WON'T WORK.. trust me! I have tried everything..
Dumping a statement like this without any useful information isn't the way to go. Please tell us a bit more:
- Which LFS version are you trying to build,
- What are you using as host for building LFS,
- If you do not use the LFS livsCD, did you make your host compliant,
- What are the error messages you are seeing (10-15 lines before the Cannot run C compiled programs message).
I seriously doubt that the book doesn't work. Many have successfully build an LFS system, including me on different hardware platforms. Don't get me wrong, your hardware might be the exception to the rule, but in almost all the cases the builder did something wrong in the step they are working on or one of the previous steps.
I believe the problem is the configure script above which uses this statement: CC="$LFS_TGT-gcc -B/tools/lib/" is not correct.. {{ by the way the binary is in the bin, not the lib directory }}
I got this to work on the first pass but not the second.. it really is a PATH problem I believe.. the ./configure script finds the gcc binary but upon testing calls an error.. it keeps trying to use the default "host" binary..
Cheers,
Bob
Last edited by linux_tales; 07-24-2011 at 09:24 AM.
by the way, if I gave the impression that there is something wrong with the LFS website, that is incorrect and I apologize.. I believe the guy that created the LFS concept and the website is brilliant.. I am sure most of the problems we peons have in creating Linux distros are because of our own making, NOT from LFS.
Cheers,
Bob
Last edited by linux_tales; 07-24-2011 at 06:25 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.