Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mingling173 opened this issue Jan 17, 2022 · 0 comments

Comments

@mingling173
Copy link

  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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant