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

Compilation error due to missing pthread.h in LogModule on Linux #23

Open
yarduoc opened this issue Dec 16, 2024 · 1 comment
Open

Compilation error due to missing pthread.h in LogModule on Linux #23

yarduoc opened this issue Dec 16, 2024 · 1 comment

Comments

@yarduoc
Copy link

yarduoc commented Dec 16, 2024

When attempting to compile the module on Ubuntu 24.04, the compilation fails due to the absence of pthread.h in the log_module.cpp file. Specifically, the error messages point to the lack of declaration for pthread_mutex_init, pthread_mutex_lock, and pthread_mutex_unlock.

Here’s the error output encountered:

error: ‘pthread_mutex_init’ was not declared in this scope; did you mean ‘pthread_mutex_t’?
error: ‘pthread_mutex_unlock’ was not declared in this scope; did you mean ‘pthread_mutex_t’?
error: ‘pthread_mutex_lock’ was not declared in this scope; did you mean ‘pthread_mutex_t’?

Looking at the log_module.h, it appears that the inclusion of pthread.h has been commented out under the #else directive for Linux:

#ifndef LINUX
#include <windows.h>
#else
// #include <pthread.h>
#include <stdarg.h>
#define printf_s(fileptr,str)  (fprintf(fileptr,"%s",str))
#define __in
#endif // ??????????????????????

The code compiles perfectly when the commented-out line (#include <pthread.h>) is uncommented.

Questions:

  • Was the exclusion of pthread.h intentional for Linux, or is this an oversight?
  • Is there a specific reason for this exclusion that I should be aware of?
  • What would be the recommended approach for compiling the package without running into this error?

Environment:

  • Operating System: Ubuntu 24.04 (x86_64 architecture)
  • Kernel Version: 6.8.0-50-generic
  • ROS 2 Distribution: Jazzy
  • C++ Compiler: GCC 13.3.0
  • CMake Version: 3.28.3
  • Colcon Version: 0.18.4
@hippo5329
Copy link

hippo5329 commented Dec 16, 2024

I sent a pull-request to fix this issue

#24

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

2 participants