I try to use the symbolicc++ toolbox with catkin. With a bigger project I have the structure:
//main2.cpp
#include "someheader.h"
int main(){
Symbol a;
Symbolicclass b(a);
b.func();
}
//someheader.h
#ifndef SOMEHEADER_H
#define SOMEHEADER_H
#include "symbolicclass.h"
#endif
//symbolicclass.h
#ifndef SYMBOLICCLASSHEADER_H
#define SYMBOLICCLASSHEADER_H
#include "symbolicc++.h"
using namespace std;
class Symbolicclass{
Symbolic value;
public:
void func();
Symbolicclass(Symbolic _value){value=_value;};
};
#endif
//symbolicclass.cpp
#include "symbolicclass.h"
void Symbolicclass::func(){ printf("whatever"); };
The whole catkin package can be found here: https://www.dropbox.com/s/4khoagm3uhsbs31/symbolic.zip?dl=0 Its 34Mb, as it includes the symbolicc++ library.
Than I get multiple definition errors of the SymbolicC++ library? e.g.
/home/Projects/SymbolicPlatform/Catkin/src/symbolic/thirdparty/SymbolicC++3-3.35/headers/symbolic/functions.h:1105: multiple definition of `Kronecker::Kronecker(Kronecker const&)'
CMakeFiles/symbolic_node.dir/src/main.cpp.o:/home/Projects/SymbolicPlatform/Catkin/src/symbolic/thirdparty/SymbolicC++3-3.35/headers/symbolic/functions.h:1105: first defined here
CMakeFiles/symbolic_node.dir/src/symbolic_agent.cpp.o: In function `Kronecker::Kronecker(Symbolic const&, Symbolic const&)':
/home/Projects/SymbolicPlatform/Catkin/src/symbolic/thirdparty/SymbolicC++3-3.35/headers/symbolic/functions.h:1107: multiple definition of `Kronecker::Kronecker(Symbolic const&, Symbolic const&)'
CMakeFiles/symbolic_node.dir/src/main.cpp.o:/home/Projects/SymbolicPlatform/Catkin/src/symbolic/thirdparty/SymbolicC++3-3.35/headers/symbolic/functions.h:1107: first defined here
etc. The only difference in CMakeLists is:
add_executable(symbolic_node src/main1.cpp) //WORKING FOR SIMPLE EXAMPLE
add_executable(symbolic_node src/main2.cpp src/symbolicclass.cpp)//CRAZY ERRORS
Do you have any idea what could be the problem?! For me it doesn't make sense that I get the multiple definition errors but I just use the #include "symbolicc++.h" once?! I think the error might be in the CMakeLists, there I build the symbolicc++ library and add it to the project. Thanks a lot for your help!
Ok, I think I will elaborate more about symbolicc++ use with catkin in ROS, so let's get to it step-by-step:
1 - download the only headers library (not the prebuilt, it looks like some bugs are in there) fro here and extract it somewhere.
2 - in CMakeLists.txt add the following line :
and add the headers folder to the includes :
-3 - if you need the library, just add it to the includes in your headers/sources as:
and that should be all to be done !
Now, considering your problem, just change the add_executable to this :
It will work just fine.