- Linker error when building a project in NBEclipse with EnableSystemDiagnostics() enabled in UserMain
Linker error when building a project in NBEclipse with EnableSystemDiagnostics() enabled in UserMain
Known Affected Versions
3.5.5
3.5.6
Description
This error will only affect imported examples and custom applications with EnableSystemDiagnostics() enabled. We typically do not recommend this option to be enabled on release versions of code, but it is helpful while developing an application. This option is enabled in all netburner examples.
System Diagnostics allows you to see which configuration options are enabled / disabled in a build at runtime. They will populate a page on the config server webpage (http://<device.IP>:20034)
The error message is similar to the following:
Code: Select all
Invoking: GNU C/C++ Linker
nblibs\libnetburner.a(diagnostics_set.o): In function `DiagLinkTime::ServeContent(int)':
C:/nburn/nbrtos/source/diagnostics_set.cpp:46: undefined reference to `LinkTime'
To fix the linker error we recommend one of two methods.
1. Disabled EnableSystemDiagnostics()
Comment out the line from UserMain to disable diagnostics. This is the easiest workaround. Diagnostics will not be available for viewing on the config server web page.
2. Edit makefile.targets in the NBEclipse project directory
Add the following text to the end of the file
Code: Select all
ifneq ($(strip $(ELF)),)
.SECONDEXPANSION:
ELF1 := $(firstword $(ELF))
TIMESTAMP_SRC = "extern const char LinkTime[]; const char LinkTime[] = \"`date -u +"%Y-%m-%dT%H:%M:%SZ"`\";"
LINKSTAMP_OBJ := $(dir $(ELF1))$(notdir $(basename $(ELF1)))_linkDTStamp.o
USER_OBJS += $(LINKSTAMP_OBJ)
$(ELF1): $(LINKSTAMP_OBJ)
$(LINKSTAMP_OBJ): $$(filter-out $$(LINKSTAMP_OBJ),$$(OBJS) $$(USER_OBJS)) $$(LIBS) makefile objects.mk sources.mk subdir.mk
@echo "Time stamping $@"
@mkdir -p $(dir $@)
@echo $(TIMESTAMP_SRC) | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -xc++ -c -
endif
Resolved
3.5.6 properly creates makefile.targets with the additional code to fix this. Preexisting projects that are getting this error will still need to be modified to resolve this using one of the methods above.
---