-1

My Dockerfile uses FROM gcc:5, runs apt-get update and installs CMake v3.9 via wget. My top-level CMakeLists.txt has set(CMAKE_CXX_STANDARD 11) but that doesn't seem to convince gcc to compile using C++11 as I get the following error:

/ifeature.hpp:51:42: error: 'shared_ptr' in namespace 'std' does not name a template type
     virtual float compare(const std::shared_ptr<IFeature>& feature) const = 0
                                      ^

I tried adding variations of set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") with libstdc++, gnuc++11 etc. but the compiler does not recognize them. I also tried add_compile_options(-std=c++11) to no avail. I also tried apt-get upgrade gcc but that didn't help either.

What am I missing here?

Pejman
  • 1,328
  • 1
  • 18
  • 26
  • 1
    You do include the `` header file? – Some programmer dude Dec 15 '17 at 08:46
  • On an unrelated note, why do you pass the shared pointer *by reference*? The normal use-case is to pass it by value, or the whole "shared" thing won't really work. – Some programmer dude Dec 15 '17 at 08:48
  • Hi There. Thank you. This is embarrassing but that was it. I had not included , given that I use a different compiler on my own machine. – Pejman Dec 15 '17 at 10:32
  • @Someprogrammerdude I pass the shared pointer by *reference* when I want to avoid adding another reference count to the shared_ptr itself. Is that a bad practice? Also, I apologize that it took some time for me to reply. It is 4:30 AM here. – Pejman Dec 15 '17 at 10:36

1 Answers1

0

For future reference and in the interest of anyone who may encounter this page, I should update that just as @some-programmer-dude mentioned in the comment, simply including <memory> resolved the error shown in my question.

Given that my original development environment was different from the one in my Docker image and the code was written with different compiler, I had to resolve a few similar issues (missing include files) to satisfy gcc-v5 requirements.

Pejman
  • 1,328
  • 1
  • 18
  • 26