Altera_Forum
Honored Contributor
21 years agolibs for NIOSII
Hi all, do anyone have found information about building a library for the niosII and how I can use this library in IDE projects? Thank you for help. Siegmar
Hello Sigiz,
The example I sent to you last night is capable of debugging source code built in the external library, as the Nios II IDE does have information about how that library is built . Add the line: CFLAGS = -g to the libcommon.a Makefile. Rebuild the libcommon.a library project. Then rebuild the hello_world_2 application project and any other project which links against the common library. The resulting Makefile for the Nios II IDE Advanced project which builds the common library then would look as follows: ----------------------------------------------------------------------------------------------------------------- CC = nios2-elf-gcc AR = nios2-elf-ar CFLAGS = -g LIB = common OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) all: lib$(LIB).a lib$(LIB).a: $(OBJS) Makefile $(AR) src $@ $(OBJS) clean: $(RM) *.o lib$(LIB).a ----------------------------------------------------------------------------------------------------------------- The makefile for the Nios II IDE Application Project which is generated automatically by the Nios II IDE does not need to change, and still looks like the following. I am repeating it here primarily for the benefit of those who would like to see how this makefile defines dependencies for the common library, but have not seen the Word .doc format application note I sent to you: Note that there are comments which mention how the Nios II IDE application properties page can be modified to add the makefile dependency for the common library project into the makefile variables named CFLAGS, LDFLAGS and LIBS. These comments refer to the steps I detailed in the screen shots I sent to you in the Word .doc format application note. The makefile for the Nios II IDE Application Project follows: ----------------------------------------------------------------------------------------------------------------- # ********************************************************************** # # THIS IS AN AUTO-GENERATED FILE. DO NOT EDIT DIRECTLY# # To change the settings in here:# - Right click on the project# - Select "Properties" option# - Use property pages to set options. Details given below # # ********************************************************************** # These flags can be set from C/C++ build property page -> nios2-elf-gcc -> General CFLAGS = -DALT_DEBUG -O0 -g -I/cygdrive/c/Common_Library -Wall ASFLAGS = -g # These flags can be set from C/C++ build property page -> nios2-elf-gcc.linker -> General LDFLAGS := -L/cygdrive/c/Common_Library LIBS := -lcommon LIBS += -lm RM := rm -rf # This project PROJECT := hello_world_2# Location of this project APP_DIR :=C:/altera/kits/nios2/examples/verilog/niosII_stratix_1s40/full_featured/software/hello_world_2 # Configuration for application project# The configuration can be changed from C/C++ build property page -> Configuration drop-down box.# If changed a new configuration folder (e.g. Release) is generated with all the generated and built files APP_CONFIG := Debug # Referenced system library & location. # These can be changed from App Options property page SYSTEM_NAME := hello_world_2_syslib SYSTEM_DIR := C:/altera/kits/nios2/examples/verilog/niosII_stratix_1s40/full_featured/software/hello_world_2_syslib # Configuration for system library project# The configuration can be changed from system library properties -> C/C++ build -> Configuration drop-down box.# If changed a new configuration folder (e.g. Release) is generated with all the generated and built files SYS_CONFIG := Debug # Change this setting from Window->Preferences->Nios II Run and Build Settings DO_MAKE_OBJDUMP := 0 # Autogenerated list of subdirectories which contain source files SUBDIRS := . # Include the makefiles for each source subdirectory -include ${patsubst %, %/subdir.mk, $(SUBDIRS)} MAKEFILE_LIST += $(patsubst %, %/subdir.mk, $(SUBDIRS)) # Include makefile for the OS we are building on as specified in system library project APP_MAKEFILE := C:/altera/kits/nios2/components/altera_hal/build/app.mk include $(APP_MAKEFILE) -----------------------------------------------------------------------------------------------------------------