Reputation: 3823
I did setup a C project with Eclipse Photon (4.8.0) for developing a program for the ESP-32. I did configure the IDE according to this official setup instructions.
Flashing the ESP-32 works fine. But as soon as I try to include header files from a sub folder, I run into troubles. I have set up a very simple project to illustrate the issue. The project consists of main.c
, base/test.h
and base/test.c
, whereas the test.h
and test.c
files only contain one function with the signature void function1(void);
.
When I try to call function1()
in main.c
, I get this error in main.c
:
Undefined reference to function1()
Please compare to the attached screenshot, where everything is depicted.
How to solve this issue?
Upvotes: 3
Views: 6976
Reputation: 8610
Seems like you need to do proper linking.
Project\Settings\C C++ General\Paths and Symbols\Libraries
Project\Settings\C C++ General\Paths and Symbols\Library Paths
Project\Settings\C C++ Build\Settings\Linker\Miscellaneous\Other objects
Note:
libsomething.a
, than you need to specify only something
as the name; so omit lib
prefix and .a
suffix.lib
, then you need to add its name prefixed with :
. For example, something.a
should be added as :something.a
.Upvotes: 2
Reputation: 6073
This is not a compiler, but rather a linker error.
Note, with #include
ing a header file, you only make the external function known to the compiler. You also need to link to the external function during the linking stage. Make sure you include the compiled object file that contains function1
into the link.
Upvotes: 2