TestRunnerClient.h undef ref to malloc

Help
2009-01-29
2013-04-22
  • Hi, the following code can be built in suse 10,2 x64 bits version using eclipse 3.4 and ECUT M2 cppUnit 1.12, but in opensuse 11.1 with gcc 4.3 make produce:
    <code>
    make all
    Building file: ../MovieList.cpp
    Invoking: GCC C++ Compiler
    g++ -DCPPUNIT_MAIN=main -I/usr/include/cppunit/ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"MovieList.d" -MT"MovieList.d" -o"MovieList.o" "../MovieList.cpp"
    Finished building: ../MovieList.cpp

    Building file: ../MovieListTest.cpp
    Invoking: GCC C++ Compiler
    g++ -DCPPUNIT_MAIN=main -I/usr/include/cppunit/ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"MovieListTest.d" -MT"MovieListTest.d" -o"MovieListTest.o" "../MovieListTest.cpp"
    Finished building: ../MovieListTest.cpp

    Building file: ../TestRunnerClient.cpp
    Invoking: GCC C++ Compiler
    g++ -DCPPUNIT_MAIN=main -I/usr/include/cppunit/ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"TestRunnerClient.d" -MT"TestRunnerClient.d" -o"TestRunnerClient.o" "../TestRunnerClient.cpp"
    In file included from ../TestRunnerClient.cpp:9:
    ../TestRunnerClient.h:123: error: ‘std::string’ has not been declared
    ../TestRunnerClient.h:129: error: ‘std::string’ has not been declared
    ../TestRunnerClient.h:130: error: ‘std::string’ has not been declared
    ../TestRunnerClient.h:131: error: ‘std::string’ has not been declared
    ../TestRunnerClient.h:132: error: ‘std::string’ has not been declared
    ../TestRunnerClient.h:132: error: ‘std::string’ has not been declared
    ../TestRunnerClient.h:132: error: ‘std::string’ has not been declared
    ../TestRunnerClient.h:134: error: ‘string’ in namespace ‘std’ does not name a type
    ../TestRunnerClient.cpp: In constructor ‘TestRunnerClient::TestRunnerClient()’:
    ../TestRunnerClient.cpp:68: error: ‘malloc’ was not declared in this scope
    ../TestRunnerClient.cpp:69: error: ‘strcpy’ was not declared in this scope
    ../TestRunnerClient.cpp: In destructor ‘virtual TestRunnerClient::~TestRunnerClient()’:
    ../TestRunnerClient.cpp:75: error: ‘free’ was not declared in this scope
    ../TestRunnerClient.cpp: In member function ‘void TestRunnerClient::ParseCommandLine(int, char**)’:
    ../TestRunnerClient.cpp:126: error: ‘atoi’ was not declared in this scope
    ../TestRunnerClient.cpp: In member function ‘void TestRunnerClient::DefineHostName()’:
    ../TestRunnerClient.cpp:145: error: ‘strcpy’ was not declared in this scope
    ../TestRunnerClient.cpp: In member function ‘int TestRunnerClient::Connect()’:
    ../TestRunnerClient.cpp:189: error: ‘memset’ was not declared in this scope
    ../TestRunnerClient.cpp:193: error: ‘memcpy’ was not declared in this scope
    ../TestRunnerClient.cpp: In member function ‘void TestRunnerClient::SendTestTree(CppUnit::Test*)’:
    ../TestRunnerClient.cpp:349: error: no matching function for call to ‘TestRunnerClient::NotifyTestTreeEntry(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)’
    ../TestRunnerClient.h:129: note: candidates are: void TestRunnerClient::NotifyTestTreeEntry(int)
    ../TestRunnerClient.cpp:360: error: no matching function for call to ‘TestRunnerClient::NotifyTestTreeEntry(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)’
    ../TestRunnerClient.h:129: note: candidates are: void TestRunnerClient::NotifyTestTreeEntry(int)
    ../TestRunnerClient.cpp: At global scope:
    ../TestRunnerClient.cpp:364: error: prototype for ‘void TestRunnerClient::SendMessage(std::string)’ does not match any in class ‘TestRunnerClient’
    ../TestRunnerClient.h:123: error: candidate is: void TestRunnerClient::SendMessage(int)
    ../TestRunnerClient.cpp: In member function ‘void TestRunnerClient::NotifyTestRunStarted(int)’:
    ../TestRunnerClient.cpp:390: error: no matching function for call to ‘TestRunnerClient::SendMessage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)’
    ../TestRunnerClient.h:123: note: candidates are: void TestRunnerClient::SendMessage(int)
    ../TestRunnerClient.cpp: In member function ‘void TestRunnerClient::NotifyTestRunEnded(long int)’:
    ../TestRunnerClient.cpp:397: error: no matching function for call to ‘TestRunnerClient::SendMessage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)’
    ../TestRunnerClient.h:123: note: candidates are: void TestRunnerClient::SendMessage(int)
    ../TestRunnerClient.cpp: In member function ‘void TestRunnerClient::NotifyTestRunStopped(long int)’:
    ../TestRunnerClient.cpp:404: error: no matching function for call to ‘TestRunnerClient::SendMessage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)’
    ../TestRunnerClient.h:123: note: candidates are: void TestRunnerClient::SendMessage(int)
    ../TestRunnerClient.cpp: At global scope:
    ../TestRunnerClient.cpp:407: error: prototype for ‘void TestRunnerClient::NotifyTestTreeEntry(std::string)’ does not match any in class ‘TestRunnerClient’
    ../TestRunnerClient.h:129: error: candidate is: void TestRunnerClient::NotifyTestTreeEntry(int)
    ../TestRunnerClient.cpp:412: error: prototype for ‘void TestRunnerClient::NotifyTestStarted(std::string)’ does not match any in class ‘TestRunnerClient’
    ../TestRunnerClient.h:130: error: candidate is: void TestRunnerClient::NotifyTestStarted(int)
    ../TestRunnerClient.cpp:417: error: prototype for ‘void TestRunnerClient::NotifyTestEnded(std::string)’ does not match any in class ‘TestRunnerClient’
    ../TestRunnerClient.h:131: error: candidate is: void TestRunnerClient::NotifyTestEnded(int)
    ../TestRunnerClient.cpp:422: error: prototype for ‘void TestRunnerClient::NotifyTestFailed(std::string, std::string, std::string)’ does not match any in class ‘TestRunnerClient’
    ../TestRunnerClient.h:132: error: candidate is: void TestRunnerClient::NotifyTestFailed(int, int, int)
    ../TestRunnerClient.cpp: In member function ‘virtual void TestRunnerClient::startTest(CppUnit::Test*)’:
    ../TestRunnerClient.cpp:433: error: no matching function for call to ‘TestRunnerClient::NotifyTestStarted(std::string)’
    ../TestRunnerClient.h:130: note: candidates are: void TestRunnerClient::NotifyTestStarted(int)
    ../TestRunnerClient.cpp: In member function ‘virtual void TestRunnerClient::addFailure(const CppUnit::TestFailure&)’:
    ../TestRunnerClient.cpp:441: error: ‘GetTrace’ was not declared in this scope
    ../TestRunnerClient.cpp:445: error: ‘GetTrace’ was not declared in this scope
    ../TestRunnerClient.cpp: In member function ‘virtual void TestRunnerClient::endTest(CppUnit::Test*)’:
    ../TestRunnerClient.cpp:452: error: no matching function for call to ‘TestRunnerClient::NotifyTestEnded(std::string)’
    ../TestRunnerClient.h:131: note: candidates are: void TestRunnerClient::NotifyTestEnded(int)
    ../TestRunnerClient.cpp: At global scope:
    ../TestRunnerClient.cpp:455: error: no ‘std::string TestRunnerClient::GetTrace(const CppUnit::TestFailure&)’ member function declared in class ‘TestRunnerClient’
    ../TestRunnerClient.cpp: In function ‘int main(int, char**)’:
    ../TestRunnerClient.cpp:536: error: ‘exit’ was not declared in this scope
    make: *** [TestRunnerClient.o] Error 1
    </code>

    the code is:
    <code>
    /*
    * MovieList.cpp
    *
    *  Created on: 28-ene-2009
    *      Author: Elcid
    */

    #include "MovieList.h"

    MovieList::MovieList() {
        // TODO Auto-generated constructor stub

    }

    MovieList::~MovieList() {
        // TODO Auto-generated destructor stub
    }
    *****************************************************
    /*
    * MovieList.h
    *
    *  Created on: 28-ene-2009
    *      Author: Elcid
    */

    #ifndef MOVIELIST_H_
    #define MOVIELIST_H_

    class MovieList {
    public:
        MovieList();
        virtual ~MovieList();
    };

    #endif /* MOVIELIST_H_ */

    /**
    * Generated CppUnit test driver template.
    * To build it, add the following line at the end of
    * your existing Makefile:
    *    include MovieListTest.mk
    * Build the MovieListTest target from the Make Target view
    */

    #ifndef TEST_MovieListTest
    #define TEST_MovieListTest
    #include "cppunit/extensions/HelperMacros.h"

    class MovieListTest : public CppUnit::TestFixture {
    public:
        void setUp()
        {
        }
        void tearDown()
        {
        }
        void testMovieList()
        {
            CPPUNIT_ASSERT(false);
        }
        void testDMovieList()
        {
            CPPUNIT_ASSERT(false);
        }
        CPPUNIT_TEST_SUITE(MovieListTest);
        CPPUNIT_TEST(testMovieList);
        CPPUNIT_TEST(testDMovieList);
        CPPUNIT_TEST_SUITE_END();
    };
    CPPUNIT_TEST_SUITE_REGISTRATION(MovieListTest);
    #endif
    </code>

    It seems like the standard libraries couldn't be found by gcc, but this only occurs when I'm compiling test cases.

    Thank you