Problem with using matrix library with unit test library

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with using matrix library with unit test library

Boost - Dev mailing list
Hi everyone,
I have been developing something, and basically it requires the two boost
libraries - the matrix library and unit test library.

I have a file test.cpp :

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/test/included/unit_test.hpp>

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE test

BOOST_AUTO_TEST_SUITE(Integer_matrices)

BOOST_AUTO_TEST_CASE(Constructors)
{
BOOST_CHECK(2 == 2);
}

BOOST_AUTO_TEST_SUITE_END()


I am compiling this with:
g++ -I <path to boost_1_63_0> test.cpp


I'm getting the following error:
/tmp/ccnxRzsf.o: In function `main':
test.cpp:(.text+0x18aa1): undefined reference to `init_unit_test_suite(int,
char**)'
collect2: error: ld returned 1 exit status

Any help will be greatly appreciated.
Thanks.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Problem with using matrix library with unit test library

Boost - Dev mailing list
Le 20/03/2017 à 17:50, SHIVAM MITTAL via Boost a écrit :

> Hi everyone,
> I have been developing something, and basically it requires the two boost
> libraries - the matrix library and unit test library.
>
> I have a file test.cpp :
>
> #include <boost/numeric/ublas/matrix.hpp>
> #include <boost/numeric/ublas/io.hpp>
> #include <boost/test/included/unit_test.hpp>
>
> #define BOOST_TEST_DYN_LINK
> #define BOOST_TEST_MODULE test
>
> BOOST_AUTO_TEST_SUITE(Integer_matrices)
>
> BOOST_AUTO_TEST_CASE(Constructors)
> {
> BOOST_CHECK(2 == 2);
> }
>
> BOOST_AUTO_TEST_SUITE_END()
>
>
> I am compiling this with:
> g++ -I <path to boost_1_63_0> test.cpp
>
>
> I'm getting the following error:
> /tmp/ccnxRzsf.o: In function `main':
> test.cpp:(.text+0x18aa1): undefined reference to `init_unit_test_suite(int,
> char**)'
> collect2: error: ld returned 1 exit status
>
> Any help will be greatly appreciated.
> Thanks.

Just remove the "#define BOOST_TEST_DYN_LINK": you are forcing the
dynamic link while at the same time you are using the "included" variant
(header only).

See
http://www.boost.org/doc/libs/1_63_0/libs/test/doc/html/boost_test/usage_variants.html 
for more details.

Raffi




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost