1

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)
questionasker
  • 2,536
  • 12
  • 55
  • 119
Fen
  • 37
  • 1
  • 6
  • 1
    Please provide your actual command line that you are trying to use to link the binary together. – Ahmed Masud Mar 14 '19 at 14:38
  • I find your lack of code... disturbing. Please add some code so that we can help you better. Thanks! –  Mar 14 '19 at 14:38
  • Blimey! Do Green Hills still make C compilers or is this for an ancient system? (I remember when the Green Hills C compiler command was confusingly called `gcc` around 30 years ago.) – Ian Abbott Mar 14 '19 at 14:38
  • 3
    Welcome to [SO]. Please read [ask] and [mcve] and post your question with the exact example of what's going wrong so we can help. Thank you – Ahmed Masud Mar 14 '19 at 14:38
  • @IanAbbott They are one of the bigger compiler vendors for (modern) embedded systems. – Lundin Mar 14 '19 at 14:40
  • 2
    The path to the header files should be irrelevant if you are getting linker errors. Perhaps you need to specify the path to the library files. Traditionally, for `cc` that was done with the `-L` option, so I guess it is the same for the Green Hills C compiler. Also the lower-case `l` option specifies the library name without the *lib* prefix, e.g. `-lname` specifies `libname.a` or `libname.so`. – Ian Abbott Mar 14 '19 at 14:47
  • regarding: `GHSRH850_LFLAGS += -I file\path\to\headers` This is wrong. The header files are only used during the compile step. During the linker step need path to libraries and (shortened) library names – user3629249 Mar 14 '19 at 16:04

1 Answers1

0

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.

Fen
  • 37
  • 1
  • 6