<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>main.h file not found in project dir unless full Windows path is provided</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119088/main-h-file-not-found-in-project-dir-unless-full-windows-path-is-provided</link><description>This is likely a Visual Studio issue but figured this is an obvious rookie error so someone will set me straight right away! I have loaded a sample project and compiled and run it properly on my hardware development kit; I can debug and all is good. However</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 19 Feb 2025 23:46:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119088/main-h-file-not-found-in-project-dir-unless-full-windows-path-is-provided" /><item><title>RE: main.h file not found in project dir unless full Windows path is provided</title><link>https://devzone.nordicsemi.com/thread/523783?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2025 23:46:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efbabe6a-bb37-41ac-8f9c-ecb71cb8beaf</guid><dc:creator>Johnny Nguyen</dc:creator><description>&lt;p&gt;Glad we could get it resolved.&lt;/p&gt;
&lt;p&gt;For extra literature and learning, here are a few helpful links&lt;/p&gt;
&lt;p&gt;- There is a cursory glance at the build system here in our Developer Academy:&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-1-nrf-connect-sdk-introduction/topic/nrf-connect-sdk-structure-and-content/"&gt;nRF Connect SDK structure and content - Nordic Developer Academy&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;- You can read deeper on the build system here:&amp;nbsp;&lt;a id="" href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/config_and_build/index.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/config_and_build/index.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; -&amp;gt; and more specifically how to utilize CMake here:&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/config_and_build/cmake/index.html"&gt;Adding files and configuring CMake&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: main.h file not found in project dir unless full Windows path is provided</title><link>https://devzone.nordicsemi.com/thread/523780?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2025 22:49:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22390eac-191b-4d3b-bfcd-73edff41e989</guid><dc:creator>PaulJ</dc:creator><description>&lt;p&gt;Yes, I added the main.h file to the target_source list while debugging this issue; it didn&amp;#39;t fix the problem but it doesn&amp;#39;t stop a clean compile either when I provide the full windows path in the #include statement. I removed it from the target_sources list as you suggested and now the compile is working with &amp;quot;include &amp;lt;main.h&amp;gt;&amp;quot;. That makes absolutely no sense to me at any level; a novice like me would expect that if you use the GUI to add a file to the project, the GUI should at least have the decency to ask if it is needed for the build and then set the appropriate commands in the configuration files.&amp;nbsp;I think this explains why I never became a professional programmer! Thanks for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: main.h file not found in project dir unless full Windows path is provided</title><link>https://devzone.nordicsemi.com/thread/523776?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2025 22:17:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b386c1df-f753-4fba-a9de-c7b19612ad3e</guid><dc:creator>Johnny Nguyen</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;main.h is not a source file, so remove it from target_sources(...)&lt;/p&gt;
&lt;p&gt;If inc/ is in the project directory (i.e. not within src), then that path should be ok on zephyr_include_directories(...)&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: main.h file not found in project dir unless full Windows path is provided</title><link>https://devzone.nordicsemi.com/thread/523770?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2025 21:08:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52fb7217-537d-4015-980e-45a875f350b2</guid><dc:creator>PaulJ</dc:creator><description>&lt;p&gt;I added the command as you suggested (except the file is now in a sub-directory called &amp;quot;inc&amp;quot; but I get an error telling me that the build failed due to &amp;quot;CMake Generate step failed. This is my CMakeLists.txt file:&lt;/p&gt;
&lt;p&gt;#&lt;br /&gt;# Copyright (c) 2018 Nordic Semiconductor&lt;br /&gt;#&lt;br /&gt;# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause&lt;br /&gt;#&lt;br /&gt;cmake_minimum_required(VERSION 3.20.0)&lt;/p&gt;
&lt;p&gt;find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})&lt;/p&gt;
&lt;p&gt;zephyr_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)&lt;/p&gt;
&lt;p&gt;project(NONE)&lt;/p&gt;
&lt;p&gt;# NORDIC SDK APP START&lt;br /&gt;target_sources(app PRIVATE&lt;br /&gt; src/main.c,&lt;br /&gt; inc/main.h&lt;br /&gt;)&lt;/p&gt;
&lt;p&gt;# NORDIC SDK APP END&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: main.h file not found in project dir unless full Windows path is provided</title><link>https://devzone.nordicsemi.com/thread/523762?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2025 17:43:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1252836-d146-40c1-8827-1ce10cc21d3d</guid><dc:creator>Johnny Nguyen</dc:creator><description>&lt;p&gt;Hi Paul,&lt;/p&gt;
&lt;p&gt;Two paths forward:&lt;/p&gt;
&lt;p&gt;1) you can use #include &amp;quot;main.h&amp;quot;&lt;/p&gt;
&lt;p&gt;2) you can use #include &amp;lt;main.h&amp;gt; if the path for that file is included in CMakeLists.txt by adding it as an include path.&lt;/p&gt;
&lt;p&gt;For instance, if main.h is in the same location as main.c in your_project/src, then adding&amp;nbsp;&lt;span&gt;zephyr_include_directories(&lt;/span&gt;&lt;span&gt;${CMAKE_CURRENT_SOURCE_DIR}&lt;/span&gt;&lt;span&gt;/src) before the project sources will work.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: main.h file not found in project dir unless full Windows path is provided</title><link>https://devzone.nordicsemi.com/thread/523685?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2025 12:14:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f5360bb-7e50-430a-9b55-a3846a91b188</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Paul,&lt;/p&gt;
&lt;p&gt;Would it be possible to attach your sample project so that I can try to run it here at my end?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>