|
Boost Users : |
Subject: Re: [Boost-users] [Test] failure linking tests dynamically
From: Latimerius (pvl_at_[hidden])
Date: 2014-11-08 10:54:07
Hello Richard,
Thanks for your reply! Please see my comments inline.
On Fri, Nov 07, 2014 at 04:14:41PM +0000, Richard wrote:
> [Please do not mail me a copy of your followup]
>
> Latimerius <pvl_at_[hidden]> spake the secret code
> <20141107175110.GA3432_at_[hidden]> thusly:
>
> >[...] However, all attempts so far failed due to
> >
> >Undefined symbols for architecture x86_64:
> > "_main", referenced from:
> > implicit entry/start for main executable
> >ld: symbol(s) not found for architecture x86_64
>
> When you compiled your test program, did you define BOOST_TEST_MAIN in
> one of your source files before including the boost.test headers?
I was speaking here about the examples supplied with the library. My
problem is that when I download Boost and compile it (using the
procedure described in my previous message), the examples (in
<boost_dir>/libs/test/example) don't build for me for some reason, and
the error message is the one concerning missing main().
As far as my own attempts go, those do build curiously enough, but the
resulting program crashes while exiting the main function, and its
output is garbled:
Running 2 test cases...
InputWindowTest.cpp:14: error in "=@???DP?:7|??DP???DP?:7|": check
*** 1 failure detected (1953719668 failures expected) in test suite
"Segmentation fault: 11
The program is as follows:
#include "InputWindow.h"
#define BOOST_TEST_MODULE EventActionMgr
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE (EventAction_test)
{
ui::EventAction a;
BOOST_CHECK (a.RunHandlers () == true);
}
built with
clang++ -g -Wall -std=c++11 -stdlib=libc++ -DBOOST_TEST_DYN_LINK -I.. -I
../../.. -I/usr/local/boost_1_57_0/include -L/usr/local/boost_1_57_0/lib
InputWindowTest.cpp -o InputWindowTest -lboost_unit_test_framework
I suspect memory corruption. The way the output is garbled varies with
the argument of BOOST_TEST_MODULE. Whether I do or do not #define
BOOST_TEST_MAIN doesn't seem to matter.
As for where the crash happens: a test run with zero detected failures
crashes after main(). A run with failures usually crashes while trying
to print a failure. I suspect something wrong might be happening at the
boundary between the main program and the shared library
(libboost_unit_test_framework.dylib).
> Someone needs to supply a definition of main and if you ask boost.test
> to do it by defining that symbol before including the headers, it will
> provide one for you.
>
> Try looking at my documentation here and see if this clears things up:
> <http://user.xmission.com/~legalize/boost.test/libs/test/doc/html/test/guide/compilation/shared_library.html>
Thanks for the link, that's good info! I somehow missed it before.
Thanks again,
pvl
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net