我尝试将 symbolicc++ 工具箱与 catkin 一起使用。对于一个更大的项目,我有以下结构:
//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"); };
整个 catkin 包可以在这里找到: https ://www.dropbox.com/s/4khoagm3uhsbs31/symbolic.zip?dl= 0 它的大小为 34Mb,因为它包含了 symbolicc++ 库。
比我得到 SymbolicC++ 库的多个定义错误吗?例如
/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
等 CMakeLists 的唯一区别是:
add_executable(symbolic_node src/main1.cpp) //WORKING FOR SIMPLE EXAMPLE
add_executable(symbolic_node src/main2.cpp src/symbolicclass.cpp)//CRAZY ERRORS
你知道可能是什么问题吗?!对我来说,我得到多个定义错误没有意义,但我只使用 #include "symbolicc++.h" 一次?!我认为错误可能在 CMakeLists 中,我在那里构建了 symbolicc++ 库并将其添加到项目中。非常感谢你的帮助!