I'm experiencing a weird link problem which has already been mentionned in other posts, but without any solution.
Problem is (almost) the same with 4.7 2014q2\arm-none-eabi and 4.9 2015q2\arm-none-eabi
I'm coding in C/C++. Most of my code is in C++. I'm using RT/HAL with the last version of ChibiStudio.
Here's what I get with 4.9 2015q2\arm-none-eabi :
Code: Select all
c:/chibistudio/tools/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-abort.o): In function `abort':
abort.c:(.text.abort+0xa): undefined reference to `_exit'
c:/chibistudio/tools/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'
c:/chibistudio/tools/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid'
c:/chibistudio/tools/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
I found out how to link my code by commenting out some lines, but then it won't work anymore !
It deals about a i2c slave request handler. I want to call different hook functions, depending on the first byte of the received request.
Here's the code :
Code: Select all
u8 rxBody[60]; /* stores last message master sent us */
u8 txBody[60]; /* response */
typedef void HookFunction();
typedef struct {
HookFunction* hook;
u8 size;
} I2cRequestHandler;
void readSensor() {
IdentifiedRecord *rec = (IdentifiedRecord*)txBody;
bool res = mesures.pull(rec);
if (!res) {
rec->sensorId = 0;
}
}
I2cRequestHandler clientReadHandlers[MAX_READ_OR_WRITE_COMMANDS] = {{ &readSensor, sizeof(IdentifiedRecord) }, {0, 0}}; // IF I DON'T INITIALIZE THIS LINE IT LINKS !!!
void i2cSlaveRxCpltCallback(I2CDriver *i2cp)
{
(void)i2cp;
u8 code = rxBody[0]; // IF I CHANGE THIS LINE WITH code = 0; IT LINKS !!!
u8 cmd = code & CODE_MASK;
if ((code >> 4) == 0) { // Client reading function
if (clientReadHandlers[cmd].hook != 0) {
(*clientReadHandlers[cmd].hook)();
}
} else { // Client writing to board function
if (clientWriteHandlers[cmd].hook != 0) {
(*clientWriteHandlers[cmd].hook)();
}
}
}
I2CSlaveMsg slaveRequest = {
sizeof(rxBody), /* max sizeof received msg body */
rxBody, /* body of received msg */
ignore, /* do nothing on address match */
i2cSlaveRxCpltCallback,/* on msg received */
ignore //reportRxErr
};
I2CSlaveMsg slaveReply = {
32, /* trailing zero byte will be repeated as needed */
txBody,
ignore, /* do nothing on address match */
ignore, /* do nothing after reply sent */
ignore //reportReplyErr
};
I tried static and const declarations for almost every global variable, but this doesn't change anything : keeping my code functionnal makes it impossible to link.
Thank you for the help.
NB