nxp-mcuxpresso / vscode-for-mcux

Support for NXP Visual Studio Code for MCUXpresso Extension project.
13 stars 0 forks source link

Add include paths to zephyr #13

Closed MaxOvervoordee closed 9 months ago

MaxOvervoordee commented 9 months ago

Hi,

Is there an easy way to add include paths to your project in zephyr? Just like you could normally do in C/C++ Build>Settings>Tool Settings>Includes>Include Paths.

DerekSnell commented 9 months ago

Hi @MaxOvervoordee ,

You can add more include paths by modifying the Cmake file for the application. Here is an example to do this using the Cmake target_include_directories() in this sample applications CMakeLists.txt.

Best regards

MaxOvervoordee commented 9 months ago

Hi @DerekSnell Thank you for your fast answer. I've tried what you said, building seems to be correct in the output terminal. Now i only get one more error, the first include of my main: #include "mc_periph_init.h" When ctrl clicking this include it does show me the correct file in lib/motor_cource/mc_periph_init.h I included the next code, with many directories according to your example: target_include_directories(app PRIVATE lib/motor_source) Could you help me figure out what i'm doing wrong?

DerekSnell commented 9 months ago

Hello @MaxOvervoordee ,

Perhaps an example will help. hello_world_include.zip uses the same include path and filename that you listed. You can import this as a Project Archive into the MCUXpresso extension for VS Code.

Let us know how this works for you. Best regards

MaxOvervoordee commented 9 months ago

@DerekSnell Thank you.

For some more context, i've been working on a motor FOC example in MCUXpresso for some time, and i'm trying to convert/transfer that code to the zephyr os. I was told as zephyr includes the global libraries of supported board, it should be doable. The way i'm doing that rn is just copy pasting library folders into zephyr and getting them in the directory using the method you suggest.

The build shows two error of the following kind: conflicting types for 'int32_t'; have 'long int' > previous declaration of 'int32_t' with type 'int32_t' {aka 'int'}

This error comes from the file "mlib_files.h" with the following code: #if !defined( __int32_t_defined) #if !defined(__STDINT_H_INCLUDED) #if !defined(__INT32_T_TYPE__) typedef signed long int32_t; #endif /* __INT32_T_TYPE__ */ #if !defined(__INT32_T_TYPE__) typedef unsigned long uint32_t; #endif /* __INT32_T_TYPE__ */ #define __int32_t_defined 1 #endif /* __STDINT_H_INCLUDED */ #endif /* __int32_t_defined */

Does this mean the other code doesn't have errors or just that these are the first errors it has encountered therefore stopped immediately? And is there maybe a more recommended way to convert code and libraries made in mcuxpresso to zephyrOS?

DerekSnell commented 9 months ago

Hi @MaxOvervoordee , Your latest response seems unrelated to the original topic of this Issue. Can you create a new Issue for each topic? You can link existing issues and discussions in the new Issues for context. But others struggling with similar issues will have an easier time finding these solutions if the discussions are all related to the title of the Issue. And for our tracking purposes and ensuring we resolve all issues, it is best to keep each topic separate, so we can address them all.

As for the original include path issue, I assume the example helped you find your header file. Are you ready to close this Issue now?

Thanks