Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » installing existing code into a new project(installing existing code into a new project)
installing existing code into a new project [message #1019013] Thu, 14 March 2013 22:17 Go to next message
sydney faria is currently offline sydney fariaFriend
Messages: 54
Registered: March 2013
Member
I have Eckel's C++ book and source code in a folder in my machine, and now I would like to create new projects and put the various examples into projects so that I can use them along with the book tutotrial. So I created a new c / c++ project in a new workspace in the eckel folder as this seemed like a good place for the new workspace. Then I created a new C++ project to use for the code. I can open a code (cpp) file and see it in the code view, but that doesn't put it into the project, so compiling it does nothing! How do I put in the various code files into this new project so that I can use the book code in the project and compile and run it? Also, I had to put in an environment variable PATH = C:\minGW\bin to get my first example running, co will I have to put this environment variable into every new project or will it stay in there as a default?
Re: installing existing code into a new project [message #1019272 is a reply to message #1019013] Fri, 15 March 2013 10:55 Go to previous messageGo to next message
Nick Schweyer is currently offline Nick SchweyerFriend
Messages: 175
Registered: July 2009
Senior Member
There are two possible ways to import code:
1) you do it by copy and paste
2) the better method is using the import function of Eclipse
Menue: file/import/General/File system
Then follow the interactive steps.

Generally, any files to be used within Eclipse should be generated via the menue items or imported by the import function (here you also can import complete projects). This is valid at least for managed projects.

I am working with Eclipse on Linux but on Windows the menues should be similar.


Niko

Eclipse-CDT Version: 2019-12 (4.14.0), Win10 64bit
Re: installing existing code into a new project [message #1019492 is a reply to message #1019272] Fri, 15 March 2013 20:32 Go to previous messageGo to next message
sydney faria is currently offline sydney fariaFriend
Messages: 54
Registered: March 2013
Member
Well now I can create a new C++, empty project configured to minGW and debug and release. Now I tried to import a C++ file from Eckel's book code by the following steps: File->Import->File System->select a directory->choose a cpp file to import-> finish. Now the project explorer contains the imported code! Building it and running it is another case. When I go into the run & debug configuration menus to make sure the environment paths are good for the minGW/bin directory I find that they are. Both configurations for both projects are the same: the working hello world made from the tutorial and the imported hello world are all the same except the imported project's main menu is complaining that the "Program does not exist"! By comparing the two projects I see that the one that works has Debug\filename.exe file in the C/C++ applications box so I tried the equivalent name for the new project and then everything ran amuck, the error did not go away! No executable code can be generated because the configuration can't be done without fixing the "program does not exist" error and I am stumpted on this one. What is this error message all about! I sure would like to be able to import Eckel's code into some projects so I can get on with learning C++!
Re: installing existing code into a new project [message #1020980 is a reply to message #1019492] Tue, 19 March 2013 09:47 Go to previous messageGo to next message
Nick Schweyer is currently offline Nick SchweyerFriend
Messages: 175
Registered: July 2009
Senior Member
I am not familiar with the Windows Version of Eclipse.
Every time you add source files the make file has to be adapted.
Generally you may have a managed project where the make files are generated automatically. Every time you insert new sources or delete some of them the make file(s) are adapted automatically. This type of project I would recommend. When generating a new project you have several choices. One which seems to be suitable is new/project/C/C++/Make file project with existing code.


Niko

Eclipse-CDT Version: 2019-12 (4.14.0), Win10 64bit
Re: installing existing code into a new project [message #1023228 is a reply to message #1020980] Sat, 23 March 2013 17:29 Go to previous messageGo to next message
sydney faria is currently offline sydney fariaFriend
Messages: 54
Registered: March 2013
Member
So you are saying that I should have created a makefile project with existing code instead of creating a new C++ project and importing the code into the project? So what happens if I create a new C++ project from scratch and after I have been developing code with it I find that I have to import a piece of code into the project instead of writing it in by hand, will this technique not work then because I didn't start out with a makefile project? I thought that this IDE created and updated a makefile with any new project and that this should be taken care of for any project whether or not I am importing files into the project!
Re: installing existing code into a new project [message #1032047 is a reply to message #1023228] Tue, 02 April 2013 14:05 Go to previous message
sydney faria is currently offline sydney fariaFriend
Messages: 54
Registered: March 2013
Member
After going through the Eclipse tutorial for making a new project I finally figured out the there are 2 ways of making a project: one with a makefile (which was suggested by another reply) and the other without a makefile (you have to create one yourself) which is completely different than the DevC++ environment that does everything for you when you create a project. Now I can do it both ways, so the problem is solved!
Previous Topic:Couldn't save workspace
Next Topic:release process
Goto Forum:
  


Current Time: Fri Mar 29 12:59:21 GMT 2024

Powered by FUDForum. Page generated in 0.02507 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top