Implementing my library
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-03 2:15 AM
Hello, I am having problems adding my library to my project. I added the .h file to Core/Inc and my .c file to Core/Src. I included the .h in Model.cpp since that is where I want to use it. I can use the definitions that are in my header file but not the functions. I think it is not able to properly link with the .c file and I do not know how to fix it.
C:/TouchGFXProjects/test/TouchGFX/gui/src/model/Model.cpp:46: undefined reference to `i2c_master_write(unsigned char*, unsigned long)'
- Labels:
-
TouchGFX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-03 3:54 AM
Hello @MexiAxel ,
I suggest you try the following:
- open project properties
- Add files to that project Include paths ( project->properties->c/c++ General->path and symbols ->includes ) (IN which folder files are available)
- Add folder (project->properties->c/c++ General->path and symbols -> Source Location ) (select your source folder)
if you are still having issues feel free to share it hope you find this helpful.
BR Hichem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-03 5:09 AM
Sounds like you haven't added the source file to the project.
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
‎2023-11-03 5:27 AM
Calling a C function from C++ code requires the function to have extern "C" linkage, see https://en.cppreference.com/w/cpp/language/language_linkage and HAL header files.
hth
KnarfB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-03 7:43 AM - edited ‎2023-11-03 7:45 AM
I tried this and it didn't work so I deleted the paths that I created but it caused other issues.
C:/TouchGFXProjects/test/STM32CubeIDE/Debug/../Application/Startup/startup_stm32f429zitx.s:113: undefined reference to `main'
I tried making a new project, but for some reason now I can not build any of my projects. If I press the build button it builds way too fast and it doesn't actually build anymore, it doesn't even tell me the errors either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-03 7:45 AM
I did
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-03 10:14 AM
you need to add the extern "c" before you include your header i have tested it and it works fine this is illustrated in the picture bellow you can check this link for more details about mixing c and c++ you will also find a screenshot of the template project with extern "c" addition
the main.cpp
example.h
example.c
 
BR
