How to solve “Undefined reference to function” in Eclipse CDT?
up vote
0
down vote
favorite
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?

c eclipse embedded eclipse-cdt
add a comment |
up vote
0
down vote
favorite
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?

c eclipse embedded eclipse-cdt
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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?

c eclipse embedded eclipse-cdt
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?

c eclipse embedded eclipse-cdt
c eclipse embedded eclipse-cdt
asked Nov 9 at 23:27
salocinx
1,35753574
1,35753574
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
This is not a compiler, but rather a linker error.
Note, with #includeing 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.
add a comment |
up vote
1
down vote
Seems like you need to do proper linking.
If you are linking with a library, you need to specify:
- name of the library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibraries
- where the linker should search for this library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibrary Paths
See Note 1.
- name of the library:
If you are linking with object files, add those to:
ProjectSettingsC C++ BuildSettingsLinkerMiscellaneousOther objects
Note 1:
If your library name is for example libsomething.a, than you need to specify only something as the name; so omitt lib prefix, and .a suffix. If your library is not prefixed with lib, then you need to add its name prefixed with :, for example: something.a should be added as :something.a.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
This is not a compiler, but rather a linker error.
Note, with #includeing 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.
add a comment |
up vote
2
down vote
This is not a compiler, but rather a linker error.
Note, with #includeing 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.
add a comment |
up vote
2
down vote
up vote
2
down vote
This is not a compiler, but rather a linker error.
Note, with #includeing 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.
This is not a compiler, but rather a linker error.
Note, with #includeing 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.
answered Nov 10 at 11:51
tofro
4,250725
4,250725
add a comment |
add a comment |
up vote
1
down vote
Seems like you need to do proper linking.
If you are linking with a library, you need to specify:
- name of the library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibraries
- where the linker should search for this library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibrary Paths
See Note 1.
- name of the library:
If you are linking with object files, add those to:
ProjectSettingsC C++ BuildSettingsLinkerMiscellaneousOther objects
Note 1:
If your library name is for example libsomething.a, than you need to specify only something as the name; so omitt lib prefix, and .a suffix. If your library is not prefixed with lib, then you need to add its name prefixed with :, for example: something.a should be added as :something.a.
add a comment |
up vote
1
down vote
Seems like you need to do proper linking.
If you are linking with a library, you need to specify:
- name of the library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibraries
- where the linker should search for this library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibrary Paths
See Note 1.
- name of the library:
If you are linking with object files, add those to:
ProjectSettingsC C++ BuildSettingsLinkerMiscellaneousOther objects
Note 1:
If your library name is for example libsomething.a, than you need to specify only something as the name; so omitt lib prefix, and .a suffix. If your library is not prefixed with lib, then you need to add its name prefixed with :, for example: something.a should be added as :something.a.
add a comment |
up vote
1
down vote
up vote
1
down vote
Seems like you need to do proper linking.
If you are linking with a library, you need to specify:
- name of the library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibraries
- where the linker should search for this library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibrary Paths
See Note 1.
- name of the library:
If you are linking with object files, add those to:
ProjectSettingsC C++ BuildSettingsLinkerMiscellaneousOther objects
Note 1:
If your library name is for example libsomething.a, than you need to specify only something as the name; so omitt lib prefix, and .a suffix. If your library is not prefixed with lib, then you need to add its name prefixed with :, for example: something.a should be added as :something.a.
Seems like you need to do proper linking.
If you are linking with a library, you need to specify:
- name of the library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibraries
- where the linker should search for this library:
ProjectSettingsC C++ GeneralPaths and SymbolsLibrary Paths
See Note 1.
- name of the library:
If you are linking with object files, add those to:
ProjectSettingsC C++ BuildSettingsLinkerMiscellaneousOther objects
Note 1:
If your library name is for example libsomething.a, than you need to specify only something as the name; so omitt lib prefix, and .a suffix. If your library is not prefixed with lib, then you need to add its name prefixed with :, for example: something.a should be added as :something.a.
answered Nov 14 at 13:34
Danijel
2,448124684
2,448124684
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234543%2fhow-to-solve-undefined-reference-to-function-in-eclipse-cdt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown