wilselby / ROS_quadrotor_simulator

Quadrotor simulator using ROS, Gazebo, and RVIZ
278 stars 123 forks source link

The solution to "undefined reference to LogMessageFatal and ~LogMessageFatal" #50

Open mingling173 opened 2 years ago

mingling173 commented 2 years ago
  1. Error
CMakeFiles/position_controller_node.dir/src/nodes/position_controller_node.cpp.o: 
In function `double*& google::CheckNotNull<double*&>(char const*, int, char const*, double*&)':
position_controller_node.cpp:(.text._ZN6google12CheckNotNullIRPdEET_PKciS5_OS3_[_ZN6google12CheckNotNullIRPdEET_PKciS5_OS3_]+0x86): 
undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
position_controller_node.cpp:(.text._ZN6google12CheckNotNullIRPdEET_PKciS5_OS3_[_ZN6google12CheckNotNullIRPdEET_PKciS5_OS3_]+0x92): 
undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
collect2: error: ld returned 1 exit status
quadrotor/ROS_quadrotor_simulator/quad_control/CMakeFiles/position_controller_node.dir/build.make:112: 
recipe for target 
  1. Solution

    Comment "CHECK_NOTNULL" in those files:(You can also use VSCode to find "CHECK_NOTNULL" in the folder)

ROS_quadrotor_simulator/quad_control/include/quad_control/common.h ROS_quadrotor_simulator/quad_control/include/quad_control/parameters_ros.h rotors_simulator/rotors_control/include/rotors_control/common.h rotors_simulator/rotors_control/include/rotors_control/parameters_ros.h

  1. Reason

You can find such code in "/usr/local/include/glog/logging.h" if you set up the glog by yourself.Those functions are called by "CHECK_NOTNULL" in logging.h.


class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
 public:
  LogMessageFatal(const char* file, int line);
  LogMessageFatal(const char* file, int line, const CheckOpString& result);
  __attribute__((noreturn)) ~LogMessageFatal();
};

template <typename T>
T* CheckNotNull(const char *file, int line, const char *names, T* t) {
  if (t == NULL) {
    LogMessageFatal(file, line, new std::string(names));
  }
  return t;
}

#define CHECK_NOTNULL(val) \
  google::CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val))