Modify Makefile for cross compiling with Xenomai [message #1818205] |
Tue, 10 December 2019 03:38  |
Eclipse User |
|
|
|
Goodmorning,
I'm using a Beaglebone black and currently I can cross compile and directly execute an application, which uses Xenomai, using CCS and creating the project type "Makefile project with Existing Code". I used the following Makefile where the application name is: cyclic_test.
MAIN_SRC = cyclic_test
TARGET = cyclic_test
SKIN := alchemy
CFLAGS := $(shell /usr/xenomai/bin/xeno-config --skin=$(SKIN) --cflags)
LDFLAGS := $(shell /usr/xenomai/bin/xeno-config --skin=$(SKIN) --ldflags)
#CC := $(shell /usr/xenomai/bin/xeno-config --cc)
CC := /home/davide/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
all: $(TARGET)
$(TARGET):$(MAIN_SRC).c
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
clean:
@rm $(MAIN_SRC)
Now I would like to use in CCS, the standard project type "C Project".
Searching in the net for modifing the generated Makefile, I found that many people modify the compiling and linker settings.
First I defined two Build Variables in C/C++ Build -> Build Variables:
CFLAGS = $(shell /usr/xenomai/bin/xeno-config --skin=alchemy --cflags)
LDFLAGS = $(shell /usr/xenomai/bin/xeno-config --skin=alchemy --ldflags)
Then I modify the Command line pattern in C/C++ Build -> Settings -> Tool Settings -> Cross GCC Compiler as:
${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${CFLAGS} ${LDFLAGS}
At last I modified the Command line pattern in C/C++ Build -> Settings -> Tool Settings ->Cross GCC Linker as:
${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${CFLAGS} ${LDFLAGS}
As a result, I obtain the following:
09:03:58 **** Build of configuration Release for project XenomaiTest ****
make all
Building file: ../cyclic_test.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -o "cyclic_test.o" "../cyclic_test.c" -I/usr/xenomai/include/cobalt -I/usr/xenomai/include -march=armv7-a -mfpu=vfp3 -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__COBALT__ -I/usr/xenomai/include/alchemy -Wl,--no-as-needed -Wl,@/usr/xenomai/lib/modechk.wrappers -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt -march=armv7-a -mfpu=vfp3
Finished building: ../cyclic_test.c
Building target: XenomaiTest
Invoking: Cross GCC Linker
arm-linux-gnueabihf-gcc -o "XenomaiTest" ./cyclic_test.o -Wl,--no-as-needed -Wl,@/usr/xenomai/lib/modechk.wrappers -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lcobalt -lmodechk -lpthread -lrt -march=armv7-a -mfpu=vfp3
/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o: in function `_fini':
/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/../sysdeps/arm/crti.S:97: multiple definition of `_fini'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/crti.o:/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/../sysdeps/arm/crti.S:97: first defined here
/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o: in function `__data_start':
:(.data+0x0): multiple definition of `__data_start'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/crt1.o:static-reloc.c:(.data+0x0): first defined here
/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o: in function `__data_start':
makefile:35: recipe for target 'XenomaiTest' failed
:(.data+0x4): multiple definition of `__dso_handle'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/crtbegin.o:(.data+0x0): first defined here
/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o:/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/init.c:23: multiple definition of `_IO_stdin_used'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/crt1.o:/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/init.c:23: first defined here
/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ./cyclic_test.o: in function `_start':
/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/../sysdeps/arm/start.S:79: multiple definition of `_start'; /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/crt1.o:/tmp/dgboter/bbs/rhev-vm8--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/glibc/csu/../sysdeps/arm/start.S:79: first defined here
/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/xenomai/lib/xenomai/bootstrap.o: in function `__wrap_main':
bootstrap.c:(.text+0x0): multiple definition of `xenomai_main'; ./cyclic_test.o::(.text+0x358): first defined here
/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /usr/xenomai/lib/xenomai/bootstrap.o:(.rodata+0x0): multiple definition of `xenomai_auto_bootstrap'; ./cyclic_test.o:(.rodata+0x78): first defined here
/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'; ./cyclic_test.o::(.data+0x8): first defined here
collect2: error: ld returned 1 exit status
make: *** [XenomaiTest] Error 1
As you can see, the compiling phase is correctly carried out nad generate the object files. The problem is with the linker phase. Have you got any ideas?
Thank you.
Regards,
Davide Brunelli
|
|
|
Re: Modify Makefile for cross compiling with Xenomai [message #1818249 is a reply to message #1818205] |
Tue, 10 December 2019 17:21  |
Eclipse User |
|
|
|
Eclipse expects the compile and link steps are separate.
In fact, it usually adds -c to the compile so that it is compile only.
You appear to have defeated that.
FYI: The command and link options to GCC are positionally sensitive.
It may also be caused by adding the LDFLAGS to the compile step.
Possibly because if the --dynamic-list option.
I don't have your files to try anything so can't really say.
The error you're getting is "multiple definition of xxx".
It isn't clear how that happened.
I suggest you create an HelloWorld project to see what Eclipse (CDT actually) expects.
For the most part, it's better to have your own edited Makefile instead of trying to force Eclipse into making a particular one.
Manipulating makefiles is off-topic for this forum as Make is an external tool.
|
|
|
Powered by
FUDForum. Page generated in 0.07092 seconds