Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

hello_world makefile

Altera_Forum
Honored Contributor II
1,182 Views

Hi people 

 

I have made the standard hello world as a test app for my custom board. 

 

 

Makefile 

include Rules.mak ECLIPSE_WORKSPACE := /cygdrive/c/altera/kits/nios2/bin/eclipse/workspace KERNEL_PROJECT := hello_world BUILDDIR := $(ECLIPSE_WORKSPACE)/$(KERNEL_PROJECT)/build/include CFLAGS += -O0 -g -I$(BUILDDIR) all: hello.exe hello.gdb 

 

Rules.mak is the standard file and has not been modified. 

 

When I try to compile the code shown here below the error below the code is shown. 

 

Code: hello.cpp 

#include "stdio.h" int main(int argc, char *argv) {  printf("Hello world test app!!!\n");  return 1; } 

 

console : compiler/linker  

make -k all  no emulation specific options. nios2-elf-gcc -nostdinc -D__linux__ -O2 -I"c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/include -I/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1//include -fno-optimize-sibling-calls -mhw-mul -mhw-mulx -O0 -g -I/cygdrive/c/altera/kits/nios2/bin/eclipse/workspace/hello_world/build/include -Wall -o hello.o hello.cpp nios2-elf-gcc -r -d -L"c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/lib -o hello.bin hello.o /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/lib/libm.a /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/libgcc.a "c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/lib/libc.a hello.o(.text+0x0): In function `_start': : multiple definition of `_start' /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/lib/crt0.o(.text+0x0): first defined here collect2: ld returned 1 exit status make: *** Error 1 make: Target `all' not remade because of errors. 

 

 

Hope some of you can tell me what I am missing here. 

thx upfront. 

 

Regards 

Michael E
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
345 Views

Hi 

 

Just an update 

 

1) have changed my makefile to the one shown below 

# # configurable options#  - set DEBUG = 1 to turn on debugging support# DEBUG = 1 PROJ_NAME = hello INSTALL_DIR = PROGS := $(PROJ_NAME).exe CFLAGS += # # You should not need to modify anything beyond this point# # TOPDIR = .. include Rules.mak ifeq '$(DEBUG)' '1'     PROGS += $(PROGS:.exe=.gdb) endif all: $(PROGS) .PHONY: clean clean:     -rm -f *. *.elf *.gdb *.bin *.exe .PHONY: install install: all ifeq "$(INSTALL_DIR)" ""     $(error No installation directory specified) endif     mkdir -p $(INSTALL_DIR)/bin     install -v $(filter %.exe, $(PROGS)) $(INSTALL_DIR)/bin 

 

2) I have compiled a custom uClibc library ( used the guide for this ) 

 

3) Have tried overwriting the lib folder with the new files created by my custom compilation. 

 

c:\altera\kits\nios2\bin\eclipse\plugins\com.microtronix.nios2linux.uClibc_1.4.0\lib 

 

has been replaced by the files from  

 

C:\altera\kits\nios2\examples\software\linux\ECTKernel\lib 

 

 

Still I get the console output 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

make -k all  

  no emulation specific options. 

nios2-elf-gcc  -nostdinc -D__linux__ -O0 -g  -I"c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/include -I/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1//include -fno-optimize-sibling-calls -mhw-mul -mhw-mulx -Wall -o hello.o hello.cpp 

nios2-elf-gcc -msys-crt0="c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/lib/crt0.o -r -d -L"c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/lib -o hello.bin hello.o /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/lib/libm.a /cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1/libgcc.a "c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/lib/libc.a 

hello.o(.text+0x0): In function `_start&#39;: 

: multiple definition of `_start&#39; 

c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0/lib/crt0.o(.text+0x0): first defined here 

collect2: ld returned 1 exit status 

make: *** [hello.bin] Error 1 

make: Target `all&#39; not remade because of errors. 

rm hello.o[/b] 

--- Quote End ---  

 

 

sugestions??? 

 

Regards 

Michael E
0 Kudos
Altera_Forum
Honored Contributor II
345 Views

Why not hello.c instead of hello.cpp? 

 

I test when *.c change to *.cpp, the same error occurs. So in my opinion, if you insist to *.cpp you should add some proper FLAG to tell compiler to compile *.cpp.
0 Kudos
Altera_Forum
Honored Contributor II
345 Views

Hi mountain 

 

Thx dude. 

That was it. Changed to .c now it compiles http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/ohmy.gif ) 

 

Regards 

Michael E
0 Kudos
Reply