Search code examples
cgreenhills

link static library with headers with Green Hills compiler


I have a static library .a with several header files provided. I want to link it with .o files into binary using Green hills compiler. The error I get is:

[elxr] (error #412) unresolved symbols.

I am trying to specify path to header files providing -I filepath to linker.

However, this does not seem to work.

Updated with code.

# Recipe for linking
__GHSRH850_ERRALL += $(__GHSRH850_TARGETERR)
GHSRH850_LIB = SRC\MCU\DROME\RGL\libd1mx_rh850_ghs.a
$(GHSRH850_TARGETEMU): $(__GHSRH850_OBJS) $(GHSRH850_LSCRIPT) $(GHSRH850_LIB) \
                      $(CORE_MAKPREREQS) | __GHSRH850_DIRS
    $(call CORE_REPORTFILE,Linking,$(@F))
    $(eval __GHSRH850_ERRDONE += $(__GHSRH850_TARGETERR))
    $(GHSRH850_LD)                       \
       $(GHSRH850_LSCRIPT)                                                            \
       -o $@                                                                          \
       $(GHSRH850_LIB)                                                  \
       $(__GHSRH850_OBJS)                                                            \
       $(GHSRH850_LFLAGS)                                                             \
       > $(__GHSRH850_TARGETERR)

The make file is quite huge, so I cannot put all of it here. Basically library is added with:

GHSRH850_LIB = file\path\to\libname.a

In flags added filepath to headers with:

GHSRH850_LFLAGS += -I file\path\to\headers

Other descriptions are:

GHSRH850_LFLAGS - Linker flags

GHSRH850_LSCRIPT - Linker script file

__GHSRH850_OBJS - Object files list

Compiler that is used ccrh850.exe.

Error code:

[elxr] (error #412) unresolved symbols: 35
_R_UTIL_DHD_Init    from drglgmm_dhd.o
_R_UTIL_DHD_Config  from drglgmm_dhd.o
_R_DEV_SQRTF    from libd1mx_rh850_ghs.a(r_drw2d_main.o)
_R_VDCE_Sys_HsyncActLevelSet    from libd1mx_rh850_ghs.a(r_vdce_api.o)

Solution

  • Thanks all for quick answer. The problem was solved. Basically errors appeared due to other source files were not compiling, because of missing headers and compiler did not throw any notification about that. Thus, when all object files compiled errors have gone. The correct way to add library is either to add path as I did or use -lname as mentioned by Ian Abbot.