Hello,
I would like to split one big file "main.cpp" into more files. But I get compile-time error:
undefined reference to ...
Situation before:
I have PC, Ubuntu and the unix-toolchain. I use Geany as the text editor.
It works well thanks your cookery-book (http://leaflabs.com/docs/unix-toolchain.html).
Normally I make changes in "main.cpp" (modified blinky project) then "make flash" and then "make install".
Everything works.
Situation now:
I make two new files: "my.h" and "my.cpp" and write some C code. Inside "main.cpp" I call a function declared in "my.h" and defined in "my.cpp".
The files are saved at some location as "main.cpp" and as "Makefile" (~/_arm32/).
But I get compile-time errors:
main.cpp:22: undefined reference to `my_hex'
main.cpp:26: undefined reference to `my_buff'
It seems that the compiler doesn't see my two new files. Do I need modify "Makefile" or is there another problem ?
file "my.h" looks like
/*
file: my.h
*/
#ifndef _MY_H
#define _MY_H
#ifdef __cplusplus
extern "C" {
#endif
#include "libmaple_types.h"
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
extern void my_hex(void *dest, uint32 nr); // some my func
extern unsigned char my_buff[20]; // some my variable
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifdef __cplusplus
}
#endif
#endif //_MY_H