crt1.o crti.o crtbegin.o not found...

manoj
hi..

I am building a toolchain for Begal board for gcc.

I am using gcc-4.5.1 for that. Facing an error that:

crt1.o not found
crti.o not found
crtbegin.o not found.

[root@Mannu include]# locate crt1.o
/usr/lib/Mcrt1.o
/usr/lib/Scrt1.o
/usr/lib/crt1.o
/usr/lib/gcrt1.o
.
.
I got this after locate.
.
.
somebody put some light on this problem.

Thanks

Manoj  |   India

davef
I think the Beagle board forum would be a more appropriate place.

manoj
can you tell me an appropriate link.

pankaj hooda
m also facing the same problem...but no solutions yet

davef
?? https://groups.google.com/forum/#!forum/beagleboard

manoj
thnx davef...:-)

redeagle
The problem is, that your libc is not available at this point because you
cannot build it without the gcc :) - So you first have to create a "broken"
gcc without libc

make -k all-target-libgcc
make -i install-target-libgcc

then you can build the libc and after that, you can rebuild the gcc again
to have a full working one


I'm working on a Cross-Compiler for the Parrot ARDrone which uses a linux
2.6.27 running on an ARM926EJ-S
My logfile may help you: http://reos.re.funpic.de/doku.php?id=ot:ardronexc

maddy
where exactly to run this command...??

or should I show you my script...??

redeagle
Its for the first build of your cross-compiler.

In general:

(1)
prepare the gcc-source
configure it (./configure …) - but enable as less as possible features
compile it (make all-gcc ; make install all-gcc)

(2)
after that you have to create the libgcc but without the necessary glibc.
This is done by just ignoring the dependency to the glibc:
make -k all-target-libgcc
make -i install-target-libgcc

now you have a half working cross-compiler to use it to compile glibc.

(3)
Cross-compile the glibc.

(4)
configure the gcc again, this time with all features you need (like c++
supports…)
rebuild the gcc, but this time without the -k and -i flags

---

this process may differ if you don't use glibc but newlib or dietlibc

of cause showing your script may help to precise the problem

maddy
yes...

I am using newlibc for it..
.
.
there was a compatibility issue in it..

.
.
I changed my gcc and this error has resolved bt.. a new error has
occured.i.e.

when I execute a program called hello.c
.
.
I get.
.
-lgcc not found.
.
Can you thell me somthing about it..??

redeagle
-lgcc is a parameter for the linker which tells the linker to look in
libgcc for "missing" functions.
libgcc contains functions the gcc uses internally when it compiles your
code (e.g. floatingpoint emulation))

When you build your crosscompiler for the last time you first should build
just the cross-compiler:

make all-gcc
make install-gcc

after that you have to compile libgcc:

make all-target-libgcc
make install-target-libgcc

then you can build the rest like libstd++:

make
make install

maddy
sir...

I built the first stage compiler. and tried to run simple code of c.i.e.

int main()
{
}
.
.
.
but on that time it says that -lgcc not found.... the exact error is.
.
.
 /home/toolchain_project/Control-project/tools/libexec/gcc/arm-linux/4.4.4/colle
ct2
--eh-frame-hdr -dynamic-linker /lib/ld-linux.so.2 -X -m armelf_linux -p
crt1.o crti.o crtbegin.o
-L/home/toolchain_project/Control-project/tools/lib/gcc/arm-linux/4.4.4
-L/home/toolchain_project/Control-project/tools/lib/gcc/arm-linux/4.4.4/../../..
/../arm-linux/lib
/tmp/cc2ao3sc.o -lgcc -lc -lgcc crtend.o crtn.o
/home/toolchain_project/Control-project/tools/lib/gcc/arm-linux/4.4.4/../../../.
./arm-linux/bin/ld:
cannot find -lgcc
collect2: ld returned 1 exit status
.
.
.
I want to know, whether the first stage compiler can compile a simple
program like the above one...??
.
.
or is it compulsary to add libgcc also...??

redeagle
After you build the gcc (make all-gcc) you have to create the libgcc (make
all-target-libgcc)
The libgcc is needed by the gcc to compile your code - it contains some
important functions (like memcpy) your program and libc needs.

The stage one compiler cannot compile whole programs because they usually
need a libc (like glibc or newlib).
The libc is responsible for calling your main-function.

Is there a reason why you want to compile a program with a half-complete
compiler?

In short: No, the first stage compiler cannot compile whole programs, you
need libgcc.

maddy
ok sir,,

now I am trying to build it by using glibc. another error came that .
.
.
the compiler must support c cleanup handling.

redeagle
i guess you haven't configures glibc correct.
I had to add "libc_cv_c_cleanup=yes" (without the "") to the
./configure-call.
The whole configuration looks like the following line:
../configure --host=arm-none-linux-gnueabi --build=$MACHTYPE
--prefix=/opt/ardronexc/arm-none-linux-gnueabi/ --without-fp
--enable-add-ons="nptl,ports" --enable-kernel=2.6.27
--with-headers=/opt/ardronexc/arm-none-linux-gnueabi/include
--with-binutils=/opt/ardronexc/arm-none-linux-gnueabi/bin
libc_cv_forced_unwind=yes libc_cv_ctors_header=yes libc_cv_c_cleanup=yes

(see http://reos.re.funpic.de/doku.php?id=ot:ardronexc#glibc )
This may differ depending on your glibc-version and your previous steps

maddy
Thanks a lot sir....:-)
.
.
This problem is solved.
.
After completing the static compiler when I executed the hello.c program...
I am facing this error...
.
.
.
[root@Mannu sysroot]# arm-none-linux-gnueabi-gcc /home/hello.c
/opt/arm/lib/gcc/arm-none-linux-gnueabi/4.4.4/../../../../arm-none-linux-gnueabi
/bin/ld:
this linker was not configured to use sysroots
collect2: ld returned 1 exit status
.
.
what can be the reason of it...??

redeagle
After a bit googleing i found out that this may be a bug in GCC.
Did you use the --with-sysroot= - option?
Try without it and it may work

maddy
After removing --with-sysroot... the error comes at the time of execution
that -lgcc_s not found...
.
.
someone on net told me that Fedora 15 can not be used for the development
of the cross-compiler...!!
.
.
Is it true. He told me to use Fedora 17 or Ubuntoo.
.
What should I do...??

redeagle
First: I build two different cross-compiler on my Fedora 15, and there is
absolutely no reason why Fedora (or any other Linux distribution) should
not be usable for building a cross-compiler :)
I also build the same cross-compiler on a friends Fedora 17 - there was no
difference.

I can remember that I had the same "-lgcc_s not found"-problem. But I
cannot really remember what I did to solve it, but I think I just forgot to
build the libgcc.

(Where in the building-process are you? And how does your configurations
look like?)

My first-stage-gcc - configuration:
../configure --prefix=/opt/ardronexc --enable-languages="c"
--with-arch=armv5te --with-float=soft --disable-nls --without-headers
--disable-threads --with-abi=aapcs-linux --build=$MACHTYPE --host=$MACHTYPE
--target=arm-none-linux-gnueabi

After you build the gcc, you have to build a half-complete libgcc

make -k all-target-libgcc
make -i install-target-libgcc

-k do as much as possible. 
-i ignore errors. There are some missing parts which makes make not to
install everything. With -i all available parts will be installed.

maddy
sir,

I have used two approaches... First one was provided by my company and the
second one is this... ://pmc.polytechnique.fr/pagesperso/dc/arm-en.html
.
.
In first method I have used newlib and in the second one I used glibc.
.
.
I am explaining you the first method.i.e
.
.
configured binutils-2.20.1
.
.
configured kernel-2.6.10 headers
.
.
configured gcc for the first time like this.:

""""../gcc-4.4.4/configure --target=$TARGET --prefix=$PREFIX
--enable-interwork --disable-multilib --enable-languages="c" --with-newlib
--with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs
--without-headers --disable-shared --disable-nls --with-gnu-as
--with-gnu-ld""""
.
make -j 2 all-gcc
make install-gcc
make -k all-target-libgcc
make -i install-target-libgcc
.
.
.
configured newlibc like this..
.
.
../newlib-1.19.0/configure --target=$TARGET --prefix=$PREFIX
--with-headers=/home/toolchain_project/Control-project/build-tools/newlib-1.19.0
/libgloss
--enable-interwork --disable-multilib --with-gnu-as --with-gnu-ld
--disable-nls.
.
.
.
then final gcc like this...
.
.
../gcc-4.4.4/configure --target=$TARGET --prefix=$PREFIX --enable-interwork
--disable-multilib --enable-languages="c" --with-newlib
--with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs
--without-headers --disable-shared --disable-libssp --disable-nls
--disable-hardfloat --enable-threads=single --with-gnu-as --with-gnu-ld.
.
I have used gmp,mpfr and mpc.
.
.

redeagle
And at which point do you have trouble with libgcc?

Did you use the crosscompiler for compiling the newlib? If you're not sure,
you can check it like this:
readelf -h libc.a | grep Machine | head -n 1

maddy
error occurs at last step's make -j 2.
.
.
it says.. c compiler can not create executables.
.
.
Now, where is the exact problem I am not sure.
.
.
I have tried on 4 different kernels.
glibc-2.14 worked fine with kernel 2.6.32.
.
.
but in that process, when I try to configure gmp... it says...
Can not find a working kernel.

maddy
sir.. I noticed that when I run make all-target-gcc after first stage
configuration... it shows..
.
.
.
In file included from
../../../../sources/gcc-4.4.4/libgcc/../gcc/libgcc2.c:29:
../../../../sources/gcc-4.4.4/libgcc/../gcc/tsystem.h:87:19: error:
stdio.h: No such file or directory
../../../../sources/gcc-4.4.4/libgcc/../gcc/tsystem.h:90:23: error:
sys/types.h: No such file or directory
../../../../sources/gcc-4.4.4/libgcc/../gcc/tsystem.h:93:19: error:
errno.h: No such file or directory
../../../../sources/gcc-4.4.4/libgcc/../gcc/tsystem.h:100:20: error:
string.h: No such file or directory
../../../../sources/gcc-4.4.4/libgcc/../gcc/tsystem.h:101:20: error:
stdlib.h: No such file or directory
../../../../sources/gcc-4.4.4/libgcc/../gcc/tsystem.h:102:20: error:
unistd.h: No such file or directory
../../../../sources/gcc-4.4.4/libgcc/../gcc/tsystem.h:108:18: error:
time.h: No such file or directory
make[1]: *** [_muldi3.o] Error 1
make[1]: Leaving directory
`/root/chain/build/amorce-gcc/arm-none-linux-gnueabi/libgcc'
make: *** [all-target-libgcc] Error 2
.
.
can u help in this.??

redeagle
sys/types.h is part of the kernel-headers. So obviously there went
something wrong during the installation of the kernel headers :)

After I configured the kernel I executed the following two commands:

/opt/oldmake/bin/make ARCH=arm headers_check
/opt/oldmake/bin/make ARCH=arm
INSTALL_HDR_PATH=/opt/ardronexc/arm-none-linux-gnueabi/ headers_install
(I need a older version of make because the new make-version was not
backwards-compatible to the old Linux 2.6.27 makefiles. This may not be
necessary with your kernel-version, but you should check if the
make-process succeeds)

It's Important that you always set ARCH=arm and that you run headers_check
before headers_install.

The missing stdlib.h and so on is because you don't have a libc at that
point. Thats why you use the -k - flag. So just ignore the libc-related
errors. 

---

And to the gmp-problem
I just created a symbol-link into the gcc-source-directory:
ln -s ../mpfr-3.1.0 mpfr
ln -s ../gmp-5.0.5 gmp
ln -s ../mpc-0.9 mpc

"If you want to build GCC but do not have the GMP library, the MPFR library
and/or the MPC library installed in a standard location and do not have
their sources present in the GCC source tree then you can explicitly
specify the directory where they are installed (`--with-gmp=gmpinstalldir',
`--with-mpfr=mpfrinstalldir', `--with-mpc=mpcinstalldir')." --
http://gcc.gnu.org/install/configure.html

redeagle
Oh, the board-software did a disadvantageous line feed :D

/opt/oldmake/bin/make ARCH=arm
INSTALL_HDR_PATH=/opt/ardronexc/arm-none-linux-gnueabi/ headers_install

is one line :)
in short: 
oldmake ARCH=arm INSTALL_HDR_PATH=../arm-none-linux-gnueabi/
headers_install

maddy
Actually I was making a very silly mistake... was using CROSS instead of
CROSS_COMPILE... .
.
successfully executed a.out on BeagleBoard.
Thank god 
.
.
Sir, you helped me a lot... thank you very much sir.
.
.
can you guide me.. what should I do now as now my cross-compiler is done.??

redeagle
You can do everything you want :)
Cross-Compile the kernel and install it on your board, build libs you want
to use, …

Maddy
sir..

I just need a start, want to cross-compile the kernel from scratch.
.
.
Tell me some links or the way to startup. Are you talking about a native
compiler for the ARM..??
.
.
Please give me a start.

redeagle
Compiling the kernel for your board should be really easy now - well, with
a but luck :)

Some points that are importang:
 * Patch the kernel so that it fits to your board
 * Find a configuration or create one by yourself (this may be a bit
painful)
 * find a root-directory (this may influence your configuration (ABI,
Floatingpoint-handling and so on)
 * build everything
 * install it
 * play with it :)

You should inform you a bit about some distributions for ARM. I have a
Slackware 13.37 on my mini6410, but I read a lot about Fedora17 (I use F15
on my PC)
So you first have to figure out which kernel (version) and which
rootfs/distribution you want to use.

maddy
Sir.. I have ported Angstrome image on board that is of 169 MB.
.
Have started working on Native compiler for ARM.
.
.
After that I'll go for my own root file system..
.
.
Hoping that i'll get success in that as well.
.
.
I'll be in your contact.

Thanks

maddy
Sir, 
While building the native compiler for ARM, Facing the following error.
.
.


checking for /opt/arm/bin/arm-none-linux-gnueabi-gcc option to accept ISO
C89... none needed
checking for /opt/arm/bin/arm-none-linux-gnueabi-gcc option to accept ISO
C99... -std=gnu99
checking for /opt/arm/bin/arm-none-linux-gnueabi-gcc -std=gnu99 option to
accept ISO Standard C... (cached) -std=gnu99
checking how to run the C preprocessor...
/opt/arm/bin/arm-none-linux-gnueabi-gcc -std=gnu99 -E
checking build system compiler /opt/arm/bin/arm-none-linux-gnueabi-gcc...
yes
checking for build system preprocessor...
/opt/arm/bin/arm-none-linux-gnueabi-gcc -E
checking for build system executable suffix... configure: error: Cannot
determine executable suffix
make[1]: *** [configure-gmp] Error 1
make[1]: Leaving directory `/root/native_arm/build/native-gcc'
.
.
.
I used following command to configure.
.
.
 ../../sources/gcc-4.4.4/configure --build=$BUILDMACH --host=$TARGETMACH
--target=$TARGETMACH --prefix=$INSTALLDIR --with-gmp-include=$(pwd)/gmp
--with-gmp-lib=$(pwd)/gmp/.libs --enable-language=c --with-gnueabi-ld
--with-gnueabi-as --enable-threads=posix --disable-multilib
--disable-werror
.
.
.
after make the above error occured..
.
.
.
some times this error is occuring.
.
.
checking build system compiler /opt/arm/bin/arm-none-linux-gnueabi-gcc...
no
configure: error: Specified CC_FOR_BUILD doesn't seem to work
make[1]: *** [configure-gmp] Error 1
make[1]: Leaving directory `/root/native_arm/build/native-gcc'
make: *** [all] Error 2
.
.
.

redeagle
sorry, I never did this, so I have no experience with this :)
But have you set the PATH-variable correct?

maddy
yes sir,

My path variables are correct but i am not sure about the options used with
configurations.

Marschall Timoschenko
I think you both are mistaken.

The some magic kind of compilation doe not solve the problem itself. The
problem is that for the configuration  
    arm-none-linux-gnueabi
the GCC versions from 4.4.4 till 4.6.2. don't provide right ./configure,
thereby you inevitably fall into trouble (with libquadmath, libgomp,
libmudflap, etc).

Switch newer GCC version where this bug is presumably fixed.

SSE, eMbeddora LLC,

redeagle
You may be right :)
I used the 4.7.0 source :)

Marschall Timoschenko
hi redeagle, that's right my comment about GCC version is a bit pointless.

the truth is:

a) his "./configure"  set of configurations does not provide him a
compilable Makefile (+sett of directories)

b) his first approach mentioned in commend of <2012-06-25 11:39:38> is
useless on arm-none-linux-gnueabi. I.e. only that approach which deploys
the GLIBC will be workable.  

-------------

NOTE: as for other targets he can use his "first" approach (mentioned in
commend of <2012-06-25 11:39:38>)

Marschall Timoschenko
forgive me guys, just another "meo" from my corner: 

1. Maddy, as long as you use compile for Linux ( arm-none-linux-gnueabi 
)you may forget about NEWLIB. NEWLIB is for bare metal ;platforms, not for
Linux or other OSs. (with exception of set of _very rare cases. meybe empty
set. )

2. The franzosische link (//pmc.polytechnique.fr/pagesperso/dc/arm-en.html)
is a bit odd as on me. I haven't managed with finding BINUTILS 2.20 across
the net (I mean official GNU sites, not garage compilations) and the
procedure described in there seems to be a bit longer than should to. 

Did you really manage to build  it?

---------
SSE, eMbeddora LLC,

maddy
Hi Marschall Timoschenko,

I used the following versions and successfully configured the
cross-compiler for ARM.

binutils 2.20.1
gcc 4.4.4
linux 2.6.32
glibc 2.14

and was able to configure it.
Configured images like uImage, MLO, u-boot for beagleboard but still unable
to insert modules on it. Because I don't have a compiler for that.

James Chan
use gcc -B lib_path_containing_crt?.o

Amit Prakash
While compiling glibc-2.13 I am getting error:

/usr/bin/ld: cannot find -lgcc_eh
/usr/bin/ld: cannot find -lgcc_eh
collect2: ld returned 1 exit status
make[2]: ***
[/home/amit/toolchain/build-tools/build-glibc/iconv/iconvconfig] Error 1
make[2]: Leaving directory
`/home/amit/toolchain/build-tools/glibc-2.13/iconv'
make[1]: *** [iconv/others] Error 2
make[1]: Leaving directory `/home/amit/toolchain/build-tools/glibc-2.13'
make: *** [all] Error 2

I have configured like 

../glibc-2.13/configure --prefix=/home/amit/toolchain/tools/
--target=arm-unknown-linux-gnueabi
--with-headers=/home/amit/toolchain/tools/arm-unknown-linux-gnueabi/include/
--enable-add-ons=/home/amit/toolchain/build-tools/glibc-2.13/glibc-ports-2.13/,n
ptl
--disable-shared --disable-profile  --with-tls --enable-interwork
libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes

Firo
I just install libgcc-s-dev and fix similar issue on another distribution.