This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems linking multiple files


>>>>> "Erant" == Erant  <erantimus@gmail.com> writes:

    Erant> I've recently been getting to know eCos, and have written a
    Erant> simple USB slave driver. In order to use this driver, I've
    Erant> also written a simple API to go with it. This API resides
    Erant> in a folder in my application folder, and consist of three
    Erant> separate C files. I've successfully built applications
    Erant> consisting of single C files, however multiple C files pose
    Erant> a problem. When I attempt to link these C files into my
    Erant> main application, I run into a lot of 'multiple
    Erant> definitions' in the linking stage, all of the following
    Erant> form:

    Erant> maxmux/platform.o: In function `atof':
    Erant> /Users/tristan/Projects/devboard/src/ecos/app/../install/include/cyg/libc/stdlib/atox.inl:124: multiple definition of `atof'
    Erant> main.o:/Users/tristan/Projects/devboard/src/ecos/app/../install/include/cyg/libc/stdlib/atox.inl:124: first defined here

    Erant> The conflicts are between all three library files and my main.o file.

    Erant> I've been using the following commandlines to attempt to build my project:

    Erant> arm-eabi-gcc -c -v -g -I../install/include/ -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -O2 -DECOS -DECOS_USB main.c -std=c99 -o main.o
    Erant> arm-eabi-gcc -c -v -g -I../install/include/ -O2 -DECOS -DECOS_USB maxmux/maxmux.c -std=c99 -o maxmux/maxmux.o
    Erant> arm-eabi-gcc -c -v -g -I../install/include/ -O2 -DECOS -DECOS_USB maxmux/ring.c -std=c99 -o maxmux/ring.o
    Erant> arm-eabi-gcc -c -v -g -I../install/include/ -O2 -DECOS -DECOS_USB maxmux/platform.c -std=c99 -o maxmux/platform.o
    Erant> arm-eabi-gcc -g -v -I../install/include/ -L../install/lib -Wl,-static -nostdlib -DECOS -DECOS_USB main.o maxmux/maxmux.o maxmux/ring.o maxmux/platform.o -std=c99 -Ttarget.ld -o main.elf

Much of the core eCos code predates the C99 standard. The main issue
here is that -std=c99 changes the semantics of inline function
declarations in a way that is incompatible with various eCos headers.
One solution is to remove -std=c99 from the compiler flags. Another
solution, which may or may not work for you, is to add -fgnu89-inline
to the flags, resetting the semantics to the old version. Obviously if
your own headers depend on the C99 behaviour then you will run into
further difficulties. The long term solution is to fix the eCos
headers, but that is a non-trivial change.

Bart

-- 
Bart Veer                                   eCos Configuration Architect
eCosCentric Limited    The eCos experts      http://www.ecoscentric.com/
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
Besuchen Sie uns vom 2-4 März auf der Embedded World 2010, Stand 11-208
Visit us at Embedded World 2010, Nürnberg-Germany, 2-4 Mar, Stand 11-208

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]