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

CRIS linking problems



Dear Sirs,

I am trying to compile an application to ETRAX100/ELinux under Linux.
My project consists of several C/C++ files. One of the first problems
I faced was when trying to include .h files which contain C++ specific
keywords, 
to .c files. This produced some errors when compiling. As far as I know, the
"-x c++" option is used for "forcing" CRIS compiler to compile everything as
C++
There is a line in Rules.elinux:
CXX = gcc_cris -melinux -x c++

And Rules.elinux is included in Makefile:
include	../Rules.elinux

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?

Second problem, why is the "-nostdlib" option in example Makefile, that I
suppose
came with Axis:

# LDFLAGS   += -nostdlib -L$(prefix)/lib # Original, free not found when
linking
LDFLAGS   += -L$(prefix)/lib # removed -nostdlib

Using following LDFLAGS in Makefile:
LDFLAGS   += -nostdlib -L$(prefix)/lib # Original, free not found when
linking

Produces error when linking (original object names changed):

gcc_cris -melinux -s -symbolic -nostdlib -L/projects/12150/axis/eroot/lib
/proj
ects/12150/axis/eroot/lib/uccrt0.o main.o file1.o file2.o file3.o file4.o
file5.o 
file6.o file7.o file8.o file9.o file10.o file11.o file12.o file13.o file14.o

file15.o file16.o file17.o file18.o file19.o -lucc -lic -lg
cc -o main
/usr/local/cris/lib/gcc-lib/cris/2.7.2/libgcc.a(_op_delete.o): In function
`____
builtin_delete':
/data/software_packages/axis/cris-dist-1.7/./gcc/./libgcc2.c(.text+0xc):
undefin
ed reference to `_free'
make: *** [main] Error 1

I assume the "-nostdlib" is here for memory saving purposes? However, 
standard library function "free" seems to be located in stdlib, so I guess
stdlib is
also needed? On the other hand, in our sources codes, there isn't a single
call
to function free.

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:

gcc_cris -melinux -s -symbolic -L/projects/12150/axis/eroot/lib
/projects/12150
/axis/eroot/lib/uccrt0.o main.o file1.o file2.o file3.o file4.o file5.o
file6.o 
file7.o file8.o file9.o file10.o file11.o file12.o file13.o file14.o
file15.o 
file16.o file17.o file18.o file19.o -lucc -lic -lgcc -o main
/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

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?

BR,

--
  Timo Sakari, email: Timo.Sakari@xxxxxxx.fi

  "#define QUESTION ((bb) || !(bb))"    - Shakespeare

Makefile

Rules.elinux