Debugging in STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-05 10:25 AM
Hello,
I am working on a project where I have created several of my own files (.h and .cpp) but I am having issues with undefined reference to certain functions. I cannot solve this issue while having the files separated, but I was wondering if it is possible to generate and view the files combined together in assembly code? The functions are accessible in the main.c file, but not in my own files.
Thanks,
MC
- Labels:
-
STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-05 2:13 PM
You need to put the function definitions in a header file and then #include that header in the source files you wish to use it in. This is a basic C concept.
main.h:
void my_function();
main.c:
#include "main.h"
void my_function() {
// stuff...
}
other_source_file.c:
#include "main.h"
void other_function() {
my_function();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-06 4:07 AM
I know this concept and I have done this already, however I am trying to debug the undefined reference error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-06 7:17 AM
An "undefined reference error" suggests you haven't done this correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-06 7:45 AM
You can check which files the linker is linking by using the "-Wl,--verbose" option (Project > Properties > C/C++ Build > Settings > Tool settings > MCU GCC Linker > General).
For analyzing individual .o files, you may use objdump with its many options. You find a copy under C:\ST\STM32CubeIDE\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.7-2018-q2-update.win32_1.4.0.202007081208\tools\bin. The path may vary depending on your install path and tool version.
hth
KnarfB
