Hello,
how to add an existing file to my project (AVR Studio 5)? I don't want the file to be copied to the current project's location, I need to keep the file at its location (it is file shared by many projects).
Thank you for your help
Martin
Hello,
how to add an existing file to my project (AVR Studio 5)? I don't want the file to be copied to the current project's location, I need to keep the file at its location (it is file shared by many projects).
Thank you for your help
Martin
The search function says:
Thank you. I have one more problem regarding this...
My project's location is C:\SOURCE\Project. There are 2 files - main.c and hardware.h
The common files are stored in C:\SOURCE\Inc. There are two files - spi.h and spi.c.
Spi.h contains "#include hardware.h".
Main.c contains "#include spi.h".
I can't compile my project because of "Hardware.h: No such file or directory" (the error comes from spi.h file). I assume that the file hardware.h should be located on the same location as spi.h but it is not possible as hardware.h is project specific file. What to do? :)
Add missing Include Paths in Project Options Directories.
I'm sorry, I tried to look for the option, but I can't see it. Can you navigate me, where to click? I have AVR studio 5.
Right click your project->properties->toolchain.
Under AVR/GNU C compiler you have Directories, under Linker you have libraries and under Assembler you have genereal tab, where you may set extra include paths
Thanks, I get it.
But nothing changes, I'm not able to compile my project. I will describe the situation:
My project consists of main.c and hardware.h file and two other files: spi.h and spiHw.c . These two files are common for many projects.
project is stored at D:/Source/AVR8/FlashDriver
main.c is stored at D:/Source/AVR8/FlashDriver/FlashDriver
hardware.h is stored at D:/Source/AVR8/FlashDriver/FlashDriver
spi.h is stored at D:/Source/AVR8/Inc
spiHw.c is stored at D:/Source/AVR8/Modules/Cpu
I added spi.h and spiHw.c files to my project as links (small arrow in bottom left corner of the icon in Solution Explorer)
spi.h includes hardware.h (#include "hardware.h").
I added this include path:
../../Inc
But I get error "Hardware.h: No such file or directory" (the error comes from spi.h file).
Thanks for any help
Hello,
This is my first post. Apologies if I am making any mistakes in asking.
I have been having similar such problem with my project as well. My project and other reusable code (.C and.H) files are stored in different folders. Similar sort of hierarchy as mentioned above. Even after giving it the include paths for .c and the .h files it refuses to compile by saying No such file or directory.
At the moment what I am doing to get on working is to add the xyz.c and the xyz.h files as links in the project and then in the #include give the relative path like for eg.
#include "../../../Library/uart.h"
and it compiles fine.
However, it would be really useful to just say
#include "uart.h" and just give the
../../../Library/ as one of the entries in the include directories option. Isn't that the use of the Include directories option in the first place?
It becomes annoying when you keep moving your project location and the project grows bigger. One always has to calculate the relative path to different include directories.
Does anybody know a solution to this problem? Would be really helpful for myself and gaminn!!
Thanks for any help in advance
I can include library files simply by #include "spi.h", don't have to specify relative path (I added include paths). But I have problem when the library file (spi.h) includes project specific file (hardware.h). Then the project is never built unless I write full path in spi.h (#include "D:/SOURCE..........FlashDriver/hardware.h"). But that is uselles as there will be many project using spi.h.
As long as you have -I's for every directory where .h files are located then you should be able to include any of them in any project file simply with #include "file.h".
For the actual .c files just add them to the project list of files to be built.
When you added the Include Path in the Project Options and used the "..." button to locate the directory, there might be a "../" missing at your "../../Inc" path. This bug Atmel support confirmed to me. When addressing a lib directory directly outside from your project you normally need the path "../../../lib" added.
Thanks! I didn't realize that I have to add include path to the project directory itself (..).
madmax_7: Add include paths in your project, that's all you need I think.
Hi
Will do that!! However, I am not exactly clear on what clawson said
For the actual .c files just add them to the project list of files to be built.
Do we have to add the .c files as copies or links in the project? or it doesn't matter ?
Also
PeteAVR
When you added the Include Path in the Project Options and used the "..." button to locate the directory, there might be a "../" missing at your "../../Inc" path. This bug Atmel support confirmed to me. When addressing a lib directory directly outside from your project you normally need the path "../../../lib" added.
Does it mean that in project properties--> AVR Gnu compiler -> Directories we need an additional '../' in the path ??
Thanks a lot for all your help
Do we have to add the .c files as copies or links in the project? or it doesn't matter ?
Does it mean that in project properties--> AVR Gnu compiler -> Directories we need an additional '../' in the path ??
Nope. It means, that when you are in the "Edit Include Paths" dialog and you use the "..." button to choose a path, the path might be wrong.
Hi
I tried something which I would like to share here .. it may help someone having similar issues..
1) I created a folder name d AVRProjects in my D drive
2) Created 2 additional folder in it namely Library and TestProjects.
3) In the LIbrary folder i created another folder named INC which just stands for Increment (remember this is just an experiment !! :) ).
4) In the INC folder I had 2 files namely inc.c and inc.h very simple files. Inc.c had a function name
inc_value(int var) and its prototype declared int the inc.h file
5) Created a new GCC project named testInc and had it place in the Testprojects folder.
So, the directory hierarchy now lookc
D:/Avrprojects/Library/INC
D:/Avrprojects/TestProjects/testInc
The Library folder to contain libraries of different stuff..like lcd,uart etc.. in differnt folders
The test project folder to contain various test projects to test the library and solve bugs arising from doing the tests
6) Now in the newly created project link the existing inc.c file from its folder respectively the INC folder under library and in the c file that gets generated for the project which has the main function include the inc.h by saying
#include "inc.h"
and call the inc_var function in the main function
7) Now i did three things here:
a) Without doing any additional settings just compile the project (BOUND TO FAIL FOR SURE ..but just for the sake of it) the result is obviously that it fails..!!
b) Now in the AVRGNU Compiler ---> Directories option add a path by click the add path icon After clicking it comes up with a box saying Add Include path and then uncheck the relative path box and point it to the path of the Library/INC folder and compile and the result it compiles !!!!
c) NOw, Many people like relative paths so again navigate to the directories option and this time give it the path to the Library/INC folder but have the relative path box checked.. Build it and suddenly it fails with an error message saying
inc.h: No such File or directory
Now, at this point I am going to refer to the post by PeteAVR which was to do with atmels bug in the relative path calculation ..
PeteAVR :
When you added the Include Path in the Project Options and used the "..." button to locate the directory, there might be a "../" missing at your "../../Inc" path. This bug Atmel support confirmed to me. When addressing a lib directory directly outside from your project you normally need the path "../../../lib" added.
A link by Atmel on the word press site suggests that the relative path is with the output directory .. I think that is what makes the difference
[url]
http://avrstudio5.wordpress.com/...
[/url]
So, now after you have give it the relative path to library/INC ADD an extra ../ at the begining in the Add include Path dialog
So, from
../../../Library/INC it becomes
../../../../Library/INC
Click ok. Compile and it compiles just fine ..
Conclusion :
Either use absolute paths(Uncheck the relative path box) when adding libraries or else use relative path and add an extra ../ and wait for Atmel to come up with a resolution
I hope this helps someone and saves a lot of time wasting stuff when nasty errors like ..no such file or directory thrown up and one doesn't have a clue why it is throwing such errors when actually the file exits !!
Thanks a lot to all of you for all the help !!
[/code]
Hello guys please help me.
whenever i use PROGMEM in AVR STUDIO 5 (c++ beta) , it shows
Warning -
whenever i use PROGMEM in AVR STUDIO 5 (c++ beta) , it shows
Warning -