Author Topic: Creating a project file from existing source code and header files?  (Read 32581 times)

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
I can't find how to do this anywhere.  I have two files test.cpp and test.h that I want to create a new project in code::blocks with.  Does anyone know how this is done?

I know how to add files to an existing project and how to add a file to codeblocks but not how to use my files (test.cpp and test.h) to create a new project.

Thanks

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Creating a project file from existing source code and header files?
« Reply #1 on: June 27, 2013, 10:30:56 am »
Create empty project in this folder and add the files. Then set it up.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Creating a project file from existing source code and header files?
« Reply #2 on: June 27, 2013, 10:47:38 am »
Thanks, but this is surely not the conventional way of doing it?  I do it this way already but unfortunately the project file needs to be amended because the file names have changed and if I change the names of the source code and header files this has implications for the includes.

There must be a conventional way of doing this?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Creating a project file from existing source code and header files?
« Reply #3 on: June 27, 2013, 12:08:09 pm »
I don't understand what file names have to be changed.

If it is an old project where you have a dsp, vcproj or something else we support you can import your project, otherwise you have to create it from scratch.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ToApolytoXaos

  • Guest
Re: Creating a project file from existing source code and header files?
« Reply #4 on: June 27, 2013, 12:11:08 pm »
If I understand it correctly, what you really want to do is what currently a compiler is doing, by placing its header files to a certain location and adds it to PATH.

You could create a directory in a location of your choice, preferably without spaces, and add it to PATH; this way, you could include it to any project of your choice, and change their names accordingly.

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Creating a project file from existing source code and header files?
« Reply #5 on: June 27, 2013, 01:30:39 pm »
I'll explain it another way.
What I'm trying to do is this.

I am using code::blocks.
It has an avenue to create projects in FLTK.  I have FLTK and have build it and it is working.

If I want to take some of the example files from the working examples provided (and I have seen them working) and build them myself, I have a .h file and a .cpp file

If I create a new FLTK FLUID based project in code::blocks it gives me a project file, a header file and a cpp source file. 

You would think I could just copy and past the contents of each FLTK source and header file to the one generated in the code::blocks project window but it's not as simple as that.  The project file also needs updating because if you open it up in a text editor you will see the names of all the source and header files it will be expecting to see.

Now... If I have dozens of header files and dozens of source files its simply not practical to do this.  A big waste of time actually.   I want to know if there is a way to navigate to the source and header files generated by FLTK (which is a gui toolkit by the way) and include them or turn them into a project,,, recognized as a project in codeblocks so I can compile it and do everything with it I would normally do if I had built the project from scratch in codeblocks myself.

I know there are a myriad of alternatives but I want create a project based on the header and source files I got from somewhere else.

Thanks :)  :'(

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Creating a project file from existing source code and header files?
« Reply #6 on: June 27, 2013, 01:41:42 pm »
I know there are a myriad of alternatives but I want create a project based on the header and source files I got from somewhere else.
You could probably modify the FLTK template. It is just a script, so you can right click on it and then edit it to suit your needs.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dominover

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: Creating a project file from existing source code and header files?
« Reply #7 on: June 27, 2013, 02:09:12 pm »
Actually it won't.  How do you compile a gui into an exe file which opens the gui when you click on it (to put it simply) by altering the template?

I want to use code::blocks. I want to use code::blocks..  It will help allot to learn how to do this.

By altering the FLTK template I can generate code using FLUID which will need to be compiled in a compiler.  That compiler will be MinGW which has the means to create FLTK projects.  Lets imagine it is not FLTK for a second.  Something else where there is no alternative.

How would I use existing code to set up a codeblocks project without the copy and pasting of code ritual?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Creating a project file from existing source code and header files?
« Reply #8 on: June 27, 2013, 02:26:18 pm »
Sorry but I don't understand what the goal of your last post is.

I've told you that the fltk project template in fact is just a script, so you can open it and modify it to suit your needs.
But I guess I don't understand what is your use case exactly. And now I'm sure that by 'Create project' you mean something else than the operation 'File -> New -> Project-> blabla'.

Keep in mind that there might be none of us that have used or uses FLTK, so you'll need to explain stuff better!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Creating a project file from existing source code and header files?
« Reply #9 on: June 27, 2013, 04:37:22 pm »
Here's one way:

1. Copy the files you need to some directory D
2. File ... New... Project... FLTK
3. Choose a name, the location etc, make sure the location of the CBP file will be in D
4. Project... Add files...  to add your source files to the project
5. In the project tree (manager pane) right click on the files that the wizard created and remove from project. (EDIT: You will also need to delete the files in a file manager if you want to truly be rid of them)
6. Save the project, build and run

Hopefully that should be it
« Last Edit: June 28, 2013, 02:44:26 am by dmoore »