Missing include memory statement #248

Open
johanneskbl wants to merge 1 commits from johanneskbl/master into master
johanneskbl commented 2025-09-01 13:28:15 +02:00 (Migrated from github.com)

For my installation of the SDK I couldn't build the library with make and received the following error. After including the memory library in the header file of thread_base.h it was resolved.

Livox-SDK/build$ make
[  2%] Building CXX object sdk_core/CMakeFiles/livox_sdk_static.dir/src/third_party/FastCRC/FastCRCsw.cpp.o
[  4%] Building CXX object sdk_core/CMakeFiles/livox_sdk_static.dir/src/base/io_loop.cpp.o
[  6%] Building CXX object sdk_core/CMakeFiles/livox_sdk_static.dir/src/base/thread_base.cpp.o
In file included from /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:25:
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.h:46:8: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
   46 |   std::shared_ptr<std::thread> thread_;
      |        ^~~~~~~~~~
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.h:30:1: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
   29 | #include "noncopyable.h"
  +++ |+#include <memory>
   30 | 
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp: In member function ‘virtual bool livox::ThreadBase::Start()’:
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:34:3: error: ‘thread_’ was not declared in this scope; did you mean ‘pthread_t’?
   34 |   thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this);
      |   ^~~~~~~
      |   pthread_t
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:34:18: error: ‘make_shared’ is not a member of ‘std’
   34 |   thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this);
      |                  ^~~~~~~~~~~
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:26:1: note: ‘std::make_shared’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
   25 | #include "thread_base.h"
  +++ |+#include <memory>
   26 | #include <thread>
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:34:41: error: expected primary-expression before ‘>’ token
   34 |   thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this);
      |                                         ^
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:34:68: error: left operand of comma operator has no effect [-Werror=unused-value]
   34 |   thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this);
      |                                                                    ^~~~
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp: In member function ‘virtual void livox::ThreadBase::Join()’:
/home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:41:5: error: ‘thread_’ was not declared in this scope; did you mean ‘pthread_t’?
   41 |     thread_->join();
      |     ^~~~~~~
      |     pthread_t
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-c++11-long-long’ may have been intended to silence earlier diagnostics
cc1plus: all warnings being treated as errors
make[2]: *** [sdk_core/CMakeFiles/livox_sdk_static.dir/build.make:104: sdk_core/CMakeFiles/livox_sdk_static.dir/src/base/thread_base.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:242: sdk_core/CMakeFiles/livox_sdk_static.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
For my installation of the SDK I couldn't build the library with `make` and received the following error. After including the `memory` library in the header file of `thread_base.h` it was resolved. ``` Livox-SDK/build$ make [ 2%] Building CXX object sdk_core/CMakeFiles/livox_sdk_static.dir/src/third_party/FastCRC/FastCRCsw.cpp.o [ 4%] Building CXX object sdk_core/CMakeFiles/livox_sdk_static.dir/src/base/io_loop.cpp.o [ 6%] Building CXX object sdk_core/CMakeFiles/livox_sdk_static.dir/src/base/thread_base.cpp.o In file included from /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:25: /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.h:46:8: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type 46 | std::shared_ptr<std::thread> thread_; | ^~~~~~~~~~ /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.h:30:1: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’? 29 | #include "noncopyable.h" +++ |+#include <memory> 30 | /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp: In member function ‘virtual bool livox::ThreadBase::Start()’: /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:34:3: error: ‘thread_’ was not declared in this scope; did you mean ‘pthread_t’? 34 | thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this); | ^~~~~~~ | pthread_t /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:34:18: error: ‘make_shared’ is not a member of ‘std’ 34 | thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this); | ^~~~~~~~~~~ /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:26:1: note: ‘std::make_shared’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’? 25 | #include "thread_base.h" +++ |+#include <memory> 26 | #include <thread> /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:34:41: error: expected primary-expression before ‘>’ token 34 | thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this); | ^ /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:34:68: error: left operand of comma operator has no effect [-Werror=unused-value] 34 | thread_ = std::make_shared<std::thread>(&ThreadBase::ThreadFunc, this); | ^~~~ /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp: In member function ‘virtual void livox::ThreadBase::Join()’: /home/johannes/ros/temp_packages/Livox-SDK/sdk_core/src/base/thread_base.cpp:41:5: error: ‘thread_’ was not declared in this scope; did you mean ‘pthread_t’? 41 | thread_->join(); | ^~~~~~~ | pthread_t At global scope: cc1plus: note: unrecognized command-line option ‘-Wno-c++11-long-long’ may have been intended to silence earlier diagnostics cc1plus: all warnings being treated as errors make[2]: *** [sdk_core/CMakeFiles/livox_sdk_static.dir/build.make:104: sdk_core/CMakeFiles/livox_sdk_static.dir/src/base/thread_base.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:242: sdk_core/CMakeFiles/livox_sdk_static.dir/all] Error 2 make: *** [Makefile:136: all] Error 2 ```
This repo is archived. You cannot comment on pull requests.