Quantcast

UTF: test/included/unit_test.hpp vs test/unit_test.hpp

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

UTF: test/included/unit_test.hpp vs test/unit_test.hpp

Boost - Users mailing list
Hi, 

  I am using the UTF in my code. Below is the key component of my code that I have been using on Mac for a few years with boost installed from macports. 

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE MAST_TESTS
#include <boost/test/unit_test.hpp>


// C++ includes
#include <memory>

struct GlobalTestFixture {

    

    GlobalTestFixture() {

        

/*    my code here */

    }

    

    ~GlobalTestFixture() {

        

    }

    

};


BOOST_GLOBAL_FIXTURE( GlobalTestFixture );


A few days ago I started using this code on Ubuntu and kept getting segmentation faults with random values being returned for boost::unit_test::framework::master_test_suite().argc

I managed to get rid of this problem by changing the included header to 
#include <boost/test/included/unit_test.hpp>

I have seen the description here: http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/utf/compilation/direct-include.html.  However, I am not quite able to follow why this problem occurred on Ubuntu (with system boost library) when I was still linking against the precompiled library (version 1.58). 

Is there a test I can include in my code to automatically switch from one include to the other? 

I will appreciate some guidance. 

Regards,
Manav



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UTF: test/included/unit_test.hpp vs test/unit_test.hpp

Boost - Users mailing list
On 4/05/2017 15:14, Manav Bhatia via Boost-users wrote:

> A few days ago I started using this code on Ubuntu and kept getting
> segmentation faults with random values being returned
> for boost::unit_test::framework::master_test_suite().argc
>
> I managed to get rid of this problem by changing the included header to
> #include <boost/test/included/unit_test.hpp>
>
> I have seen the description
> here: http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/utf/compilation/direct-include.html.
>  However, I am not quite able to follow why this problem occurred on
> Ubuntu (with system boost library) when I was still linking against the
> precompiled library (version 1.58).

Generally those sorts of problems occur when you use a different version
of the headers than the prebuilt libraries.  Check your include and lib
paths at build time to see whether it's finding a different version than
you're expecting (eg. finding a local Boost instead of system Boost, or
vice versa).

You can also run ldd on the executable to see which version of the Boost
shared libraries it's trying to load at runtime and whether this is the
one you expect or not.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: UTF: test/included/unit_test.hpp vs test/unit_test.hpp

Boost - Users mailing list
Le 08.05.17 à 04:25, Gavin Lambert via Boost-users a écrit :

> On 4/05/2017 15:14, Manav Bhatia via Boost-users wrote:
>> A few days ago I started using this code on Ubuntu and kept getting
>> segmentation faults with random values being returned
>> for boost::unit_test::framework::master_test_suite().argc
>>
>> I managed to get rid of this problem by changing the included header to
>> #include <boost/test/included/unit_test.hpp>
>>
>> I have seen the description
>> here:
>> http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/utf/compilation/direct-include.html.
>>
>>  However, I am not quite able to follow why this problem occurred on
>> Ubuntu (with system boost library) when I was still linking against the
>> precompiled library (version 1.58).
>
> Generally those sorts of problems occur when you use a different version
> of the headers than the prebuilt libraries.  Check your include and lib
> paths at build time to see whether it's finding a different version than
> you're expecting (eg. finding a local Boost instead of system Boost, or
> vice versa).
>
> You can also run ldd on the executable to see which version of the Boost
> shared libraries it's trying to load at runtime and whether this is the
> one you expect or not.

Hi,

I second that answer :)

The way you solved it is factually incorrect as you are including the
header only UTF files and you declare the dynamic linking variant. Have
a look at the command line generated for your compiler and your linker,
you might be linking to the static version while declaring the dynamic
version with the macro.

Best,
Raffi

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...