I have a C++ project proj1 with some source files in, however I would like to also use some of the source files I have in another project proj2. proj1 and proj2 are both subdirs of a directory my_projects. I don't want eclipse to copy the files as I want to ensure I have only one copy to edit. This is like the "add existing item" option of MS Visual Studio.
The end result I'm aiming for is to be able to create makefiles for both proj1 and proj2, zip up the two directories together and send them to coworkers so they can build the two projects themselves using make.
Is this possible in Eclipse? I've searched and haven't found the solution.
Phil
If you have proj2 open in Eclipse right click on the project and choose Import... and then select General > FileSystem and hit next. In the top window choose the directory in proj1 that contains the resources you want to link. After selecting the files you want to link in the top window hit the Advanced button to open up a submenu and select Create Links in Workspace as shown in this screenshot:
This question addresses setting up a Makefile with relative instead of absolute paths: Getting Eclipse CDT to use relative include paths in generated Makefiles
I looked forever for a solution to this, and I finally found it. Right click on the project and select Build Settings. Under the Build header on the left click "Settings". Then under the "Tool Settings" tab click "Directories" under the compiler header. Then click the add button at the top. If the desired files are in another project in the same workspace click the workspace button and then navigate to the exact folder where the files are. Once you have done this voila! you should be able to build the project!
Related
https://github.com/gladosconn/ecdsa_cxxI have been trying to get this library into my project (C++ using Visual Studio 2022, in Windows) because I need to use the ecdsa signature algorithm, I have copied all the files in src folder to a folder called "ecdsa" in the src folder inside my project, and I didn't do anything with the test folders (I think that I don't need them since they're just tests), but then there are these files (.ytml) ,(.txt) ,(.py), I have no idea what am I supposed to do with them or where to put them, but I sure I need them because the program isn't working, it's giving me this error Cannot open include file: 'secp256k1.h': No such file or directory Libraries.Also I have done everything in the requirements section, my compiler supports C++11, and I have installed openssl, and I have CMake installed.This is my first time using anything from Github so I'm sure what to do.
In Visual Studio, right-click on your project in the Solution Explorer pane. From the menu that pops up, choose the 'Properties' item. It is usually at the very bottom. A dialog box will appear.
In the left pane of the dialog box, expand the options Configuration Properties > C++ > General. Now, in the right pane of the dialog box, probably at or near the top will be an item labeled 'Additional Include Directories`. Add the full path to the folder where you copied the source files from GitHub.
You may need to explicitly add ALL the files you downloaded from GitHub into your Visual Studio project.
Try compiling again.
In my file explorer, my C++ project folders are like this:
... -> Documents -> C++ -> Files . . . . Projects
[In C++ folder, there are two more folders, called Files and one called Projects. I keep all my games/projects in the Projects folder. Each game has its own folder inside.]
Now here's the problem: I want all my common functions (.cpp & .h) to stay in one file folder, so if I ever change it, it changes for all my games. I want to keep these in Files. Is there a way to achieve this, like #include [Directory]? I know I can keep a file in its own game, but I want these to be all changed easily, and my code does not need to be transferred between computers. Thanks
This is not the right way to do it. If you have functionality that is shared between different applications (games, in your case), make a library from them and include that library in all your projects.
Solution for Visual Studio (2017)
For Source Files:
In the solution explorer right click on Sourcefiles and click "Add"/"Add existing" and choose your file(s)
Setting Include directory:
In the solution Explorer right click on your "Project" and click Properties
On the top set "Configuration" to "All Configurations"
Choose in the lsit on the left "VC++ Directories"
Click on the Dropdown arrow on the row with "Include directories" (you might have to click once on the row for the arrow to appear
Click "edit"
Add one line for each include directory. Use the folder icon on the top to open the file explorer to choose the directories
I'm working on a C++ project, after imported this project to eclipse, there are 3 new files/folders generated, they are:
.cproject
.project
.settings/
Not every one is using eclipse, so I'm not allowed to push this files to the repository, but I need them in order to work on eclipse, what should I do in such a situation when do the pushing.
You could add rules to the .gitignore file (and push that change by itself) so that they won't appear in git's list of working directory changes when you are ready to stage files for a commit.
Git Ignore Documentation
I installed the EGit plugin for eclipse found here:
http://www.eclipse.org/egit/
In order to manage the hidden files in a C++ project I open the Navigator by selecting menu option:
Window -> Show View -> Navigator.
In the Navigator (on the left hand side) you can see all the files that are hidden from a C++ project (like .cproject).
Select all the files/folders you need to ignore, right-click on the selection and go to popup menu item:
Team -> Ignore.
When you first ignore files in a folder a new file may appear (if its not already there) called .gitignore. You need to decide if the .gitignore file is going to be shared project-wide or not. If it is not currently being tracked and it needs to be you can add it to the index by right-clicking it and selecting Team -> Add to index. If it is not going to be tracked in the repository then you can select that file and ignore it.
Hope that helps.
Using Indigo and a managed build C++ project, I right-clicked on a source file and selected Resource Configurations->Exclude From Build..., and the file promptly disappears. Scrolling down shows it at the bottom of the list of source files with a new dimmed icon. Now how do I get it back? The Reset to Default... option is always dimmed out. Right-clicking on the excluded file still only shows the Exclude From Build... option. Is there an Include in Build option somewhere? I realize I can go to .cproject file and manually edit it back in but I figure there must be a way to do it from the IDE.
Yes this is an old question. But people do go looking for answers years later..
There's an easy way, but it's counter intuitive. Right click the excluded item, select "exclude from build", and on the dialog that appears, uncheck the builds for which you'd like the item back. Note the convenient 'Deselect All' button.
In eclipse there's not a similar way to reinclude resource, like:
Resource Configuration -> Reinclude from build
You need to go in Project Proprerties (Alt+Enter) and go:
C/C++ General -> Paths and Symbols
Select tab
Source Location
and expand your project's folder: here you can select filter that you want to remove and click on "Edit Filter" and then "Remove".
While I still don't know how get back a file that's been excluded. I have discovered that it's much better to just add a new folder, and then mark the folder as excluded. Then files can be excluded by dragging them into this folder and included back by dragging them back to the original folder.
I've found similar questions across the internet, none of which helped me. The Code::Blocks workspace and project files included DO generate .a files, and I've moved them to Codeblocks/MinGW/lib, and I've moved the Box2D folder to Codeblocks/MinGW/include and yet the HelloWorld.cpp example still gives me these errors.
Looks like the project files you used to build the .a were missing some files. The file mentioned in the error message is one that was removed from Box2D after v2.1.2, so I'm guessing you are using 2.1.2 source code (or thereabouts) with project files from some other source?
In any case, setting these up yourself is really simple. In the 'Management' panel, right click the 'Engine' project, select Remove files and click OK to remove everything.
Now do the same and select Add files recursively, choose the folder that contains Box2d.h file:
Click OK a few times, and you're done.
In your case, since you had it building already I would expect this to be ok now but for anyone arriving here wanting to setup a project file from scratch, you'll also need to specify the search path for the Box2D headers.
To do this, in the same right-click menu choose: Properties -> Project settings tab -> Project's build options button -> Search directories tab -> Add button. Now choose the parent folder of the one you just chose above.