[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CRIS linking problems

> From: Timo.Sakari@xxxxxxx.fi
> Date:   Mon, 29 Jan 2001 16:12:10 +0200

> However, "-x c++" has no effect when placed in Rules.elinux. Instead, it has
> to be placed to Makefile:
> # CFLAGS   += -nostdinc -I$(prefix)/include/uC-libc # Original, doesn't
> compile with C-files
> CFLAGS   += -nostdinc -I$(prefix)/include/uC-libc -x c++ # Added -x c++
> I am missing something here?

(Sorry, I'll have to let someone else answer this one, someone
with more up-to-date knowledge about the build framework.)

> /data/software_packages/axis/cris-dist-1.7/./gcc/./libgcc2.c(.text+0xc):
> undefined reference to `_free'
> make: *** [main] Error 1
> I assume the "-nostdlib" is here for memory saving purposes?

No, it's purpose is to override the installed library.  Other
options, such as -l and -L are then used to specify another
library, uclibc (which in turn is for memory-saving purposes).
The GCC manual and info pages would tell you about -nostdlib.

> However, 
> standard library function "free" seems to be located in stdlib, so I guess

It is in libc.a actually, but I believe it is also in libucc.a.

> stdlib is
> also needed? On the other hand, in our sources codes, there isn't a single
> call
> to function free.

This is key to the problem.  As can be gleaned from the link
errors, the default operator delete calls free.  Operator delete
is found in libgcc.a.  The way the GNU linker (and other
Unix-type linkers) works, it then searches for free in the
*rest* of the libraries specified on the command line.  Had your
application actually used free, it would already be present.
Since there are no more libraries on the command line, linking

With -nostdlib, the system libraries are overridden.  Without,
system libraries are added *after* the libraries you specify to
the compiler.  For cris-dist-1.7, that would be the sequence
"-lgcc -lc -lic -lgcc" (note the second "-lgcc" which is there
for reasons similar to the above).  So, free would be found in
any file named libc.a on the paths specified by -L, or by
default the installed library, glibc (or perhaps the default
minimal libc.a if glibc isn't installed), while other functions
are from uclibc.  You don't want to mix libraries like that.

> So, to get rid of this problem, I changed LDFLAGS to:
> LDFLAGS   += -L$(prefix)/lib # removed -nostdlib
> This removes the _free problem, but brings along other one:

> /usr/local/cris/lib/gcc-lib/cris/2.7.2/rld-cris: cannot open
> elinux/lib/crt0.o:
> No such file or directory
> make: *** [main] Error 1

By removing -stdlib, the tools now (as is normal) search for
crt0.o as the start-up file, but for some reason it is not found
on the specified paths.  Perhaps because you don't have glibc
installed.  (It's less important, as the options are wrong

> As far as I know, I have configured the environtment properly, I have set
> ELINUX=1, executed
> init_env, and managed to compile and run a simple Hello App in
> Axis/Etrax100.
> I am quite new to makefiles and ETrax/CRIS, so I am propably doing something
> wrong here.
> I have attached Makefile and Rules.elinux (original filenames changed).
> Any suggestions?

It seems "-lgcc" is misplaced, presumably also in
devboard-1.0.2.  Move it to be the first, alternatively add a
*second* "-lucc" after it.  Add back "-nostdlib" and other

Since you want to compile C++, I suggest you consider upgrading
the compiler tools.

brgds, H-P