Hi folks,

 

I got an irritating problem and maybe one of you have the knowledge to help me out.

Compile and link is the challenge

 

I’m working on Solaris (Oracle) and I verify it is one of the newest so no problem should expect using Boost.

I downloaded boost_1_44_0.tar.bz2.

And follow the instructions from http://www.boost.org/doc/libs/1_44_0/more/getting_started/unix-variants.html

 

I checked with the simple program from section 4 and it works fine.

 

Great, now happy and cheerful I build a simple test as describe on the unit test module.

I tried to build it using a make file and failed.

So I tried as in the previous example

   

c++ -I ~/boost_1_44_0 TestBoost.cpp -o g1TestBoost.o

 

It gave lots of errors. I got the feeling as if 2 different stl libs are involved.

 

What did I done wrong? What should I do to make it right? Is there anybody out there?

The challenge is to compile it with a make file. Do you know how?

 

Thanks.

Gilam

 

The test is copy from the manual.

 

 

 TestBoost.cpp

 

#define BOOST_TEST_MODULE AAH_TEST

#define BOOST_TEST_DYN_LINK 1

 

#include <boost/test/included/unit_test.hpp>

 

class my_class {

                int a;

                public:

                my_class(const int _a) {a = _a;}

                bool is_valid();

};

 

bool my_class::is_valid()

{

                return a > 5;

}

 

BOOST_AUTO_TEST_CASE( my_test )

{

    my_class test_object(7);

 

    BOOST_CHECK( test_object.is_valid() );

}

 

/*

//the original example include this but it will not compile because the macro already define a main.

main( int argc, char* argv[] )

{

    return ::boost::unit_test::unit_test_main( &init_unit_test, argc, argv );

}

*/

 

The output of

c++ -I ~/boost_1_44_0 TestBoost.cpp -o g1TestBoost.o

 

In file included from /emc/rothg/boost_1_44_0/boost/test/included/unit_test.hpp:30,

                 from TestBoost.cpp:101:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:131: error: redefinition of `void boost::unit_test::unit_test_log_t::test_start(boost::unit_test::counter_t)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:96: error: `virtual void boost::unit_test::unit_test_log_t::test_start(boost::unit_test::counter_t)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:147: error: redefinition of `void boost::unit_test::unit_test_log_t::test_finish()'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:97: error: `virtual void boost::unit_test::unit_test_log_t::test_finish()' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:160: error: redefinition of `void boost::unit_test::unit_test_log_t::test_aborted()'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:98: error: `virtual void boost::unit_test::unit_test_log_t::test_aborted()' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:168: error: redefinition of `void boost::unit_test::unit_test_log_t::test_unit_start(const boost::unit_test::test_unit&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:100: error: `virtual void boost::unit_test::unit_test_log_t::test_unit_start(const boost::unit_test::test_unit&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `virtual void boost::unit_test::unit_test_log_t::test_unit_start(const boost::unit_test::test_unit&)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:175: error: `tu' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:175: error: (Each undeclared identifier is reported only once for each function it appears in.)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:182: error: redefinition of `void boost::unit_test::unit_test_log_t::test_unit_finish(const boost::unit_test::test_unit&, long unsigned int)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:101: error: `virtual void boost::unit_test::unit_test_log_t::test_unit_finish(const boost::unit_test::test_unit&, long unsigned int)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `virtual void boost::unit_test::unit_test_log_t::test_unit_finish(const boost::unit_test::test_unit&, long unsigned int)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:191: error: `tu' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:198: error: redefinition of `void boost::unit_test::unit_test_log_t::test_unit_skipped(const boost::unit_test::test_unit&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:102: error: `virtual void boost::unit_test::unit_test_log_t::test_unit_skipped(const boost::unit_test::test_unit&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `virtual void boost::unit_test::unit_test_log_t::test_unit_skipped(const boost::unit_test::test_unit&)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:205: error: `tu' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:212: error: redefinition of `void boost::unit_test::unit_test_log_t::test_unit_aborted(const boost::unit_test::test_unit&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:103: error: `virtual void boost::unit_test::unit_test_log_t::test_unit_aborted(const boost::unit_test::test_unit&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:220: error: redefinition of `void boost::unit_test::unit_test_log_t::assertion_result(bool)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:105: error: `virtual void boost::unit_test::unit_test_log_t::assertion_result(bool)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:228: error: redefinition of `void boost::unit_test::unit_test_log_t::exception_caught(const boost::execution_exception&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:106: error: `virtual void boost::unit_test::unit_test_log_t::exception_caught(const boost::execution_exception&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `virtual void boost::unit_test::unit_test_log_t::exception_caught(const boost::execution_exception&)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:230: error: `ex' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:246: error: redefinition of `void boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::const_string, size_t, boost::unit_test::const_string)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:117: error: `void boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::const_string, size_t, boost::unit_test::const_string)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:381: error: redefinition of `void boost::unit_test::unit_test_log_t::set_stream(std::ostream&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:111: error: `void boost::unit_test::unit_test_log_t::set_stream(std::ostream&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `void boost::unit_test::unit_test_log_t::set_stream(std::ostream&)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:385: error: `str' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:393: error: redefinition of `void boost::unit_test::unit_test_log_t::set_threshold_level(boost::unit_test::log_level)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:112: error: `void boost::unit_test::unit_test_log_t::set_threshold_level(boost::unit_test::log_level)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `void boost::unit_test::unit_test_log_t::set_threshold_level(boost::unit_test::log_level)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:394: error: `lev' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:404: error: redefinition of `void boost::unit_test::unit_test_log_t::set_format(boost::unit_test::output_format)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:113: error: `void boost::unit_test::unit_test_log_t::set_format(boost::unit_test::output_format)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `void boost::unit_test::unit_test_log_t::set_format(boost::unit_test::output_format)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:408: error: `log_format' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:418: error: redefinition of `void boost::unit_test::unit_test_log_t::set_formatter(boost::unit_test::unit_test_log_formatter*)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:114: error: `void boost::unit_test::unit_test_log_t::set_formatter(boost::unit_test::unit_test_log_formatter*)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `void boost::unit_test::unit_test_log_t::set_formatter(boost::unit_test::unit_test_log_formatter*)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:419: error: `the_formatter' undeclared (first use this function)

 

Make File

# Target name (executable or library)

TARGET=TestBoost

 

# OBJS - A list of the objects linked to be the target

OBJS=TestBoost.o

 

# Compiling the target

$(TARGET): $(OBJS)

                $(CCC) $(LDLIBS) $(LDFLAGS) $(LIB) $(OBJS)

                /bin/rm -f $(SSHOME)/bin/$(TARGET)

                ln -fs `pwd`/$(TARGET) $(SSHOME)/bin/$(TARGET)

 

clean:

                rm -rf $(OBJS) $(TARGET)

                rm -f $(SSHOME)/bin/$(TARGET)

 

# CCFLAGS - General compilation flags

CCFLAGS += -g  -library=stlport4

 

# CPPFLAGS - Flags for the compilation stage.

#CPPFLAGS += -DDEBUG

CPPFLAGS += -I $(HOME)/boost_1_44_0/

 

# LDFLAGS - Flags for the link stage. Add -G if target is a library (.so)

LDFLAGS +=   -o $(TARGET) -lboost_unit_test_framework  -library=stlport4

 

BOOST_LIBS = boost_iostreams boost_system boost_thread boost_program_options boost_date_time boost_unit_test_framework

 

 

 

The Output of the make

In file included from /emc/rothg/boost_1_44_0/boost/test/included/unit_test.hpp:30,

                 from TestBoost.cpp:101:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:131: error: redefinition of `void boost::unit_test::unit_test_log_t::test_start(boost::unit_test::counter_t)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:96: error: `virtual void boost::unit_test::unit_test_log_t::test_start(boost::unit_test::counter_t)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:147: error: redefinition of `void boost::unit_test::unit_test_log_t::test_finish()'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:97: error: `virtual void boost::unit_test::unit_test_log_t::test_finish()' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:160: error: redefinition of `void boost::unit_test::unit_test_log_t::test_aborted()'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:98: error: `virtual void boost::unit_test::unit_test_log_t::test_aborted()' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:168: error: redefinition of `void boost::unit_test::unit_test_log_t::test_unit_start(const boost::unit_test::test_unit&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:100: error: `virtual void boost::unit_test::unit_test_log_t::test_unit_start(const boost::unit_test::test_unit&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `virtual void boost::unit_test::unit_test_log_t::test_unit_start(const boost::unit_test::test_unit&)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:175: error: `tu' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:175: error: (Each undeclared identifier is reported only once for each function it appears in.)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:182: error: redefinition of `void boost::unit_test::unit_test_log_t::test_unit_finish(const boost::unit_test::test_unit&, long unsigned int)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:101: error: `virtual void boost::unit_test::unit_test_log_t::test_unit_finish(const boost::unit_test::test_unit&, long unsigned int)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `virtual void boost::unit_test::unit_test_log_t::test_unit_finish(const boost::unit_test::test_unit&, long unsigned int)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:191: error: `tu' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:198: error: redefinition of `void boost::unit_test::unit_test_log_t::test_unit_skipped(const boost::unit_test::test_unit&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:102: error: `virtual void boost::unit_test::unit_test_log_t::test_unit_skipped(const boost::unit_test::test_unit&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `virtual void boost::unit_test::unit_test_log_t::test_unit_skipped(const boost::unit_test::test_unit&)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:205: error: `tu' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:212: error: redefinition of `void boost::unit_test::unit_test_log_t::test_unit_aborted(const boost::unit_test::test_unit&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:103: error: `virtual void boost::unit_test::unit_test_log_t::test_unit_aborted(const boost::unit_test::test_unit&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:220: error: redefinition of `void boost::unit_test::unit_test_log_t::assertion_result(bool)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:105: error: `virtual void boost::unit_test::unit_test_log_t::assertion_result(bool)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:228: error: redefinition of `void boost::unit_test::unit_test_log_t::exception_caught(const boost::execution_exception&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:106: error: `virtual void boost::unit_test::unit_test_log_t::exception_caught(const boost::execution_exception&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `virtual void boost::unit_test::unit_test_log_t::exception_caught(const boost::execution_exception&)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:230: error: `ex' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:246: error: redefinition of `void boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::const_string, size_t, boost::unit_test::const_string)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:117: error: `void boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::const_string, size_t, boost::unit_test::const_string)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:381: error: redefinition of `void boost::unit_test::unit_test_log_t::set_stream(std::ostream&)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:111: error: `void boost::unit_test::unit_test_log_t::set_stream(std::ostream&)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `void boost::unit_test::unit_test_log_t::set_stream(std::ostream&)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:385: error: `str' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:393: error: redefinition of `void boost::unit_test::unit_test_log_t::set_threshold_level(boost::unit_test::log_level)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:112: error: `void boost::unit_test::unit_test_log_t::set_threshold_level(boost::unit_test::log_level)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `void boost::unit_test::unit_test_log_t::set_threshold_level(boost::unit_test::log_level)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:394: error: `lev' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:404: error: redefinition of `void boost::unit_test::unit_test_log_t::set_format(boost::unit_test::output_format)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:113: error: `void boost::unit_test::unit_test_log_t::set_format(boost::unit_test::output_format)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `void boost::unit_test::unit_test_log_t::set_format(boost::unit_test::output_format)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:408: error: `log_format' undeclared (first use this function)

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: At global scope:

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:418: error: redefinition of `void boost::unit_test::unit_test_log_t::set_formatter(boost::unit_test::unit_test_log_formatter*)'

/emc/rothg/boost_1_44_0/boost/test/unit_test_log.hpp:114: error: `void boost::unit_test::unit_test_log_t::set_formatter(boost::unit_test::unit_test_log_formatter*)' previously defined here

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp: In member function `void boost::unit_test::unit_test_log_t::set_formatter(boost::unit_test::unit_test_log_formatter*)':

/emc/rothg/boost_1_44_0/boost/test/impl/unit_test_log.ipp:419: error: `the_formatter' undeclared (first use this function)

make: *** [TestBoost.o] Error 1