I am trying to set up CPPUnit to work with Dev C++ and am a novice when it comes to working with as many include files as CPPUnit has.
Question : what would your next step be to getting beyond this error ?
Getting an undefined reference erro `CppUnit::TestResult::TestResult(CppUnit::SynchronizedObject::SynchronizationObject*)'
Note that under Project , all of my options are disabled so I can't add include files from here. Actually I just opened files and did not create a project, could this be the trouble?
Compiler Log Below.
Any help appreciated!!!
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\MarcsFiles\Main.cpp" -o "C:\Dev-Cpp\MarcsFiles\Main.exe" -g3 -O0 -g3 -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -I"C:\cppunit\include" -I"C:\cppunit\include\cppunit\portability" -L"C:\Dev-Cpp\lib"
C:\DOCUME~1\Marc\LOCALS~1\Temp/cccBbaaa.o(.text+0x28): In function `main':
C:/Dev-Cpp/MarcsFiles/Main.cpp:16: undefined reference to `CppUnit::TestResult::TestResult(CppUnit::SynchronizedObject::SynchronizationObject*)'
C:\DOCUME~1\Marc\LOCALS~1\Temp/cccBbaaa.o(.text+0x37):C:/Dev-Cpp/MarcsFiles/Main.cpp:39: undefined reference to `CppUnit::TestResult::~TestResult()'
Execution terminated
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I know what the problem for this one is:
CppUnit::TestResult::~TestResult()
you probably have this source similar to this:
namespace CppUnit
{
class TestResult
{
~TestResult() //Destructor defined
};
};
Your problem is that you defined a destructor (~TestResult) as existing and everything compiles because the compiler knows to use that function. After all, you have a definition of it. The problem is that you never implemented it. So when the linker sees that function, it has no code to put there. Try this for yourself:
//Test.cpp
int func();
int main()
{
func();
return 0;
}
//End of Test.cpp
You will get undefined references to func() most likely.
To solve this problem in the example above and your source, add an implementation.
Take the example above. Add this line to it:
int func() { return 1; }
So now the linker knows what func() is.
In your case you need:
CppUnit::TestResult::~TestResult()
{
//Insert code for destructor implementation
}
Hope that helps
--Figgles
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to set up CPPUnit to work with Dev C++ and am a novice when it comes to working with as many include files as CPPUnit has.
Question : what would your next step be to getting beyond this error ?
Getting an undefined reference erro `CppUnit::TestResult::TestResult(CppUnit::SynchronizedObject::SynchronizationObject*)'
Note that under Project , all of my options are disabled so I can't add include files from here. Actually I just opened files and did not create a project, could this be the trouble?
Compiler Log Below.
Any help appreciated!!!
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\MarcsFiles\Main.cpp" -o "C:\Dev-Cpp\MarcsFiles\Main.exe" -g3 -O0 -g3 -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -I"C:\cppunit\include" -I"C:\cppunit\include\cppunit\portability" -L"C:\Dev-Cpp\lib"
C:\DOCUME~1\Marc\LOCALS~1\Temp/cccBbaaa.o(.text+0x28): In function `main':
C:/Dev-Cpp/MarcsFiles/Main.cpp:16: undefined reference to `CppUnit::TestResult::TestResult(CppUnit::SynchronizedObject::SynchronizationObject*)'
C:\DOCUME~1\Marc\LOCALS~1\Temp/cccBbaaa.o(.text+0x37):C:/Dev-Cpp/MarcsFiles/Main.cpp:39: undefined reference to `CppUnit::TestResult::~TestResult()'
Execution terminated
"... did not create a project, could this be the trouble?"
Yes (at least for starters)....
-- Jim.
I know what the problem for this one is:
CppUnit::TestResult::~TestResult()
you probably have this source similar to this:
namespace CppUnit
{
class TestResult
{
~TestResult() //Destructor defined
};
};
Your problem is that you defined a destructor (~TestResult) as existing and everything compiles because the compiler knows to use that function. After all, you have a definition of it. The problem is that you never implemented it. So when the linker sees that function, it has no code to put there. Try this for yourself:
//Test.cpp
int func();
int main()
{
func();
return 0;
}
//End of Test.cpp
You will get undefined references to func() most likely.
To solve this problem in the example above and your source, add an implementation.
Take the example above. Add this line to it:
int func() { return 1; }
So now the linker knows what func() is.
In your case you need:
CppUnit::TestResult::~TestResult()
{
//Insert code for destructor implementation
}
Hope that helps
--Figgles