Linker error : no definition for "DATA"(variable of type struct data_t)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 7:24 AM
I have declared a typedef struct data_t on my jsmn.h
after that I declared a variable DATA of type data_t on jsmn.c
and i defined N,T,C and H
then i declared DATA of type Data_t as extern on ScreenViewBase.cpp
and i try to display DATA.N on the screen
but a linker error appear : no definition for DATA referenced from ScreenViewBase.o
PS1: I do the same with time : in ScreenViewBase.cpp I declared extern RTC_TimeTypeDef sTime then I write Unicode::snprintf(Ndata, 6, "%02d",sTime.Hours ); and it work perfectly.
PS2: I work with stm32f769 and with IAR 8.32.3
- Labels:
-
TouchGFX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 7:41 AM
Perhaps because DATA isn't very original, and is used as a variable or section name within the namespace of the project, or associated libraries.
Pick something more unique...
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 7:48 AM
Hi @Community member​
I tried that(I replaced with youssef_data) but steel the same problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 7:56 AM
Are we sure this is a linker error?
Post a build log, saves playing guess what's wrong.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 8:01 AM
this is a screenshot of the build log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 8:10 AM
Kind of suggests
a) jsmn.c isn't in the project
b) The mixing of C/CPP compilation results in name mangling on the C++ side, and thus an inability to find the symbol
Perhaps use
extern "C" Data_t DATA;
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 8:16 AM
a) jsmn.c is in the project.
b) I used extern "C" , but the same problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 8:23 AM
The linker seems to disagree, perhaps you need to disassemble the objects and see what symbols are actually inside them.
Not sure if the IAR linker outputs a .MAP on failure cases, or if there are options for verbose output, etc.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 8:39 AM
@Community member​
I don't know why but when I add this line (Data_t DATA); in main.cpp the error disappear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-07-18 9:19 AM
I know now what is the problem the Data_t DATA was declared localy on a function in jsmn.c , I declare Data_t DATA globally and I elimineted this declaration in main.cpp
