|
Boost Testing : |
From: David Hartman (dhartman_at_[hidden])
Date: 2008-07-24 14:01:01
How do I need to configure the build for the test library, using gcc 4.3.1, boost 1.35.0, on linux? I want to ustin init_unit_test_suite. Getting undefined reference to main error, linking the test program. No error linking with a boost 1.33.1 that was built using gcc 4.2.3.
Believe I may be not using a configuration file and have problem with defines of BOOST_TEST_MAIN or BOOST_TEST_MODULE, and then BOOST_TEST_DYN_LINK and BOOST_TEST_NO_MAIN are being defined.
Below is the error when compiling the test program, info about the test program, info about the boost test library build.
Test file linking error:
g++ -o../build/<target -I/usr/local/include/boost-1_35 > <app>.o -L/usr/local/lib -L../build /usr/local/lib/libboost_iostreams-gcc43-mt-1_35.so.1.35.0 /usr/local/lib/libboost_unit_test_framework-gcc43-1_35.so.1.35.0
/usr/lib/gcc/i486-linux-gnu/4.3.1/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
Part of the test file:
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
test_suite *init_unit_test_suite(int argc, char** const argv)
{
if (2 != argc)
{
cout << "USAGE: " << argv[0] << " <test-data-root>" << endl;
exit(1);
}
test_suite *test = BOOST_TEST_SUITE("ADF Searchable File Tests");
const unicodeString testRoot = UTF8_TO_UNI(argv[1]);
TestFileInfo::testAll(test, testRoot);
TestFileContent::testAll(test, testRoot);
TestFileReport::testAll(test);
return test;
}
Configuration files when building the boost test library:
Command to do build is "make install"
Makefile:
BJAM=/usr/local/bin/bjam
BJAM_CONFIG= -a --build-type=complete
PREFIX=/usr/local
EPREFIX=/usr/local
LIBDIR=/usr/local/lib
INCLUDEDIR=/usr/local/include
LIBS= --with-test
all: .dummy
@echo "$(BJAM) $(BJAM_CONFIG) --user-config=user-config.jam $(LIBS)"
@$(BJAM) $(BJAM_CONFIG) --user-config=user-config.jam $(LIBS) || \
echo "Not all Boost libraries built properly."
clean: .dummy
rm -rf bin.v2
distclean: clean
rm -rf Makefile config.log
check: .dummy
@cd status && ../$(BJAM) $(BJAM_CONFIG) --user-config=../user-config.jam || echo "Some Boost regression tests failed. This is normal for many compilers."
install: .dummy
@echo "$(BJAM) $(BJAM_CONFIG) --user-config=user-config.jam --prefix=$(PREFIX) --exec-prefix=$(EPREFIX) --libdir=$(LIBDIR) --includedir=$(INCLUDEDIR) $(LIBS) install"
@$(BJAM) $(BJAM_CONFIG) --user-config=user-config.jam --prefix=$(PREFIX) --exec-prefix=$(EPREFIX) --libdir=$(LIBDIR) --includedir=$(INCLUDEDIR) $(LIBS) install || echo "Not all Boost libraries built properly."
.dummy:
User_config.jam:
# Boost.Build Configuration
# Automatically generated by Boost configure
# Compiler configuration
using gcc ;