<?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>How to add custom source file ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51630/how-to-add-custom-source-file</link><description>Hi All 
 I want to add some custom source files (.c) &amp;amp; header files (.h) to an existing project. 
 I tried adding it by right clicking &amp;quot;Project app/libapp.a&amp;quot; branch of the project tree. The project compiles without error/warning, but it misses main.c</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Sep 2019 09:37:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51630/how-to-add-custom-source-file" /><item><title>RE: How to add custom source file ?</title><link>https://devzone.nordicsemi.com/thread/207621?ContentTypeID=1</link><pubDate>Tue, 03 Sep 2019 09:37:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f0a721d-0ede-4c68-983d-72f5d0ba27dd</guid><dc:creator>shital</dc:creator><description>&lt;p&gt;Hi Amanda Hsieh&lt;/p&gt;
&lt;p&gt;Thanks for contributing with a solution.&lt;br /&gt;&lt;span&gt;I have seen &lt;a title="this" href="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-connect-sdk-tutorial"&gt;this&lt;/a&gt;&amp;nbsp;tutorial, it is great, but there is no more detailed introduction.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;Instead, I used the below method to add custom file .h and file.c. &amp;amp; it worked fine.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Open project folder&amp;nbsp;C:\Nordic_SDK\ncs\nrf\samples\nrf9160\GPS&lt;br /&gt;&lt;/span&gt;&lt;span&gt;- Project --&amp;gt;&amp;nbsp; &amp;nbsp;src --&amp;gt; create new folder for custom file (ex. custom_files)&lt;br /&gt;&lt;/span&gt;&lt;span&gt;- Add file.c , file.h and Cmaklists.txt file in custom folder (in custom_files)&lt;br /&gt;&lt;/span&gt;&lt;span&gt;-&amp;nbsp; open main Cmakelists.txt file (C:\Nordic_SDK\ncs\nrf\samples\nrf9160\GPS\cmakelists.txt) and add below path in main custom file of your custom folder.&lt;br /&gt;&amp;nbsp;1.) zephyr_library_include_directories (src/custom_folder_name)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;2.) add_subdirectory( src/custom_folder_name)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If there is an alternative, feel free to inform me.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thank You&lt;/p&gt;
&lt;p&gt;Shital&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to add custom source file ?</title><link>https://devzone.nordicsemi.com/thread/207362?ContentTypeID=1</link><pubDate>Mon, 02 Sep 2019 10:56:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b037310-5f71-4a1a-b06b-c80e263f7aa3</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Gosai,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To add header files and source code, create a new directory called &amp;#39;include&amp;#39;&amp;nbsp;and add all your header files. Then add your .c files in the &amp;#39;src&amp;#39; directory. The just include the header files you want to use in the &amp;#39;main.c&amp;#39; file. Please also see this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/51147/how-to-add-a-header-file-to-the-nrf9160-zephyr-project"&gt;post&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Amanda H.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>