I have a folder with some .h and .c files and I want to use header files in my projects.
I have included them in "Header Files" folder of my project using "Add Existing Item" but when i try to "#include" them compiler(mplabc18\v3.41) say "unable to locate file xyz.h"
So, what should i do to use these files without copying them into the project folder?
Just add the header to the project using the "add" dialog and select "this file is for this project, use relative path" dont remember if it is exac this text but its something like.
After that just do the normal declaration in your file:
#include "your_header.h"
This should work fine.
--UPDATE
To work with the new MPLAB X
Do the follow:
Click on the File-> Project Properties
Select the Conf -> C18 (Global Options) -> mcc18
For XC8, this is under Conf > XC8 compiler
Click on the "..." button of the propertie "Include directories"
Click on "Browse Button"
Locate you project directory
Click on Open, then Ok and Apply
Build your app !
Now it should work.
I know this is an old question, but wanted to add another tip since I just stumbled across it myself. If you go back and forth between Windows and Linux systems, be sure to pay attention to the capitalization in the filename. On Windows, it doesn't matter. However, on Linux, you need to be sure your #include reference has the same capitalization as the actual file.
If the file is saved on disk as 'UARTIO.INC', your include needs to be:
#INCLUDE "UARTIO.INC" **EXACTLY**
If you put it as:
#INCLUDE "UARTIO.inc", or #INCLUDE "uartio.inc"
It will work fine on Windows, but will fail with "Could Not Find Include File" errors on Linux.
Note that setting MPLAB to ignore case sensitivity doesn't matter for this.
Related
I have a file that shows up in "Open Quickly" on Xcode and shows up no place in the project if I do "Reveal in Project Navigator". It does compile correctly into several targets.
If I add the file to the project, the project cannot compile because the file is already included. How can I find this inclusion?
Note: The file does NOT show up in "Open Quickly" on App Code, but I can navigate to it via Command-B.
In AppCode you can use Navigate | File... (Cmd+Shift+O) and check Include non-project files - the file should be shown in the list.
Also, you can open the file in editor, switch navigator to Files mode and use Navigate | Select in... (Alt+F1) | Project View - the file will be shown in its actual location.
After that use Manager Targets action from context menu to see what targets this file belong to.
This bizarre situation happens because you are importing a .m file in one of your #import statements. If you fix this, the project will no longer compile, because the file will not be automatically included.
When i run my program in MPLAB. ( Project wizard -> PIC16F877A -> Hi Tech Ansi C Compiler -> RUN )
Error [141] C:\Users\WhyWhy\Desktop\test.c; 1.22 can't open include file "16F877A.h": No such file or directory
Where can i find the header file for the 16F877A?
Chip-specific header files should not be explicitly included in HITECH-C, the documentation clearly states that. Instead, you include the compiler header, which will take care of including the chip-specific file for you:
#include <htc.h>
All you need for this to work is to configure correct chip in the project settings. The 16F877A.h file exists in the compiler directory, but including it directly will throw a warning.
C:\Program Files\HI-TECH Software\PICC\9.70\include
In my case , I have installed HITech Compiler In C:\ Program Files.
You have to know, where have you installed the files of the compiler.
This file is from the compiler, so in your case the Hi Tech you can find here:
C:\Program Files\HIāTECH Software\PICC\\include\
Before you have found the file you have to add in the Header Files folder in the Project window on MPLAB.
And in your code you have to include it
#include <16F877A.h>
My project structure and files are as follows:
project\HAL\hw_lcd.h
project\HAL\hw_lcd.c
project\project\app.c
project\project\workspace.mcp
project\project\workspace.mcw
Where 'project' is a place holder for project name. I'm using MPLAB IDE 8.66 and HI-TECH Compiler 9.81.
I'd like to add hw_lcd.h/c files using relative path to the project. So that if I write #include "HAL/hw_lcd.h" in app.c, then hw_lcd.h will be found from app.c.
I added ../ as include search path (project > build options... > project > directories and search path > include search path) but got following error:
can't open include file "hw_lcd.h": No
such file or directory
Then I tried ../HAL as include search path and written #include "hw_lcd.h" in app.c. This also generates the above error.
Is it possible to use relative search path from within MPLAB IDE?
If the #include path itself is relative, then it works:
#include "../HAL/hw_lcd.h"
Not entirely the same, but I always use
#include "hw_lcd.h"
and then add the header to the project, and in the "add" dialog I select "this file is for this project, use relative path" or something similar.
This works fine. (but has the trouble that if paths (e.g. HAL) change, you need to walk over them, and change them all)
I have been trying to build a code that has dependencies with other header files that are not in the project directory. I added the paths to these header files in both HEADER_PATH and USER_PATH. However, I still see error while building. It says that the file is not found. I verified that the file exist in the path added to the header search path in project settings.
How do I make sure that all my header files referenced in the project is included and the paths are being picked by Xcode during compilation?
I tried copying all the files to the project with no luck. This is the first time iam using Xcode, so its kind of frustrating. Iam a linux guy and comfortable with make files. Is there a Make file for xcode which i can modify to include the header file directories.
You might want to check the order of your source files in your target's build phases to ensure that your dependencies are compiled before your source files that reference them.
Select your project in the Project Navigator.
Select your target.
Click on the Build Phases tab.
Click on Compile Sources to expand the section.
Drag the dependencies to the top of the list.
Are you sure you spelled the header file name correctly ? Is the case correct ? Did you use user quotes "" rather than system quotes <> ?
Assuming you've checked all the obvious things such as the above then one other thing to try is to quit Xcode, delete the "build" folder in your project directory, and try again - sometimes the build folder gets in a pickle internally.
Might be a very newbie question, but I can't find a way to remove files from my projects in QtCreator. Thanks!
If your project is generated from CMake, the file list is determined by the CMakeLists.txt file, and you cannot add or remove files manually from the source tree in QtCreator. Especially if your CMakeLists file specifies the glob operator for a project's file list, you must manually remove the files from disk and re-run CMake from within QtCreator by going to Build->Run CMake (QtCreator 3.3.0). This will update the file list but also regenerate the project (cbp) file - re-running CMake outside of QtCreator will not update the project file and you will have ghost entries of deleted files showing up in the source tree if you deleted them from disk.
Right-click the file you want to remove, and choose "Remove File..."
Checking the "Delete file permanently" check box will delete the file, otherwise it will just be removed from the project.
Find your project file .pro in qt creator or other text editor
Find the file/folder name you want to remove in the .pro file
Delete all the files you want to remove
save and close the project
Reload the project
DONE
Could not find one-touch action as in Eclipse to delete a class:
1) Press right click on the file/class, and then choose "remove file..."; (u can tick "permanently" to remove from HDD if you like).
2) Do it to .CPP and .H files.
3) Then check in your .pro file the class are not there anymore.
Note: Some compilers will keep searching for this file/class in compilation. Just delete the compilation directory and compile again.
If you mess up like me and accidentally add a lot of files to the qml.qrc, it might help to know that these are listed in the actual qml.qrc file which you can edit to remove these files.
I also run into this problem.
I wanted to remove a header file.
But remove action in context menu was disabled I didn't know why.
The file name was qtextdocument.h.
I wanted to change the name to textdocument.h.
I tried to do various ways, but the filename was strictly fixed.
My removal procedure was as follows:
I dare to add an empty file to the file directory (in header file directory).
Anyway, I set the file name as textdocument.h when Qt Creator asked me to set the filename.
A confirmation warning popped up.
(Qt Creator cannot add the file automatically, we must add the file name to CMakeTextLists.txt)
I changed the filename in CMakeTextLists.txt from 'qtextdocument.h' to 'textdocument.h' in the row of set(PROJECT_SOURCES).
Finally, the update was confirmed. 'qtextdocument.h' was removed and the name is changed to 'textdocument.h'.
If you only want to remove a file, only you have to do is to delete the filename when you are in step 3.
After updating the project tree, the actual file is in your computer.
If you want to delete the file completely, you select file system and remove the file, not from project.
I don't know why, but in the case of filesystem mode, remove action is enabled.
So I might & should have told you that you select "filesystem mode" and remove the file at the first time...
(Sorry I have found out this fact later.)
Both of the two ways, I think we must rewrite the contents of CMakeTextLists.txt.
I also run into the case , the update removed the filename as soon as I deleted the filename from CMakeTextLists.txt.
I believe this case I directly make a file in the actual directory. On the contrary, above case is the files are added from Project menus.
go directly delete the project folder from your hdd.
For Linux, edit ~/.config/QtProject/QtCreator.ini
Under [ProjectExplorer], delete the project name and its corresponding configuration file from the following two lists:
RecentProjects\DisplayNames
RecentProjects\FileNames
e.g., given the following
RecentProjects\DisplayNames=proj1, proj2, proj3
RecentProjects\FileNames=<proj1_dir>/CMakeLists.txt, <proj2_dir>/proj2.pro, <proj3_dir>/proj3.pro
to delete proj1 from the qtcreator startup page, edit the above two lists as
RecentProjects\DisplayNames=proj2, proj3
RecentProjects\FileNames=<proj2_dir>/proj2.pro, <proj3_dir>/proj3.pro