Eclipse: C project folder structure - c

I have an existing C project with the following folder structure:
bin
proj
src
inc
doc
conf
When i launch Eclipse and create a new project the root project folder is polluted with:
.cproject
.project
Also the parent folder with:
.metadata
RemoteSystemsTempFiles/
A want to continue use Eclipse as an C IDE with a my custom makefile (or not) but I want all Eclipse related files and folders to be put inside the proj directory. I need Eclipse to debug ARM targets.
Is it possible? If not what is the next best thing?
I made a promise to myself to start a smooth transition from IDEs to vim with a custom makefile. I still need Eclipse to help me for debugging.
One step at a time...

The files .project and .cproject (and the .settings folder if it exists) contains the Eclipse-specific (general and C/C++) project configuration.
The .metadata folder is a kind of cache/temp folder (to store error/warnings markers, local file history, etc.) and also used to store your workspace preferences (most of Window > Preferences).
Files in a project are tracked and can cause changes in the .metadata folder. If the .metadata folder would be located in a project, this could end in an infinite loop.
You could use the workspace folder of Eclipse (which contains the .metadata folder) as part of your overall project folder and link instead of copy all files and folder that you want to see in Eclipse or that are required by Eclipse into your Eclipse project (you can also mark some files and folders as derived to stop them from being tracked and to make them less visible in Eclipse).
Note, do not share or move the .metadata folder (and derived resources). In contrast, .project, .cproject and .settings are intended to be shared.

Related

Git-Ignore in Xcode

I am using X-Code 10 as a C IDE. I am doing a group project and we must use GitLab to share the code. To work in Xcode there are a lot of files to make Xcode work, but none that I need to share with my partners who are using their own IDE and who just need the .c files we are working on. How do I make Git not upload ALL files and just the .c?
There are ways to handle the excludes for a git project. There is the .gitignore file where you can create rules for what files should be excluded from your project. This file will be tracked by git, so you and your teammates will be sharing this file.
For your own personal excludes, you can put them into the .git/info/exclude file. This will not be tracked by git and will affect only your own local repository. This is a good place put rules that are specific to your own workflow.

How to make multiple subdirectories in Eclipse from existing code

I am using Windows 10 and Eclipse Mars edition 32 bit. Programming in C
I am trying to learn C from a Lynda.com course C Essential Training. The course provides a zipped directory with many .c and files and a few others like .h files as you can see below.
However in the video he managed to get each .c file and related source code into its own directory structure.
I've tried numerous type of imports and I also used a batch file to put each .c file in its own folder and tried importing that. I was able to get the Eclipse IDE project window to look like the instructors, but as soon as I tried to compile individual .c programs the project kept looking in the primary workspace folder which for me is C:\Source\Testing\workspace and error'd out.
Is there an import option to create this type of subdirectory structure automatically? I want to go through the tutorial and build and execute each .c file individually. However what I have had to do is put the .c file into a single folder build it and run it one at a time. I then have to delete the source and debug folder and start over for each lesson. There must be a better way.
Eclipse workspace is streigh connected to FS.
This means that your workspace in Eclipse is a folder on your hard disk or where it is stored.
What you can simply do is to create a new folder using right-click-popup-menu within Eclipse Project Explorer and then copy/move files into the new folder.
Or you can create a new folder into your workspace directory and copy/move file inside, then you must refresh Eclipse workspace.

proper way to handle common header files with C and Git

So i have folders like this
c:\projects\generic\
c:\projects\project1\
c:\projects\project2\
Each folder under projects are their own separate local git repository. A project may use one or more header files from the generic folder. If a project uses a header file, it needs to be right in the project folder, not a subfolder under the project folder. Also, I probably wouldn't want the latest and greatest, I'd want to pull it by tag so I could be sure I have a specific version of the file in use for that project.
How would I do that? Is this something that could be done with submodules? Is there a better way to organize the folders in this situation?
I'd want [...] a specific version of the file in use for that project.
Yup: submodules are for exactly that. A submodule is a nested repository, the using projects' commits record (only) exactly which (other) commit SHA they need checked out at the submodule's path, git submodule just does the chores of getting the right submodule commits checked out when you want.
If a project uses a header file [from another repository], it needs to be right in the project folder, not a subfolder under the project folder [... I'm on windows].
It's lucky these are headers, otherwise there'd be a problem with that combination. As it is, the compiler can chase the relative pathnames with a #include "relative/path/to/submodule/header.h":
repo
|--generic.h: "#include generic1/generic.h"
|--generic1
|--generic.h: the real thing

Add external source files from a library to the project in Eclipse-CDT

I have a project which I try to compile with Eclipse-CDT. The project depends on a library with header files and source files. How can I configure the project in Eclipse such that it will compile the needed source files from the library with the project?
With a makefile I use:
SRC+=lib_source.c
You can add linked source file.
Choose project properties and in the left panel choose c++ general.
Under it choose path and symbols.
Now in the right panel tabs choose source location and add linked source folder.
Include you need to define in "include" (under c++ build you will find settings)
Another approach is to use the operating system to add your libraries to the project. Eclipse then treats all source files (including library files) as part of the project, and therefore compiles any that need it even if they are in the libraries. This set-up allows keeping the library sources in a separate git repository from the project source code. You can record the git commit of a library to provide library version control so that improving the library in one project does not break all the others. The setup relies on the operating system's capability to link directories in a way that is entirely transparent to eclipse--in windows using the mklink command.
In windows the steps are
put your library files in a clean workspace not mixed with .git (you can have .git in the parent directory as egit sets it up)
use cmd window in administrator mode to add a link from your project directory to your library directory.
from eclipse press F5 t make sure your project matches what is on disk, then set up git to ignore your library directory.
set up your library file properties for read only access unless you are still tweaking that library.
set up your project include path to include the project sub-directory in your project.
I can't remember why I abandoned eclipse linked directories; i think it was that the includes kept breaking. The mklink approach has worked flawlessly so far.
I have a pdf tutorial of how to set this up--but I'm new to the forum and don't see how to attach a file.

Eclipse CDT c project setup for a specific structure

i recently moved to a C project and i want to use eclipse CDT as my IDE. The project layout is a bit annoying. the header files are located
main_component/sub_comonent/include/ folder
However, in the c source file. they are referenced as #inlcude<main/subcomonent/sample.h>.
In eclipse, if i put include folder into my path, but in the source file will be referenced as #inlcude<sample.h> instead of #inlcude<main/subcomonent/sample.h>.
if i put the root of project into the path the real path will be #inlcude<main/subcomonent/includesample.h> instead of #inlcude<main/subcomonent/sample.h>.
so how can i configure eclipse to just have#inlcude<main/subcomonent/sample.h>.
thanks
It seems there is no better way. I finally decided to copy all the header files out to one folder by a bash.

Resources