我有一个相当大的代码库。这就是https://github.com/mpkuse/nap/tree/master-desktop/src
它实际上是一个ros包,必须用catkin_make
编译
这是一个超过cmake的层。
我的代码库在我的ubuntu-desktop(gcc版本5.4.0)上编译得很好。 但是,当我将它移动到Nvidia-TX2时,我得到了很长的错误列表。它的片段如下。 Node类在Node.h中定义,并包含在其他类中。
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:73:68: error: template argument 2 is invalid
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:73:68: error: template argument 1 is invalid
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:73:68: error: template argument 2 is invalid
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:73:56: error: invalid use of template-name ‘std::vector’ without an argument list
LocalBundle( const nap::NapMsg::ConstPtr& msg, const vector<Node*>& global_nodes, const PinholeCamera& camera );
^
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:73:62: error: expected ‘,’ or ‘...’ before ‘<’ token
LocalBundle( const nap::NapMsg::ConstPtr& msg, const vector<Node*>& global_nodes, const PinholeCamera& camera );
^
In file included from /home/nvidia/catkin_ws/src/nap/src/DataManager.h:82:0,
from /home/nvidia/catkin_ws/src/nap/src/DataManager_rviz_visualization.cpp:1:
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:127:45: error: template argument 1 is invalid
int find_indexof_node( const vector<Node*>& global_nodes, ros::Time stamp );
^
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:127:45: error: template argument 2 is invalid
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:127:45: error: template argument 1 is invalid
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:127:45: error: template argument 2 is invalid
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:127:45: error: template argument 1 is invalid
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:127:45: error: template argument 2 is invalid
/home/nvidia/catkin_ws/src/nap/src/LocalBundle.h:127:45: error: template argument 1 is invalid
这里发生了什么?有什么建议吗?
我试图找出问题所在。这是我做的,我完全删除了类LocalBundle
和Corvus
。它们被用在DataManager_core.cpp / place_recog_callback()中。还删除了相应的cmake条目。现在代码可以编译了。
我尝试添加虚拟课程Suse
// Suse.h
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
class Suse
{
public:
Suse();
void sayHi();
};
// Suse.cpp
#include "Suse.h"
Suse::Suse()
{
}
void Suse::sayHi()
{
cout << "Hi from Suse\n";
}
然后尝试在完全相同的位置使用此类(即in place_recog_callback()),如:
Suse sy = Suse();
sy.sayHi();
还在cmake编译列表中添加了Suse.cpp,并在DataManager.h中包含了Suse.h。
用它编译成功。
但是,因为我在Suse.h中包含opencv,如:
// //opencv
#include <opencv2/core/core.hpp>
using namespace cv;
我收到一条长错误信息,前几行看起来与原始错误类似。
[ 81%] Building CXX object nap/CMakeFiles/pose_graph_opt_node.dir/src/DataManager_core.cpp.o
[ 83%] Building CXX object nap/CMakeFiles/pose_graph_opt_node.dir/src/DataManager_rviz_visualization.cpp.o
[ 85%] Building CXX object nap/CMakeFiles/pose_graph_opt_node.dir/src/pose_graph_opt_node.cpp.o
[ 87%] Building CXX object nap/CMakeFiles/pose_graph_opt_node.dir/src/DataManager_utils.cpp.o
[ 88%] Building CXX object nap/CMakeFiles/pose_graph_opt_node.dir/src/Suse.cpp.o
In file included from /home/nvidia/catkin_ws/src/nap/src/DataManager_core.cpp:1:0:
/home/nvidia/catkin_ws/src/nap/src/DataManager.h:171:21: error: template argument 1 is invalid
const vector<Node*>& getNodesRef() { return nNodes; }
^
/home/nvidia/catkin_ws/src/nap/src/DataManager.h:171:21: error: template argument 2 is invalid
/home/nvidia/catkin_ws/src/nap/src/DataManager.h:185:15: error: template argument 1 is invalid
vector<Node*> nNodes; //list of notes
^
/home/nvidia/catkin_ws/src/nap/src/DataManager.h:185:15: error: template argument 2 is invalid
In file included from /home/nvidia/catkin_ws/src/nap/src/DataManager_rviz_visualization.cpp:1:0:
/home/nvidia/catkin_ws/src/nap/src/DataManager.h:171:21: error: template argument 1 is invalid
const vector<Node*>& getNodesRef() { return nNodes; }
^
/home/nvidia/catkin_ws/src/nap/src/DataManager.h:171:21: error: template argument 2 is invalid
/home/nvidia/catkin_ws/src/nap/src/DataManager.h:185:15: error: template argument 1 is invalid
vector<Node*> nNodes; //list of notes
^
/home/nvidia/catkin_ws/src/nap/src/DataManager.h:185:15: error: template argument 2 is invalid