ApolloX: Correct Way to Add Path for Subfolders & Static Library

Hi

What’s the correct approach if my project using sub folders and a static library?

.conf/
.vscode/
src/
├─ logger/
│ ├─ logger.cpp
├─ main.cpp/
libs/
├─ libHwInterface.a

I assume I must edit the Makefile?

Hi @Qubit ,

I don’t think we have any ‘correct’ approaches to file organization when it comes to our templates. Any files present in the project directory will be visible by the SDK container during the cross-compilation stage, so all directories in your example would be accessible during compilation, including libs/. Feel free to organize your files in any way you prefer.

And yes, you need to indicate in your Makefile any libraries being used during compilation, including additional library search paths (using the -L compiler flag) if necessary.

Hope this clarifies things for you.

Best regards,
Lucas Akira

Is the makefile not overwritten with a plugin update? I thought there was a better place where it is stored as a variable, e.g. in .vscode/settings.json

Hi @Qubit ,

The Makefile is not overwritten by our extension, you can configure it directly according to your needs. Also for V2 all Dockerfiles in your project are not overwritten by any settings, so you can modify them directly as well.

Best regards,
Lucas Akira

Thank you for clarification.

I am currently having problems finding the correct settings for the Makefile. As mentioned above, I want to have many files in a subfolder for overview.

In the Makefile I have only changed the CCFLAGS to:
CCFLAGS := -Iincludes/ -Isrc/logger/

It compiles without errors but does not create .o files which then leads to a linker error.

If I move all files from the subfolder into the “src” folder, everything works.

Never really worked with Makefile so far and Docker on top of that it’s a bit complicated to find the issue.

I guess I must adapt the SRC_PATH parameter?

Hi @Qubit ,

I think the current Makefile present in our template doesn’t support sub-directories inside src.
For this you can use a more elaborate Makefile like this one: Makefile-Templates/MediumProject at master · TheNetAdmin/Makefile-Templates · GitHub , though keep in mind I didn’t test it with the extension.

Of course, you can keep all source files in src if you don’t want to tinker with the Makefile.

In the Makefile I have only changed the CCFLAGS to:
CCFLAGS := -Iincludes/ -Isrc/logger/

I believe that the -I option specifies to the compiler a list of directories to be searched for header files, not source files, so I don’t think -Isrc/logger/ would work.

Given that Makefile/Make is a very broad topic by itself and not directly related to Toradex, I’m not really the best person to assist you on this subject.

You can find more information on how to use it in the the GNU Make manual: Top (GNU make)

Best regards,
Lucas Akira

Yes, I have also found that it is not suitable for projects with subfolders. I’m also close to a solution but Makefile plus Docker are a bit too much “new stuff” :sweat_smile:

But it would actually be good if your template could do that :wink: Putting all source code files in one folder quickly becomes confusing.

But I understand isn’t a Toradex/Torizon specific topic.

Hi @Qubit ,

I understand your request, and I passed this to the extension team. We might eventually change the Makefile template depending if more customers request it.

However, our templates are more of a starting point for developers to get familiarized with the extension. Our intention is to give developers freedom to fully and freely customize it according to their needs, as we can’t possibly cover every single use case with them.

Keep in mind that our templates are open to contributions by the community: GitHub - toradex/vscode-torizon-templates: VS Code Torizon Integrated Development Environment Templates . So new features might be added by people outside of Toradex as well. Pull requests are more than welcome!

Hope I was able to clarify things.

Best regards,
Lucas Akira

1 Like