chipKIT® Development Platform

Inspired by Arduino™

Lib not found during building

Created Fri, 02 Aug 2013 07:47:45 +0000 by PICedh


PICedh

Fri, 02 Aug 2013 07:47:45 +0000

hello,

I build a C++ project with MPIDE that use some lib C NVMWriteWord ,NVMErasePage and the linker does not found them.

DO you have an idea to solve the issue ?

thanks

Deeprom.cpp.o: In function putEeprom(eeSeg*, unsigned long, unsigned char)': C:/Users/EDELAH~1/AppData/Local/Temp/build1727412872726788344.tmp/Deeprom.cpp:276: undefined reference to NVMWriteWord(void*, unsigned int)' C:/Users/EDELAH~1/AppData/Local/Temp/build1727412872726788344.tmp/Deeprom.cpp:254: undefined reference to NVMWriteWord(void*, unsigned int)' Deeprom.cpp.o: In function getBuffer(eeSeg*, unsigned char*)': C:/Users/EDELAH~1/AppData/Local/Temp/build1727412872726788344.tmp/Deeprom.cpp:394: undefined reference to NVMWriteWord(void*, unsigned int)' Deeprom.cpp.o: In function writeEeprom(unsigned long, unsigned char)': C:/Users/EDELAH~1/AppData/Local/Temp/build1727412872726788344.tmp/Deeprom.cpp:157: undefined reference to `NVMErasePage(void*)' collect2: ld returned 1 exit status


PICedh

Fri, 02 Aug 2013 11:18:24 +0000

I have found the solution:

This library appears to have an API that assumes it will be called from C, not C++. This is important because C++ effectively requires that the symbols exported from a library have more information in them than just the function name. This is handled by "name mangling" the functions.

To make it compatible with both C and C++, I have arrange to tell a C++ compiler that the functions it declares should be assumed to use C's linkage and naming.

So I have enclosed the corresponding include <peripheral/nvm.h> bu an extern C directive:

#ifdef __cplusplus extern "C" #endif

Thanks to Stack overflow