simple boost::test, undefined reference to main

Discussion in 'C++' started by suresh, Sep 2, 2010.

  1. suresh

    suresh Guest

    Hi,
    the following code does not compile and being a newbie, i am unable to
    figure it out. could you please help?

    #define BOOST_TEST_MAIN
    #include <boost/test/unit_test.hpp>

    int add( int i, int j ) { return i+j; }

    BOOST_AUTO_TEST_CASE( my_test ){
    BOOST_CHECK( add( 2,2 ) == 4 );
    }

    compiled with the command, g++ test.cpp -lboost_unit_test_framework

    Error: undefined reference to `main'

    thanks
    suresh
     
    suresh, Sep 2, 2010
    #1
    1. Advertising

  2. suresh <>, on 02/09/2010 14:32:18, wrote:

    > Hi,
    > the following code does not compile and being a newbie, i am unable to
    > figure it out. could you please help?
    >
    > #define BOOST_TEST_MAIN
    > #include<boost/test/unit_test.hpp>
    >
    > int add( int i, int j ) { return i+j; }
    >
    > BOOST_AUTO_TEST_CASE( my_test ){
    > BOOST_CHECK( add( 2,2 ) == 4 );
    > }
    >
    > compiled with the command, g++ test.cpp -lboost_unit_test_framework
    >
    > Error: undefined reference to `main'


    Well, that linking error by itself is clear. The stuff you're trying to
    run doesn't contain any "main()" function.

    Besides of that, I'm not familiar with the Boost unit test framework
    (and neither it is exactly topical here) so I cannot help further.

    What puzzles me is the fact of even thinking to "fight" with such
    advanced stuff (Boost, unit testing and so forth) while being at the
    beginning. It sounds just like trying to complicate one's own life.

    If you don't have any particular reason for running that code, drop it
    and concentrate on the standard language features and on solving
    compilation and linking problems in _your_ programs. That would give you
    a decent basis that will help you solving more complicated issues, like
    solving a linking error while trying to run a test file in Boost.

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Sep 2, 2010
    #2
    1. Advertising

  3. suresh

    suresh Guest

    On Sep 2, 2:47 pm, "Francesco S. Carta" <> wrote:
    > suresh <>, on 02/09/2010 14:32:18, wrote:
    >
    >
    >
    >
    >
    > > Hi,
    > > the following code does not compile and being a newbie, i am unable to
    > > figure it out. could you please help?

    >
    > > #define BOOST_TEST_MAIN
    > > #include<boost/test/unit_test.hpp>

    >
    > > int add( int i, int j ) { return i+j; }

    >
    > > BOOST_AUTO_TEST_CASE( my_test ){
    > >      BOOST_CHECK( add( 2,2 ) == 4 );
    > > }

    >
    > > compiled with the command, g++ test.cpp -lboost_unit_test_framework

    >
    > > Error: undefined reference to `main'

    >
    > Well, that linking error by itself is clear. The stuff you're trying to
    > run doesn't contain any "main()" function.
    >
    > Besides of that, I'm not familiar with the Boost unit test framework
    > (and neither it is exactly topical here) so I cannot help further.
    >
    > What puzzles me is the fact of even thinking to "fight" with such
    > advanced stuff (Boost, unit testing and so forth) while being at the
    > beginning. It sounds just like trying to complicate one's own life.
    >
    > If you don't have any particular reason for running that code, drop it
    > and concentrate on the standard language features and on solving
    > compilation and linking problems in _your_ programs. That would give you
    > a decent basis that will help you solving more complicated issues, like
    > solving a linking error while trying to run a test file in Boost.
    >
    > --
    >   FSC -http://userscripts.org/scripts/show/59948
    >  http://fscode.altervista.org-http://sardinias.com


    If I want to do unit test, what else I can do, other than to use
    Boost? Boost::users list had been non functional and thats why I post
    my questions here....
    thanks replying
    suresh
     
    suresh, Sep 2, 2010
    #3
  4. suresh <>, on 02/09/2010 14:49:59, wrote:

    > On Sep 2, 2:47 pm, "Francesco S. Carta"<> wrote:
    >> suresh<>, on 02/09/2010 14:32:18, wrote:
    >>
    >>
    >>
    >>
    >>
    >>> Hi,
    >>> the following code does not compile and being a newbie, i am unable to
    >>> figure it out. could you please help?

    >>
    >>> #define BOOST_TEST_MAIN
    >>> #include<boost/test/unit_test.hpp>

    >>
    >>> int add( int i, int j ) { return i+j; }

    >>
    >>> BOOST_AUTO_TEST_CASE( my_test ){
    >>> BOOST_CHECK( add( 2,2 ) == 4 );
    >>> }

    >>
    >>> compiled with the command, g++ test.cpp -lboost_unit_test_framework

    >>
    >>> Error: undefined reference to `main'

    >>
    >> Well, that linking error by itself is clear. The stuff you're trying to
    >> run doesn't contain any "main()" function.
    >>
    >> Besides of that, I'm not familiar with the Boost unit test framework
    >> (and neither it is exactly topical here) so I cannot help further.
    >>
    >> What puzzles me is the fact of even thinking to "fight" with such
    >> advanced stuff (Boost, unit testing and so forth) while being at the
    >> beginning. It sounds just like trying to complicate one's own life.
    >>
    >> If you don't have any particular reason for running that code, drop it
    >> and concentrate on the standard language features and on solving
    >> compilation and linking problems in _your_ programs. That would give you
    >> a decent basis that will help you solving more complicated issues, like
    >> solving a linking error while trying to run a test file in Boost.
    >>


    <please snip signatures>

    >
    > If I want to do unit test, what else I can do, other than to use
    > Boost? Boost::users list had been non functional and thats why I post
    > my questions here....


    Well, nobody forces you to use Boost to do unit testing. Once you
    understand what unit testing is about, you can do it pretty much on your
    own or use some other smaller and simpler library (I have nothing
    against Boost, I'm just pointing out alternatives).

    If you really want to do unit testing with Boost, start by reading its
    documentation. After doing that, if you don't succeed, come back here
    and post all the exact steps you have done in order to achieve your aim,
    along with the complete code that you fed to the compiler, and
    eventually along with questions about the parts of the documentation
    that might be unclear.

    This group (or at least one person of this group) will then happily help
    you to straighten out all the issues, I promise it.

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Sep 2, 2010
    #4
  5. suresh

    suresh Guest

    On Sep 2, 3:04 pm, "Francesco S. Carta" <> wrote:
    > suresh <>, on 02/09/2010 14:49:59, wrote:
    >
    >
    >
    >
    >
    > > On Sep 2, 2:47 pm, "Francesco S. Carta"<>  wrote:
    > >> suresh<>, on 02/09/2010 14:32:18, wrote:

    >
    > >>> Hi,
    > >>> the following code does not compile and being a newbie, i am unable to
    > >>> figure it out. could you please help?

    >
    > >>> #define BOOST_TEST_MAIN
    > >>> #include<boost/test/unit_test.hpp>

    >
    > >>> int add( int i, int j ) { return i+j; }

    >
    > >>> BOOST_AUTO_TEST_CASE( my_test ){
    > >>>       BOOST_CHECK( add( 2,2 ) == 4 );
    > >>> }

    >
    > >>> compiled with the command, g++ test.cpp -lboost_unit_test_framework

    >
    > >>> Error: undefined reference to `main'

    >
    > >> Well, that linking error by itself is clear. The stuff you're trying to
    > >> run doesn't contain any "main()" function.

    >
    > >> Besides of that, I'm not familiar with the Boost unit test framework
    > >> (and neither it is exactly topical here) so I cannot help further.

    >
    > >> What puzzles me is the fact of even thinking to "fight" with such
    > >> advanced stuff (Boost, unit testing and so forth) while being at the
    > >> beginning. It sounds just like trying to complicate one's own life.

    >
    > >> If you don't have any particular reason for running that code, drop it
    > >> and concentrate on the standard language features and on solving
    > >> compilation and linking problems in _your_ programs. That would give you
    > >> a decent basis that will help you solving more complicated issues, like
    > >> solving a linking error while trying to run a test file in Boost.

    >
    > <please snip signatures>
    >
    >
    >
    > > If I want to do unit test, what else I can do, other than to use
    > > Boost? Boost::users list had been non functional and thats why I post
    > > my questions here....

    >
    > Well, nobody forces you to use Boost to do unit testing. Once you
    > understand what unit testing is about, you can do it pretty much on your
    > own or use some other smaller and simpler library (I have nothing
    > against Boost, I'm just pointing out alternatives).
    >
    > If you really want to do unit testing with Boost, start by reading its
    > documentation. After doing that, if you don't succeed, come back here
    > and post all the exact steps you have done in order to achieve your aim,
    > along with the complete code that you fed to the compiler, and
    > eventually along with questions about the parts of the documentation
    > that might be unclear.
    >
    > This group (or at least one person of this group) will then happily help
    > you to straighten out all the issues, I promise it.
    >
    > --
    >   FSC -http://userscripts.org/scripts/show/59948
    >  http://fscode.altervista.org-http://sardinias.com


    thanks for replying.
    In fact I spent time in reading the boost test docs but I could not
    make out...I read some blogs and the sample code is actually taken
    from a blog. I figured out that if I add
    #define BOOST_TEST_DYN_LINK
    and
    #define BOOST_TEST_MODULE MyTest
    it works with -lboost_unit_test_framework linking option.

    I wanted to know why the earlier code didnt work, as I was not clear
    about the concepts there.

    Now, I have not heard about other simpler test libraries..can you
    mention them?

    thanks again
    suresh
     
    suresh, Sep 2, 2010
    #5
  6. suresh <>, on 02/09/2010 15:15:13, wrote:

    > On Sep 2, 3:04 pm, "Francesco S. Carta"<> wrote:
    >> suresh<>, on 02/09/2010 14:49:59, wrote:
    >>
    >>
    >>
    >>
    >>
    >>> On Sep 2, 2:47 pm, "Francesco S. Carta"<> wrote:
    >>>> suresh<>, on 02/09/2010 14:32:18, wrote:

    >>
    >>>>> Hi,
    >>>>> the following code does not compile and being a newbie, i am unable to
    >>>>> figure it out. could you please help?

    >>
    >>>>> #define BOOST_TEST_MAIN
    >>>>> #include<boost/test/unit_test.hpp>

    >>
    >>>>> int add( int i, int j ) { return i+j; }

    >>
    >>>>> BOOST_AUTO_TEST_CASE( my_test ){
    >>>>> BOOST_CHECK( add( 2,2 ) == 4 );
    >>>>> }

    >>
    >>>>> compiled with the command, g++ test.cpp -lboost_unit_test_framework

    >>
    >>>>> Error: undefined reference to `main'

    >>
    >>>> Well, that linking error by itself is clear. The stuff you're trying to
    >>>> run doesn't contain any "main()" function.

    >>
    >>>> Besides of that, I'm not familiar with the Boost unit test framework
    >>>> (and neither it is exactly topical here) so I cannot help further.

    >>
    >>>> What puzzles me is the fact of even thinking to "fight" with such
    >>>> advanced stuff (Boost, unit testing and so forth) while being at the
    >>>> beginning. It sounds just like trying to complicate one's own life.

    >>
    >>>> If you don't have any particular reason for running that code, drop it
    >>>> and concentrate on the standard language features and on solving
    >>>> compilation and linking problems in _your_ programs. That would give you
    >>>> a decent basis that will help you solving more complicated issues, like
    >>>> solving a linking error while trying to run a test file in Boost.

    >>
    >> <please snip signatures>
    >>
    >>
    >>
    >>> If I want to do unit test, what else I can do, other than to use
    >>> Boost? Boost::users list had been non functional and thats why I post
    >>> my questions here....

    >>
    >> Well, nobody forces you to use Boost to do unit testing. Once you
    >> understand what unit testing is about, you can do it pretty much on your
    >> own or use some other smaller and simpler library (I have nothing
    >> against Boost, I'm just pointing out alternatives).
    >>
    >> If you really want to do unit testing with Boost, start by reading its
    >> documentation. After doing that, if you don't succeed, come back here
    >> and post all the exact steps you have done in order to achieve your aim,
    >> along with the complete code that you fed to the compiler, and
    >> eventually along with questions about the parts of the documentation
    >> that might be unclear.
    >>
    >> This group (or at least one person of this group) will then happily help
    >> you to straighten out all the issues, I promise it.
    >>
    >> --
    >> FSC -http://userscripts.org/scripts/show/59948
    >> http://fscode.altervista.org-http://sardinias.com

    >
    > thanks for replying.


    You're welcome, but please snip signatures out from quotes.

    > In fact I spent time in reading the boost test docs but I could not
    > make out...I read some blogs and the sample code is actually taken
    > from a blog. I figured out that if I add


    This is something that you didn't mention before, and which is important
    to spell out clearly when looking for help. It might seem rude, but
    people are more happy to help proactive people that "do their homework"
    than people who point-blank ask for help, I hope you understand.

    > #define BOOST_TEST_DYN_LINK
    > and
    > #define BOOST_TEST_MODULE MyTest
    > it works with -lboost_unit_test_framework linking option.


    It seems strange to me that you have to use those defines. This
    documentation makes no mention of them, at least after reading first pages:

    http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/utf/index.html

    > I wanted to know why the earlier code didnt work, as I was not clear
    > about the concepts there.


    As I said before, I'm not familiar with it, but I'll have a look and
    I'll eventually post my comprehension here (assuming nobody else with
    better knowledge will post any good hint here).

    > Now, I have not heard about other simpler test libraries..can you
    > mention them?


    Sure, here is one which seems pretty straightforward and small:

    http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html

    There might be others hanging around on the net, search for "c++ unit test"

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Sep 2, 2010
    #6
  7. suresh

    suresh Guest

    On Sep 2, 3:30 pm, "Francesco S. Carta" <> wrote:
    > suresh <>, on 02/09/2010 15:15:13, wrote:
    >
    >
    > > On Sep 2, 3:04 pm, "Francesco S. Carta"<>  wrote:
    > >> suresh<>, on 02/09/2010 14:49:59, wrote:

    >
    > >>> On Sep 2, 2:47 pm, "Francesco S. Carta"<>    wrote:
    > >>>> suresh<>, on 02/09/2010 14:32:18, wrote:

    >
    > >>>>> Hi,
    > >>>>> the following code does not compile and being a newbie, i am unable to
    > >>>>> figure it out. could you please help?

    >
    > >>>>> #define BOOST_TEST_MAIN
    > >>>>> #include<boost/test/unit_test.hpp>

    >
    > >>>>> int add( int i, int j ) { return i+j; }

    >
    > >>>>> BOOST_AUTO_TEST_CASE( my_test ){
    > >>>>>        BOOST_CHECK( add( 2,2 ) == 4 );
    > >>>>> }

    >
    > >>>>> compiled with the command, g++ test.cpp -lboost_unit_test_framework

    >
    > >>>>> Error: undefined reference to `main'

    >
    > >>>> Well, that linking error by itself is clear. The stuff you're trying to
    > >>>> run doesn't contain any "main()" function.

    >
    > >>>> Besides of that, I'm not familiar with the Boost unit test framework
    > >>>> (and neither it is exactly topical here) so I cannot help further.

    >
    > >>>> What puzzles me is the fact of even thinking to "fight" with such
    > >>>> advanced stuff (Boost, unit testing and so forth) while being at the
    > >>>> beginning. It sounds just like trying to complicate one's own life.

    >
    > >>>> If you don't have any particular reason for running that code, drop it
    > >>>> and concentrate on the standard language features and on solving
    > >>>> compilation and linking problems in _your_ programs. That would give you
    > >>>> a decent basis that will help you solving more complicated issues, like
    > >>>> solving a linking error while trying to run a test file in Boost.

    >
    >> >>> If I want to do unit test, what else I can do, other than to use
    > >>> Boost? Boost::users list had been non functional and thats why I post
    > >>> my questions here....

    >
    > >> Well, nobody forces you to use Boost to do unit testing. Once you
    > >> understand what unit testing is about, you can do it pretty much on your
    > >> own or use some other smaller and simpler library (I have nothing
    > >> against Boost, I'm just pointing out alternatives).

    >
    > >> If you really want to do unit testing with Boost, start by reading its
    > >> documentation. After doing that, if you don't succeed, come back here
    > >> and post all the exact steps you have done in order to achieve your aim,
    > >> along with the complete code that you fed to the compiler, and
    > >> eventually along with questions about the parts of the documentation
    > >> that might be unclear.

    >
    > >> This group (or at least one person of this group) will then happily help
    > >> you to straighten out all the issues, I promise it.

    >


    > > thanks for replying.

    >
    > You're welcome, but please snip signatures out from quotes.
    >
    > > In fact I spent time in reading the boost test docs but I could not
    > > make out...I read some blogs and the sample code is actually taken
    > > from a blog. I figured out that if I add

    >
    > This is something that you didn't mention before, and which is important
    > to spell out clearly when looking for help. It might seem rude, but
    > people are more happy to help proactive people that "do their homework"
    > than people who point-blank ask for help, I hope you understand.
    >
    > > #define BOOST_TEST_DYN_LINK
    > > and
    > > #define BOOST_TEST_MODULE MyTest
    > > it works with -lboost_unit_test_framework linking option.

    >
    > It seems strange to me that you have to use those defines. This
    > documentation makes no mention of them, at least after reading first pages:
    >
    > http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/utf/ind...
    >
    > > I wanted to know why the earlier code didnt work, as I was not clear
    > > about the concepts there.

    >
    > As I said before, I'm not familiar with it, but I'll have a look and
    > I'll eventually post my comprehension here (assuming nobody else with
    > better knowledge will post any good hint here).
    >
    > > Now, I have not heard about other simpler test libraries..can you
    > > mention them?

    >
    > Sure, here is one which seems pretty straightforward and small:
    >
    > http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html
    >
    > There might be others hanging around on the net, search for "c++ unit test"
    >

    dear friend,
    thanks for helping...
    with my intellect, I could not figure out, how to use Boost::Test
    properly yet.
    I somehow prefer Boost thinking that they are widely used and I may
    not get into
    any problems later.

    The code given here in this page,
    http://www.boost.org/doc/libs/1_35_0/libs/test/example/unit_test_example_01..cpp
    does not compile. Produces the same error: undefined reference to
    `main'

    suresh
     
    suresh, Sep 2, 2010
    #7
  8. suresh <>, on 02/09/2010 15:44:58, wrote:

    <really large snip, let's start over>

    > I somehow prefer Boost thinking that they are widely used and I may
    > not get into
    > any problems later.


    That's fine and good, and since sooner or later I'll have to "fight"
    with Boost unit testing too, let's walk the same way. But by now...

    > The code given here in this page,
    > http://www.boost.org/doc/libs/1_35_0/libs/test/example/unit_test_example_01.cpp
    > does not compile. Produces the same error: undefined reference to
    > `main'


    ....I need to build the libraries in order to test the code, it will take
    a long time... I'll be back on this tomorrow :)

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Sep 3, 2010
    #8
  9. suresh

    suresh Guest

    On Sep 2, 4:32 pm, "Francesco S. Carta" <> wrote:
    > suresh <>, on 02/09/2010 15:44:58, wrote:
    >
    > <really large snip, let's start over>
    >
    > > I somehow prefer Boost thinking that they are widely used and I may
    > > not get into
    > > any problems later.

    >
    > That's fine and good, and since sooner or later I'll have to "fight"
    > with Boost unit testing too, let's walk the same way. But by now...
    >
    > > The code given here in this page,
    > >http://www.boost.org/doc/libs/1_35_0/libs/test/example/unit_test_exam...
    > > does not compile. Produces the same error: undefined reference to
    > > `main'

    >
    > ...I need to build the libraries in order to test the code, it will take
    > a long time... I'll be back on this tomorrow :)


    thanks...I just installed the relevant package in my ubuntu
    machine....
    suresh
     
    suresh, Sep 3, 2010
    #9
  10. suresh <>, on 02/09/2010 16:38:57, wrote:

    > On Sep 2, 4:32 pm, "Francesco S. Carta"<> wrote:
    >> suresh<>, on 02/09/2010 15:44:58, wrote:
    >>
    >> <really large snip, let's start over>
    >>
    >>> I somehow prefer Boost thinking that they are widely used and I may
    >>> not get into
    >>> any problems later.

    >>
    >> That's fine and good, and since sooner or later I'll have to "fight"
    >> with Boost unit testing too, let's walk the same way. But by now...
    >>
    >>> The code given here in this page,
    >>> http://www.boost.org/doc/libs/1_35_0/libs/test/example/unit_test_exam...
    >>> does not compile. Produces the same error: undefined reference to
    >>> `main'

    >>
    >> ...I need to build the libraries in order to test the code, it will take
    >> a long time... I'll be back on this tomorrow :)

    >
    > thanks...I just installed the relevant package in my ubuntu
    > machine....


    Eh, I suppose that was an easy task for you... I've had to figure out
    how to build it with mingw taking care that bjam does not take the MSVS
    compiler up... and I still don't know whether the build will succeed or
    not... tomorrow we will both know about it :)

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Sep 3, 2010
    #10
  11. Francesco S. Carta <>, on 03/09/2010 01:46:20, wrote:

    > suresh <>, on 02/09/2010 16:38:57, wrote:
    >
    >> On Sep 2, 4:32 pm, "Francesco S. Carta"<> wrote:
    >>> suresh<>, on 02/09/2010 15:44:58, wrote:
    >>>
    >>> <really large snip, let's start over>
    >>>
    >>>> I somehow prefer Boost thinking that they are widely used and I may
    >>>> not get into
    >>>> any problems later.
    >>>
    >>> That's fine and good, and since sooner or later I'll have to "fight"
    >>> with Boost unit testing too, let's walk the same way. But by now...
    >>>
    >>>> The code given here in this page,
    >>>> http://www.boost.org/doc/libs/1_35_0/libs/test/example/unit_test_exam...
    >>>>
    >>>> does not compile. Produces the same error: undefined reference to
    >>>> `main'
    >>>
    >>> ...I need to build the libraries in order to test the code, it will take
    >>> a long time... I'll be back on this tomorrow :)

    >>
    >> thanks...I just installed the relevant package in my ubuntu
    >> machine....

    >
    > Eh, I suppose that was an easy task for you... I've had to figure out
    > how to build it with mingw taking care that bjam does not take the MSVS
    > compiler up... and I still don't know whether the build will succeed or
    > not... tomorrow we will both know about it :)
    >


    All right, it took shorter than I hoped.

    I've pasted the code (*) in a C++ file and I've added the Boost include
    directory to my include path, I've passed the
    libboost_unit_test_framework static library to the linker and both the
    compilation and the run went fine... you must have missed to link the
    program properly against the appropriate library, that's the only
    explanation.

    (*) Both the code you linked from the boost examples and the code you
    posted in the OP worked fine as expected.

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Sep 3, 2010
    #11
  12. suresh

    Jeff Flinn Guest

    > If I want to do unit test, what else I can do, other than to use
    > Boost? Boost::users list had been non functional and thats why I post
    > my questions here....


    I've not had problems reading/posting to any of the boost mailing lists
    yesterday or today.

    The following works for me on MSVC and XCode, sorry I don't often use
    the command line.

    #define BOOST_TEST_MAIN
    #define BOOST_TEST_MODULE MyModule

    #include <boost/test/unit_test.hpp>

    int add( int i, int j ) { return i+j; }

    BOOST_AUTO_TEST_CASE( my_test )
    {
    BOOST_CHECK( add( 2,2 ) == 4 );
    }



    Jeff
     
    Jeff Flinn, Sep 3, 2010
    #12
  13. On 3 sep, 00:30, "Francesco S. Carta" <> wrote:
    > suresh <>, on 02/09/2010 15:15:13, wrote:

    [snip]
    > > Now, I have not heard about other simpler test libraries..can you
    > > mention them?

    >
    > Sure, here is one which seems pretty straightforward and small:
    >
    > http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html
    >
    > There might be others hanging around on the net, search for "c++ unit test"


    IMO CppUnit is very heavy to work with (it shows its age). There are
    far lighter unit test framework. From mind, I would mention CUTE and
    Aeryn. I have also heard about Google Test, but I have no experience
    with it.

    I liked working with Boost.Test but this talk gave me other
    perspectives:
    Rethinking Unit Testing in C++
    By Kevlin Henney
    http://skillsmatter.com/podcast/agile-testing/kevlin-henney-rethinking-unit-testing-in-c-plus-plus

    --
    Michael
     
    Michael Doubez, Sep 3, 2010
    #13
  14. Michael Doubez <>, on 03/09/2010 05:31:24, wrote:

    > On 3 sep, 00:30, "Francesco S. Carta"<> wrote:
    >> suresh<>, on 02/09/2010 15:15:13, wrote:

    > [snip]
    >>> Now, I have not heard about other simpler test libraries..can you
    >>> mention them?

    >>
    >> Sure, here is one which seems pretty straightforward and small:
    >>
    >> http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html
    >>
    >> There might be others hanging around on the net, search for "c++ unit test"

    >
    > IMO CppUnit is very heavy to work with (it shows its age). There are
    > far lighter unit test framework. From mind, I would mention CUTE and
    > Aeryn. I have also heard about Google Test, but I have no experience
    > with it.
    >
    > I liked working with Boost.Test but this talk gave me other
    > perspectives:
    > Rethinking Unit Testing in C++
    > By Kevlin Henney
    > http://skillsmatter.com/podcast/agile-testing/kevlin-henney-rethinking-unit-testing-in-c-plus-plus


    Thank you for pointing out other alternatives, honestly my evaluation of
    CppUnit followed just from a superficial skimming of the documentation -
    hence my "seems" :)

    --
    FSC - http://userscripts.org/scripts/show/59948
    http://fscode.altervista.org - http://sardinias.com
     
    Francesco S. Carta, Sep 3, 2010
    #14
  15. suresh

    James Kanze Guest

    On Sep 2, 11:30 pm, "Francesco S. Carta" <> wrote:
    > suresh <>, on 02/09/2010 15:15:13, wrote:


    [...]
    > > #define BOOST_TEST_DYN_LINK
    > > and
    > > #define BOOST_TEST_MODULE MyTest
    > > it works with -lboost_unit_test_framework linking option.


    > It seems strange to me that you have to use those defines.


    Just a guess, but it wouldn't surprise me that it is the
    -lboost_unit_test_framework which results in main being defined.
    (I'm not familiar with boost::test either, but in the unit test
    frameworks that I've seen, "main" is provided by the framework,
    and not by the client code. And without the
    -lboost_unit_test_framework, at least under Unix, you don't get
    all of the framework.)

    [...]
    > > Now, I have not heard about other simpler test libraries..can you
    > > mention them?


    > Sure, here is one which seems pretty straightforward and small:


    > http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html


    > There might be others hanging around on the net, search for "c++ unit test"


    Google has one, which from what I've heard, is very similar to
    cppunit.

    --
    James Kanze
     
    James Kanze, Sep 6, 2010
    #15
  16. suresh

    suresh Guest

    On Sep 2, 7:03 pm, "Francesco S. Carta" <> wrote:
    > Francesco S. Carta <>, on 03/09/2010 01:46:20, wrote:
    > > suresh <>, on 02/09/2010 16:38:57, wrote:

    >
    > >> On Sep 2, 4:32 pm, "Francesco S. Carta"<> wrote:
    > >>> suresh<>, on 02/09/2010 15:44:58, wrote:

    ...............

    > >>>> The code given here in this page,
    > >>>>http://www.boost.org/doc/libs/1_35_0/libs/test/example/unit_test_exam....

    >
    > >>>> does not compile. Produces the same error: undefined reference to
    > >>>> `main'

    >
    > >>> ...I need to build the libraries in order totestthe code, it will take
    > >>> a long time... I'll be back on this tomorrow :)

    >
    > >> thanks...I just installed the relevant package in my ubuntu
    > >> machine....

    >
    > > Eh, I suppose that was an easy task for you... I've had to figure out
    > > how to build it with mingw taking care that bjam does not take the MSVS
    > > compiler up... and I still don't know whether the build will succeed or
    > > not... tomorrow we will both know about it :)

    >
    > All right, it took shorter than I hoped.
    >
    > I've pasted the code (*) in a C++ file and I've added theBoostinclude
    > directory to my include path, I've passed the
    > libboost_unit_test_framework static library to the linker and both the
    > compilation and the run went fine... you must have missed to link the
    > program properly against the appropriate library, that's the only
    > explanation.
    >
    > (*) Both the code you linked from theboostexamples and the code you
    > posted in the OP worked fine as expected.


    Thanks a lot. I had to pass -static option to g++ for it to work. This
    is what I missed.
    thanks again
    suresh
     
    suresh, Sep 8, 2010
    #16
  17. suresh

    suresh Guest

    On Sep 3, 5:08 am, Jeff Flinn <> wrote:
    > > If I want to do unittest, what else I can do, other than to use
    > >Boost?Boost::users list had been non functional and thats why I post
    > > my questions here....

    >
    > I've not had problems reading/posting to any of theboostmailing lists
    > yesterday or today.
    >
    >

    ............

    > Jeff


    Jeff, I tried to subscribe to boost-users list today also by filling
    out this page:
    http://lists.boost.org/mailman/listinfo.cgi/boost-users
    but I have not received any mail from the system.
    I had tried joining this list almost an year back also but in vain.
    Hence I post to this group.

    do you have any suggestions?
    thanks
    suresh
     
    suresh, Sep 8, 2010
    #17
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. blueblueblue2005
    Replies:
    3
    Views:
    591
    Bob Hairgrove
    Jun 25, 2005
  2. owolablo

    undefined reference to `main'

    owolablo, Oct 6, 2006, in forum: C++
    Replies:
    8
    Views:
    523
    Steve Pope
    Oct 6, 2006
  3. fdm
    Replies:
    1
    Views:
    2,371
    Maxim Yegorushkin
    Oct 4, 2009
  4. kathy
    Replies:
    0
    Views:
    1,329
    kathy
    Aug 2, 2011
  5. Raj Pashwar

    Undefined Reference to Main

    Raj Pashwar, Jun 12, 2012, in forum: C Programming
    Replies:
    2
    Views:
    549
    Ben Bacarisse
    Jun 12, 2012
Loading...

Share This Page