what is a project in eclipse? - c++

I've just started working with Eclipse for C++ and I just want to clarify something that I haven't been able to figure out by searching so far. Is a project folder in eclipse only intended to have one program in it? i.e., a what is meant by project is basically a C++ program? And so you're not supposed to store many different programs in one project directory? Am I understanding this correctly?

That is correct, though they are trying to change that:
http://www.eclipse.org/eclipse/development/towards-more-flexible-projects.html
Eclipse requires that the contents of each project be stored in a
single directory on disk. Every file and folder in that directory tree
on disk must belong to the project in the workspace

Project is a project. You could divine you aplication to .dll, .exe, or other stuffs. When you are developing something that could go apart in another solution the you can put apart that piece (.dll for example). When you are developing in Visual Studio you can see that projects are in final a single file that has some own functionality, and the whole program is called solution. Didn't fired up Eclipse for a while, but it goes in the same direction. I can remember that projects in Eclipse were very poor, and meaning of the project was considered with actual language that you use (Java, C/C++, PHP, PYTHON, etc.).
Good definition is that project hold some part of application (if not all of it).

Related

Eclipse CDT: multiple C++ files in single project

I'm on Mac OS Mojave(Version 10.14), using Eclipse Photon. I have a single C++ project(which won't show up in the C++ perspective, only the Java perspective), and I'd like multiple packages/folders for various things. For example:
- MyCPPProject
- School
- Lab01.cpp
- Lab02.cpp
- Personal
- File01.cpp
- File02.cpp
All of the C++ files will have main methods(which is why I can't run them if they're in the same project). All of the files will be "simple," meaning that they will not do anything beyond competitive programming(so nothing beyond cin/cout or scanf).
The Internet says I need a new project for every main method. Does anyone have any ideas so that I can keep my programs in 1 project?
Thanks in advance.
The way Java works, you can have a different static void main(String[] args) for every Java class. Neither C nor C++ work like that: you're limited to exactly one "main()" per .exe.
That, in turn, means that you must define a separate project in Eclipse for each separate .exe. That's just the way it is :)
Eclipse, however, allows you to "group" projects into "Working Sets":
What is a working set and how do I use it?
So if you wanted to, you could organize your projects into "School" and "Personal", filtering out one or the other as you wish.
Finally, there are C/C++ "Online Fiddles" that allow you to easily run small, standalone .cpp files and that you might prefer over Eclipse, MSVS or CodeBlocks:
List of Online C++ Compilers
'Hope that helps!

Is it possible to export a project directly from visual Studio into it's own folder?

I am currently trying to build .net bindings for a very large project that is written in C an C++. The project was recently ported over to Windows, and I might add that is is a big giant mess.
The solution has about 12 projects, which is fine but the directory itself has alot more files than needed,since it includes OS specific source files, demo projects etc.
Also the other thing is the headers and source files are scattered all over the place. I am working on a parser to help me create the bindings for this project, but I am having a heck of a time. Especially when the internal include references are completely off.
The developer did a great job porting this large project to Windows, but isn't very organized and it is driving me bonkers with the issue my parser is having. So the easiest thing to do would be to re structure and put each project in it's own areas.
So as I asked in the title, is there somewhere that I can export each project and it's files from VS 2010(or another tool) so I can begin restructuring the folders? When I have ever needed to do this before in .net it was easy enough to just move the files. In smaller c++ projects I just open up the project file in notepad++ and move each file in the include/source list into different directories and changed the paths in the project file after. The issue with that is it will take way too long, and I have already spent days messing with this project, finding the best way to wrap it, and creating my helper tools.
Can anyone give me some assistance in this aspect?
EDIT:Just to clarify, I would like to export each project into it's own root folder with one folder for headers and one for source files so I can keep things simple.
I'm not sure about a tool for this, but the .vcxproj project files are in XML format, so you can easily extract a list of files from each project. Then you could relocate those files and write their new location back into the project.
Whenever I encounter a serious project mess, I usually end up dragging all the project files into Notepad++ and start doing global search and replace.
I haven't done it on the scale that you seem to be aiming at, where it involves relocating all the sources. You could be in for a rough ride. Fixing up include paths etc could be quite a pain.
I suggest you obtain the file lists (relative paths or whatever) in a simple text format, and then decide whether you want to take the red pill or the blue pill =)

new to eclipse and c++: how does a c++ project get deployed?

i am using c++ in eclipse, a project which contains many header files , cpp files...etc when finally done, how does it actually get implemented in the real world once it is done? Does an .exe file get created ? Or how can users install the program on their computers?
Can you share your experience with me ?
Also can you tell me what IDE you use for C++ development ?
I tried to look through some documentation but could not find anything.
When you compile the code, it will output an executable file (.exe) that can then be run from a command line, double-clicked, or put into an installer. The executable files name will be .exe and placed in the output directory as specified in your project settings.
As mentioned, this can be bundled in an installer but that is very likely overkill and way beyond what you want. So long as you have used standard C/C++ libraries that come installed on a user's system, they can just invoke the program from a command line or simply double-click the executable. If your program doesn't have any interface and simply prints messages, then they person will want to run it from the command line. Finally, if you have used other libraries that you need to include with your program, then an installer may be what you need in order to make sure the end user has everything they need to run your program.
As far as IDE's go, I've used both Eclipse and Visual Studio. Visual Studio is better tailored to C/C++ development (this is assuming you are programming on a Windows machine) but has the downside of costing money if you don't get it through your employer or school. If you can get access to it through either of those channels, I would choose it over Eclipse. Eclipse will do what you want and is free, but Visual Studio might be a bit better. Also, if you are going to spend money anyway, I suggest looking a SlickEdit. I use this at work and really like it for C/C++ development.

What is the SVN best practice for storing source when developing and testing with IDEs?

I do a fair amount of personal development on my computer and have used TortoiseSVN (I'm on windows) for web projects, but haven't used any version control for other languages. Anyways, soon I will be starting a decent sized C++ project and was going to try using SVN for it.
For web development, I normally just used notepad++ and it was really easy to manage it with SVN (just commit the whole source folder). However, for this project I will be using an IDE (most likely Eclipse CDT or Visual Studio) and was wondering what the best practice is to manage all of the IDE, project, and binary files. My guess was to make the IDE project outside of the version control, and just point to all of the source files into the SVN so all of the build and project files aren't committed. This way the only files in the SVN would be the .cpp and .h files.
However, if I wanted to switch to a new branch, then I would need to update the location of all of the source and headers to the new folder which seems like it would be a huge hassle.
Whats the best way to handle this?
Thanks
Ok, it seem I misgot the aim of the question in the first round. Now I'm assuming what is asked really to what to put under source control and what not.
Well, naturally everything but temporary/transient files.
If you install GitExtensions, it right away has a feature to populate the .gitignore file. Certainly depending on language you adjust it. Sure, solution, project, make files belong under control. .USER files storing some IDE preferences do not. As both IDEs and source control is ubiquitously used the content is fairly separated for many years, and should be pretty obvious as you do it.
External dependencies normally also shall be in a repo, though choice shall be made in which one. Some store everything together, others keep one dependency repo, others separate repos per component -- all depends on actual components and workflow. And you can replace physical storage of deps by an info file with stable links to the used version. It may also be covered later on the first change in dependencies.
For Visual Studio, there is a plugin that manages your files for you. As long as the files are part of the project, then they will be put into source control by the plugin. See ankhsvn for plugin info. Note that the express versions of Visual Studio are not supported.
I am sure eclipse has a plugin for SVN as well.

Translating C++ project from .exe to .dll?

I have develped my GUI Application in Qt though Qt Creator IDE & MinGW compiler.
I plan to Open source it under the terms of GNU-LGPL.
Now since I had developed all the source code with my GUI Application in my mind, I am having difficulty in modifying the project so as to build a .dll which others can use in their applications. Here are some of my doubts:
Should I maintain a different sets of source files for .exe project & another for .dll project, considering that I will be maintaining my project on GitHub.
Should I delete all the GUI related code from the .dll project? Or it would be fine to just put bool flag's everywhere GUI is created/modified?
Should I delete those functions which were only used in .exe project & will never be called in .dll project? Or should I let them be as it is?
This is my first time at Application development as well as Open Source development. Since I have developed it myself, I dont have proper guidance.
Thank You.
I would separate the program into two projects. Place the GUI stuff in one project which uses a dll created by your other project. That way you only need to maintain one instance of the dll's code. Having duplicate code in any way is usually a bad idea.
(Credit where credit is due: I got this idea from the third comment in this question. It's about C#, but the solution applies to any kind of project.)