7.8. Troubleshooting build projects failures

7.8.1. Solving multiple definition errors

If you encounter multiple definition errors (see following errors examples) when linking a Wind River Workbench Real Time Process Application Project converted to an Ada Project, add “-r” and “-nostdlib” ada switches to the linker options to avoid linking with GNAT libraries.

multiple definition of `__argc'
multiple definition of `__argv'
multiple definition of `__copyArgcArgv'
multiple definition of `__copyEnvArr'
multiple definition of `__fini_atexit_nodep'
multiple definition of `__getAuxvPtr'
multiple definition of `__registerFini'
multiple definition of `__saveArgs'
multiple definition of `__setAuxvPtr'
multiple definition of `_crtSignalInit'
multiple definition of `_crtTaskInit'
multiple definition of `_start'
multiple definition of `environ'

To add “-r” and “-nostdlib” switches to the linker options, run the “GNAT Project > Edit GPR File” contextual menu on your GNAT project, and add “-r” and “-nostdlib” switches to ada default switches the Linker package.

package Linker is
   for Default_Switches ("Ada") use ("-r", "-nostdlib");
end Linker;

Note: If you forget to add “-r” ada switches to the linker options you may get the following errors.

undefined reference to `memcmp'
undefined reference to `memmove'

If you encounter multiple definition errors (see following errors examples) when linking a Wind River Workbench Downloadable Kernel Module Project converted to an Ada Project, add the “-noauto-register” Ada switch to the linker options to prevents conflicts with the OS-provided static constructors and destructors that are added into DKM projects by Workbench when it builds an application image.

multiple definition of `_dtors''
multiple definition of `_ctors'

To add the “-noauto-register” switch to the linker options, run the “GNAT Project > Edit GPR File” contextual menu on your GNAT project, and add “-noauto-register” switch to the Ada default switches the Linker package.

package Linker is
   for Default_Switches ("Ada") use ("-noauto-register");
end Linker;

If you encounter multiple definition of `__wrs_rtp_base’ error when linking a Wind River Workbench Real Time Process Application Project converted to an Ada Project, add the following lines in the makefile of the project. (usually gnat.makefile file)

multiple definition of `__wrs_rtp_base'
  • At the beginning of the makefile, add the OBJCOPY definition.
# The name of objcopy tool (objcopypentium, objcopyarm or objcopyppc)
OBJCOPY=objcopy$(VX_CPU_FAMILY)
ifeq (sim,$(findstring sim,$(VX_CPU_FAMILY)))
     OBJCOPY=objcopypentium
endif
  • At the end of the $(GPRBUILD_OBJECT) target (after gprbuild call), add the $(OBJCOPY) call.
ifeq (RTP,$(PROJECT_TYPE))
# hide __wrs_rtp_base adacore definition
     $(OBJCOPY) -L __wrs_rtp_base $(GPRBUILD_OBJECT)
endif

7.8.2. Solving multiple definition of ‘main’ errors

If your project contains a main C routine and defines a main package, you will get the following error,

multiple definition of `main'

remove the useless main routine.

7.8.3. Solving undefined reference errors

If you get the following error,

undefined reference to `rmdir'

add fsapiUsr library to the project libraries.

  • run “Properties” contextual menu of the Ada project to open its properties pages.
  • select the “Build Properties” property page.
  • select the “Libraries” tab.
  • click the Add... button to add the fsapiUsr library file.
  • enter “-l fsapiUsr” to add the fsapiUsr library file.

If building a VxWorks Cert 6.x Real Time Process (RTP) Application you encounter one the following errors,

undefined reference to `_Unwind_Resume'
undefined reference to `_Unwind_RaiseException'
undefined reference to `_Unwind_DeleteException'
undefined reference to `_Unwind_ForcedUnwind'

Set RUNTIME to zfp or ravenscar-cert-rtp and rebuild the application. Edit the makefile of the project (usually gnat.makefile file) and for $(PROJECT_TYPE)=RTP change RUNTIME default value to zfp or ravenscar-cert-rtp Depending on your GNAT project file (GPR) content, you may be able to change the RUNTIME value from the Scenario Variables view. (see menu Window > Show View)

ifeq (RTP,$(PROJECT_TYPE))
     #RUNTIME=ravenscar-cert-rtp
     RUNTIME=zfp
     #RUNTIME=rtp
endif

7.8.4. Solving “No rule to make target `*-stubs.o’ errors

When building VxWorks 653 2.x application projects converted to Ada project with previous GNATbench versions, and when the application project files are not located inside the workspace, for example when they are located in a git repository, the project cannot be built because the generated $(SSL_NAME)-stubs.o file cannot be located.

Edit the makefile of the project (usually gnat.makefile file) and replace the occurrences of $(WS_ROOT_DIR) with $(PRJ_ROOT_DIR)/..

7.8.6. Solving unknown gcc_except_table input section ‘dld’ warning

Using diab build specs, sometimes RTP application link, reports the following ‘dld’ warning.

dld: warning: Don't know where to allocate input section:
dld: no matching input specification found in linker command file.
dld: Section name: .gcc_except_table

The workaround is to edit the linker scripts (e.g. diab-<version>/conf/rtp.dld and rtp7.dld) to add *(.gcc_except_table) to the list of sections to merge into the text section.

.text (=TEXT) : {
*(.text)
*(.rdata)
*(.rodata)
*(.rodata.cst8) *(.rodata.cst4) *(.rodata.cst16) *(.rodata.str1.1)
*(.rodata.str1.2) *(.rodata.str1.4) *(.rodata.str1.8) *(.rodata.str1.16)
*(.rodata.str1.32) *(.rodata.str1.64) *(.rodata.str1.128)
*(.rodata.str1.256)
*(.gcc_except_table)
*(.frame_info)
*(.eh_frame)
*(.j_class_table)
*(.init)
*(.fini)
}