Reusing external code

Discuss how to use the features of Atollic TrueSTUDIO, including the editor, assembler, C/C++ compiler, linker, debugger, static code analysis and team collaboration tools.

Moderators: Markus Girdland, Mattias Norlander

Posts: 1
Joined: Fri Nov 01, 2019 10:43 am

Reusing external code

Postby Baltazar » Fri Nov 01, 2019 11:09 am

I have a project for STM32F103 created with CubeMX. I would like to reuse some external code written in another project without copying *.h and *.c files to this new project.

Including external header with

Code: Select all

#include "absolute/path/to/external/header.h"

works OK, but I have problem telling TrueStudio where to find the implementation. As a consequence, I am getting

undefined reference to `xxx`

messages at build.

I tried adding paths to different folders of the another project here and there and everywhere in the current project settings for hours without success. What is the right way to do it?

In the ideal case, I would like to use the already compiled code from another project rather than including the source *.c and having to recompile again. This is at least what including *.h files instead of *.c files is used for if I understood correctly. But drag&drop&linking the other project's *.o file into the current project does not help (or I don't know how to do it correctly).

FYI, this topic was not helpful either:

Posts: 111
Joined: Wed Apr 05, 2017 5:08 pm
Location: USA

Re: Reusing external code

Postby frank_ee » Thu Nov 21, 2019 9:44 pm


Make sure the header and source file paths are in the project settings. Atollic needs to know where the header and source files are, in addition to the #include statements. You may have to put absolute file paths in the project settings. I think you should make new folders in the TrueSTUDIO project, add the source file and header files. Then, update the project settings to have the new folders visible. I had a similar problem compiling RTOS code had issues with " " verse <> for #include statements.

Return to “Atollic TrueSTUDIO tool discussions”

Who is online

Users browsing this forum: No registered users and 1 guest