Thread: Giving CodeBlocks a shot

  1. #1
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875

    Giving CodeBlocks a shot

    And have a question. I am used to managing large projects via either autotools or CMake (the latter of which I am using now) but after hearing about how many folks rave about it I installed it last night and am in the process of importing a large-ish project into it that I had working on CMake but I am maybe 25% the way finished (with general building of the projects, code, etc). And I ran into a problem with CodeBlocks that all of my best cuss words and Google efforts have failed me on. I see everywhere about how CodeBlocks supports multiple targets but nowhere on how to actually do it.

    Currently my project which is an application framework, is built like so:

    Overall console app to run/use the individual libraries for a larger purpose.

    Thread library (shared object; all libs are)

    demo/testapp to test and demo how to use thread library.

    virtual memory library

    demo app to test/show how to use the virtual memory manager

    ipc/messaging library

    demo/testapp for same

    shared memory window manager library

    demo app for same

    .. etc. In total I will have probably a dozen or more libraries, each with a testapp/demo program plus the overall app which will represent a swarm-computing tool. In CMake it is childs play to set up the dependencies so when one of the libraries is rebuilt, so is the demo app and the overall app. If starting from scratch, the main app and the demo apps need the libraries (some of which need other libraries) and the dependency chain is built as-needed.

    Is there any sane way of setting this up in CodeBlocks? It was non-obvious to me how to (it did offer to let me make a static lib...meh) but sometimes I fear I have been doing things at a low level for so long I am just not that good with the pointy-clicky stuff anymore. Thus I thought to give CodeBlocks a fair shake and see; if the fancy IDE really does help me be more productive, produce better code faster and more reliably I might revisit some of my assumptions. If not I will at least know I was right all along and can get better results faster using low-level tools I know.

    PS: Also I like to have a single binary output folder and a single shared include folder for all projects so they can share .hpp files...
    Last edited by jeffcobb; 05-21-2010 at 07:36 PM.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I've used CMake and I agree it's pretty cool albeit not all that intuitive at first. Don't know anything about CodeBlocks but we do get tons of questions about it. Not sure if that means it is not intuitive or is extremely powerful.

  3. #3
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    For just the start of this project (I am in the middle of importing it from an autotools managed project so not all of its there) this is all the configuration I needed to build three or so of the shared libs and one of the demo apps:
    Code:
    cmake_minimum_required(VERSION 2.6)
    PROJECT(libfoundation)
    
    SET(CMAKE_BINARY_DIR ${libfoundation_SOURCE_DIR}/bin)
    SET(LIBRARY_OUTPUT_PATH ${libfoundation_SOURCE_DIR}/bin/lib)
    
    ADD_DEFINITIONS( -Wall -ggdb )
    INCLUDE_DIRECTORIES(${libfoundation_SOURCE_DIR}/include)
    ADD_LIBRARY( foundationproc SHARED ./proc/foundationthread.cpp)
    ADD_LIBRARY( foundationshm SHARED ./shmwindow/shmwindow.cpp)
    ADD_LIBRARY( foundationvm  SHARED ./vm/foundationvm.cpp)
    ADD_EXECUTABLE(foundationproc_test ${libfoundation_SOURCE_DIR}/demo/proc/threadtest.cpp)
    TARGET_LINK_LIBRARIES(foundationproc_test foundationproc pthread)
    I have used CMake in the past on some pro jobs that had to manage a similar multi-platform project (lots of shared objects, some test apps, main gui app on Windows and WindowsCE, Linux and Mac) , data center servers on 64bit linux, etc and it really was a life-saver....sometimes you just come running back to what you know...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Haven't yet worked with huge projects in C::B. A bit of poking led to project->options->build targets. You can add a bunch of targets; then when you add/create files you can specify which targets that file "belongs" to.

    (Note also that you can use whatever make system you want, if you check "custom makefile" and then specify the make commands under project->options->build options->make commands. That might defeat the purpose of the exercise though.)

  5. #5
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Quote Originally Posted by tabstop View Post
    Haven't yet worked with huge projects in C::B. A bit of poking led to project->options->build targets. You can add a bunch of targets; then when you add/create files you can specify which targets that file "belongs" to.

    (Note also that you can use whatever make system you want, if you check "custom makefile" and then specify the make commands under project->options->build options->make commands. That might defeat the purpose of the exercise though.)
    That seems to have worked; I don't know where I went wrong last time I tried this and only had console app or static lib as available targets...now to work on the dependencies...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  6. #6
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Some icky issues I have run across so far (and I swore I was laying off the code tonight):
    1. When making a shared lib, if I leave the output file alone (somefile.so) it just builds it in the projects home folder.
    2. I leave the check-box checked that says it will attach the proper prefix and suffix to the output file (in this case it should make library into liblibrary.so. It doesn't.
    3. To fix 1 and 2 I am setting the output file to projectdir/bin/lib/libsomelibrary.so, which it builds but if that shared library is needed for a testapp, it links it in such a way that I can only run the program from one specific folder or the executable can never find the lib, a double-whammy of a PITA.
    4. I am still hunting for where to set dependencies (executable A needs libraryB which needs libraryC and libraryD).

    Still its not totally terrible. I will work with it more to try to find the best in it. This is how I know I freaking hate VI; after hearing so many people rave about it, I did a complete project (3 languages on three platforms, along with docs) using solely VI for a month or so. I did get good enough with it do get it all done and after the first couple of weeks there was a minimum of pain. However I never got any value from it that something like Emacs did not provide to offset the pain so I gave it the flush and went back to my old editor...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  7. #7
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    I am not sure if this will keep up but I had two instances last night as I got more and more of this rather elaborate project integrated with the CodeBlocks system that no matter how many times I saved the workspace (which always seems to revert to save as instead of just saving over itself), project, CodeBlocks "layouts", on the next run it was always missing something, either files I had added, subproject settings (these are all unix-only ATM and either console apps or dynamic libs).....things would revert back to the default targets (Mac, Lin, Win), GUI apps, it would lose include paths, link libraries, etc. Just woke up booted it and am checking it out now for such mistakes. I can put up with a lot but if I have to keep re-creating aspects of my project I will be working ~ 20% more for nothing. And right now, these days I have so little spare time to devote to the projects that I want to that I need to be choosy how I spend it...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    ....(and I swore I was laying off the code tonight):
    You can't and that is because you are a sick super nerd like the rest of us.

    I've been using SlickEdit and I like it quite well. I would be willing to give CodeBlocks a try but I'll wait and see how your experience fares before I dive in.

  9. #9
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Sigh. My secrets out. FWIW I checked over my project settings this morning and found that one project settings had reverted to a Windows target and another one where the output binary had reset to the default and not the same one I (thought) I had set. It could have been the product of doing it at 2:00am but who knows.

    Oh and FWIW, SlickEdit is the default "environment" at work, such as it is.....it does OK but we have to switch code-bases so often sometimes the tags part of it gets confused which derails some of the functionality. Still, its better than a sharp stick in the eye.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  10. #10
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Is there anything like a macro recorder in this? I like having file and function header comments as macros for creating new files/functions and it keeps the code nice and readable. For example in Emacs if I open a new file and hit alt-x, jc-filecomment (only have to type the first 4 chars actually, has tab-completion) I get:
    Code:
    //******************************************************************
    //* File:
    //*
    //* Description:
    //*
    //* Date:
    //*
    //* Author:
    //******************************************************************
    //* R E V S I O N S
    //*
    //******************************************************************
    and if starting a new function, alt-x, jc-functioncomment (again, only first four chars) produces:
    Code:
    //********************************************
    // Method:
    //
    // Args:
    //
    // Return:
    //
    // Desc:
    //********************************************
    I looked around all of the menus and found neither direct ways (this is embedded in some fancier programmers editors) nor a way to record it and bind a key-combo to trigger it as a macro..I can sorta do the insides of the comments and then wrap it in a box comment I guess but it feels like a step back in functionality...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by jeffcobb View Post
    Is there anything like a macro recorder in this? I like having file and function header comments as macros for creating new files/functions and it keeps the code nice and readable. For example in Emacs if I open a new file and hit alt-x, jc-filecomment (only have to type the first 4 chars actually, has tab-completion) I get:
    Code:
    //******************************************************************
    //* File:
    //*
    //* Description:
    //*
    //* Date:
    //*
    //* Author:
    //******************************************************************
    //* R E V S I O N S
    //*
    //******************************************************************
    and if starting a new function, alt-x, jc-functioncomment (again, only first four chars) produces:
    Code:
    //********************************************
    // Method:
    //
    // Args:
    //
    // Return:
    //
    // Desc:
    //********************************************
    I looked around all of the menus and found neither direct ways (this is embedded in some fancier programmers editors) nor a way to record it and bind a key-combo to trigger it as a macro..I can sorta do the insides of the comments and then wrap it in a box comment I guess but it feels like a step back in functionality...
    This is settings->editor->abbreviations.

  12. #12
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    abbreviations? <blink-blink>. Man GUIs and I do NOT speak the same language

    Not in a million years would I have tried that...
    Last edited by jeffcobb; 05-22-2010 at 05:05 PM.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  13. #13
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    OK so after a long day of coding (both here and on my own stuff) let me ask for the really important feature: what is the key- binding for a caffeine injection?
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  14. #14
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    what is the key- binding for a caffeine injection?
    Probably have to check the help docs for that one.

  15. #15
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Not a fan of CMake at all... having used it for a while, it doesn't solve one of the biggest problems: The moronic syntax of Make. I would try bakefile (Doesn't seem to be that active lately) or premake.

    I'm not looking forward to the day that I'm forced to use something other than VIM (which supposedly isn't an IDE...).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code::Blocks Help
    By rakeshkool27 in forum C Programming
    Replies: 0
    Last Post: 01-16-2010, 08:25 AM
  2. library issues in CodeBlocks
    By everlearnin in forum C++ Programming
    Replies: 0
    Last Post: 06-02-2009, 08:44 PM
  3. Replies: 2
    Last Post: 05-10-2009, 11:12 PM
  4. Codeblocks crashes linux?
    By Shakti in forum Tech Board
    Replies: 1
    Last Post: 03-25-2009, 07:26 AM
  5. Replies: 1
    Last Post: 01-11-2008, 09:34 AM