171 views
in System Integration by

Hi everyone,

I have a library that I want to include in the DeviceDriver.c. In the file I have inserted  #include "mcp3424.h".

but the functions are not found?
what am I doing wrong?

Error result:

/usr/bin/ld: ./obj/DeviceDriver.o: in function `DeviceDriver_GetO2':
DeviceDriver.c:(.text+0x9b8): undefined reference to `mcp3424_init'
/usr/bin/ld: DeviceDriver.c:(.text+0x9c4): undefined reference to `mcp3424_set_conversion_mode'
/usr/bin/ld: DeviceDriver.c:(.text+0x9e0): undefined reference to `mcp3424_get_raw'
collect2: error: ld returned 1 exit status
make: *** [Makefile:150: EmbeddedWizard-RasPi-CM4] Error 1
 

1 Answer

0 votes
by

Hello,

including your header file into the DeviceDriver.c file makes it possible for the compiler to find the declarations of your library functions.

The reported error message is a linker error. Please add your library to the set of libraries in the makefile (e.g. using -l in the makefile) or as additional library in your project configuration.

Then the linker will find the requested functions.

Best regards,

Manfred.

by
ok got it now.
I have attached the mcp3424.c file to the Makefile at "APP_C".

Thank you for the advice!
by
Yes, in case you have a C file, it should be added to the lists of C files for the compiler. I thought you were talking about a library.

Anyhow, it is working now.

Embedded Wizard Website | Privacy Policy | Imprint

...