undefined reference to member function in AUTO_TEST_CASE

Dear all,
I have a peculiar problem when compiling my unit tests. The reason why I
find it peculiar is that I can compile the same code in a normal
function just fine. Here is what I have in a main function:
// std
#include <iostream>
// project
#include "headers/common_definitions.hpp"
#include "classes/C_ParameterManager.hpp"
int main(int argc, char** argv) {
using std::cout;
using std::endl;
gsl_error_handler_t* const old_handler = gsl_set_error_handler_off();
rfn::ParameterManager* my_test = NULL;
my_test->instance(rfn::flow_evolved);
cout << my_test->instance() << endl;
return (EXIT_SUCCESS);
The ParameterManager::instance function is declared as follows:
static ParameterManager* instance(const FunctionalNetworkScheme scheme);
and in the main function it correctly returns a pointer.
For testing purposes I use the following code:
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE rfn test suite
// project
#include "../headers/common_definitions.hpp"
#include "../classes/C_ParameterManager.hpp"
// boost
#include

AMDG Moritz Beber wrote:
I have a peculiar problem when compiling my unit tests. The reason why I find it peculiar is that I can compile the same code in a normal function just fine. Here is what I have in a main function:
<snip> When I try to compile it I get the following errors:
/tmp/ccOI5FiJ.o: In function `ParameterManagerTest::test_default_constructor::test_method()': test_rfn.cpp:(.text+0xcf): undefined reference to `rfn::ParameterManager::instance(rfn::FunctionalNetworkScheme)' test_rfn.cpp:(.text+0x136): undefined reference to `rfn::ParameterManager::instance()'
I see no reason why the reference should be undefined as I include the class header and specify the path to the .cpp file. Does the unit test framework have a problem with static member functions?
What command line did you use to build? In Christ, Steven Watanabe

On 17/06/10 16:49, Steven Watanabe wrote:
AMDG
Moritz Beber wrote:
I have a peculiar problem when compiling my unit tests. The reason why I find it peculiar is that I can compile the same code in a normal function just fine. Here is what I have in a main function:
<snip> When I try to compile it I get the following errors:
/tmp/ccOI5FiJ.o: In function `ParameterManagerTest::test_default_constructor::test_method()': test_rfn.cpp:(.text+0xcf): undefined reference to `rfn::ParameterManager::instance(rfn::FunctionalNetworkScheme)' test_rfn.cpp:(.text+0x136): undefined reference to `rfn::ParameterManager::instance()'
I see no reason why the reference should be undefined as I include the class header and specify the path to the .cpp file. Does the unit test framework have a problem with static member functions?
What command line did you use to build?
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
g++ test_rfn.cpp -o test -I ../classes -I . -L /usr/local/lib -l boost_system -l boost_unit_test_framework -Wno-deprecated

AMDG Moritz Beber wrote:
On 17/06/10 16:49, Steven Watanabe wrote:
Moritz Beber wrote:
I have a peculiar problem when compiling my unit tests. The reason why I find it peculiar is that I can compile the same code in a normal function just fine. Here is what I have in a main function:
<snip> When I try to compile it I get the following errors:
/tmp/ccOI5FiJ.o: In function `ParameterManagerTest::test_default_constructor::test_method()': test_rfn.cpp:(.text+0xcf): undefined reference to `rfn::ParameterManager::instance(rfn::FunctionalNetworkScheme)' test_rfn.cpp:(.text+0x136): undefined reference to `rfn::ParameterManager::instance()'
I see no reason why the reference should be undefined as I include the class header and specify the path to the .cpp file. Does the unit test framework have a problem with static member functions?
What command line did you use to build? g++ test_rfn.cpp -o test -I ../classes -I . -L /usr/local/lib -l boost_system -l boost_unit_test_framework -Wno-deprecated
You need to link to whatever object file has the definition of instance. In Christ, Steven Watanabe

On 17/06/10 17:04, Steven Watanabe wrote:
AMDG
Moritz Beber wrote:
On 17/06/10 16:49, Steven Watanabe wrote:
Moritz Beber wrote:
I have a peculiar problem when compiling my unit tests. The reason why I find it peculiar is that I can compile the same code in a normal function just fine. Here is what I have in a main function:
<snip> When I try to compile it I get the following errors:
/tmp/ccOI5FiJ.o: In function `ParameterManagerTest::test_default_constructor::test_method()': test_rfn.cpp:(.text+0xcf): undefined reference to `rfn::ParameterManager::instance(rfn::FunctionalNetworkScheme)' test_rfn.cpp:(.text+0x136): undefined reference to `rfn::ParameterManager::instance()'
I see no reason why the reference should be undefined as I include the class header and specify the path to the .cpp file. Does the unit test framework have a problem with static member functions?
What command line did you use to build? g++ test_rfn.cpp -o test -I ../classes -I . -L /usr/local/lib -l boost_system -l boost_unit_test_framework -Wno-deprecated
You need to link to whatever object file has the definition of instance.
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Silly me, forgot to add the class file. Thank you. Best, Moritz
participants (2)
-
Moritz Beber
-
Steven Watanabe