Eclipse is one of the most prominent IDE's used today, that's what I think ;)
We may have many different projects in eclipse to manage, but what if you want to share a particular file say a header file across all your projects or among few projects?
Why do we need to share in the first place? Cause we don't want to have a separate copy of the same file in all the project workspace. In case if we had, then we will need to update all the files manually, right? Why take all the trouble, just share it across all the projects.
In this case, we want to share a header file across multiple projects. It's pretty simple actually.
Create a project with some name, say "Common" and add the header file there. In my case, I have a project named "log_utility" and have added a header file "global.h".
Now I want to share this "global.h" across other projects say "start_server", "start_client". Heard about "-I" flag in g++ or gcc? that's what we are going to use here also.
1. Right Click on the project where you want to add the file (start_server). [ Select the project and press Alt+Enter (shortcut) ]
2. Properties > C/C++ Build > Settings > Tool Settings > Includes
3. Now add the path/file you want to include
Here, I have added both the path and a particular file for reference.
1. Right Click on the project where you want to add the file (start_server). [ Select the project and press Alt+Enter (shortcut) ]
2. Properties > C/C++ Build > Settings > Tool Settings > Includes
3. Now add the path/file you want to include
Here, I have added both the path and a particular file for reference.
No comments:
Post a Comment