News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How to use Code::Blocks on an existing tree?

Started by C::, September 06, 2020, 03:53:11 AM

Previous topic - Next topic

C::

I want to see if, and how, I can use C::B for fixing some bugs in https://gitlab.gnome.org/GNOME/gnote

In other words, I have the gnote code base already downloaded, unpacked, and build-able on my Linux Debian box.  gnote is a gtk+ program that builds with autotools.

I've looked

* at your manual found here: http://www.codeblocks.org/docs/manual_codeblocks_en.pdf , and
* here: http://www.codeblocks.org/docs/main_codeblocks_en.html, and
* at the FAQ found here: http://wiki.codeblocks.org/index.php?title=FAQ and
* also at Help via C::B Menu> File | New | Project ... (but this seems to be to create a project from scratch),

so, I'm sorry, but I fail to see how to use C::B on an existing C++ project,  ...other than to possibly import it from MS Visual C++, MS Visual Studio, or Dev-C++, which doesn't apply to me in this case, as I'm not on Windows anyway.

How is the best way to get started using C::B, so I can try to fix a bug in gnote?  Is there some manual I'm missing that says how to get started on an existing code tree?

Thanks!

P.S. I've also now seen this http://forums.next.codeblocks.org/index.php?topic=18093.0, but it doesn't appear that dominover ever accepted any of the suggestions given, so it's not clear that this even works.  Is there an official description somewhere of how to go about this very common development pattern of working on some older code? 

BlueHazzard

Do you plan to use the debugger?

The general way to do this is:
1) Create a new empty project:
File->New->Empty project
preferable in the same directory as the code is
2) Import all source files
Project->Add files recursively
3) If this is a makefile project:
Project->Properties->Check this is a custom Makefile

Now codeblocks uses the make file for the build process

C::

#2
Which of my project files should I be 'adding' (recursively)?  Everything, or just some of them?  Or in other words, why is this question even asked and what is the outcome of it?  Should this be with a make clean  or make distclean, first, or not, or does it matter?  It does seem to default to only hpp and cpp files, so for now I'll just add them.

It doesn't seem to be putting this project in gnote.cbp, because if I start over it still knows about it, and asks me if I want to overwrite it.  For later backup purposes where is this project being saved to?

Thank you.  I'm new to using and IDE, and I appreciate your help in getting started.

And yes I plan to use the debugger, I hope, as I have to debug this as I go.


Here's what I've got so far:

After File->New->Project...->Empty project, I entered:

    Project title: gnote
    Folder to create project in:  /home/howard/src/gnote/gnote-3.30.0/
    Project filename: gnote.cbp                                                                            <-- used the default here and below
    Resulting filename: /home/howard/src/gnote/gnote-3.30.0/gnote/gnote.cbp

    Compiler:  GNU GCC Compiler
    x Create "Debug" configuration:     Debug
        "Debug" options
          Output dir:               bin/Debug/
          Objects output dir:  obj/Debug/

    x Create "Release" configuration:     Release
        "Release" options
          Output dir:               bin/Release/
          Objects output dir:  obj/Release


And I did check the Project -> Properties...-> Project settings->Makefile: 'This is a custom Makefile'.  Thanks.


My top level src directory before I started with C::B was:

/home/howard/src/gnote/gnote-3.30.0/ $ ls -1p
aclocal.m4
AUTHORS
ChangeLog
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
configure.ac
COPYING
data/
debian/
depcomp
gnote/
gnote-3.30.0.anjuta
help/
install-sh
libtool
ltmain.sh
m4/
Makefile
Makefile.am
Makefile.in
missing
mkinstalldirs
NEWS
po/
README
src/
stamp-h1
test-driver
TODO


This is a big project with lot and lots of cpp and hpp files.


stahta01

#3
Me I would use a CB custom makefile [project] and only add the files that I need to edit.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

BlueHazzard

QuoteWhich of my project files should I be 'adding' (recursively)?
All files you are interested in. It does not matter

QuoteOr in other words, why is this question even asked and what is the outcome of it?
If you are using the makefile project it absolutely makes not difference.... All files are ignored by codeblocks and only the Makefile counts

QuoteShould this be with a make clean  or make distclean, first, or not, or does it matter?
Not sure what you mean here, but if you call Build->Clean with a makefile project codeblocks calls the command line
make -f Makefile clean


If you use a Makefile project, codeblocks is only a better text editor. The build system is completely circumvented (This means settings of Project->Build options, or files in the Project are ignored by codeblocks. Only things in the Makefile count).



QuoteIt doesn't seem to be putting this project in gnote.cbp, because if I start over it still knows about it, and asks me if I want to overwrite it.  For later backup purposes where is this project being saved to?
I am not quite sure what you mean... but the project is stored in
QuoteResulting filename: /home/howard/src/gnote/gnote-3.30.0/gnote/gnote.cbp
It would probably better if you alter this path in the "new project" dialog to
/home/howard/src/gnote/gnote-3.30.0/gnote.cbp
or simply copy the existing project file to
/home/howard/src/gnote/gnote-3.30.0/gnote.cbp
Codeblocks does not care about absolute paths... Maybe you have to fix your Makefile path if you move the project file