roohy / iLASH

iLASH - IBD Estimation Using Locality Sensitive Hashing
Other
16 stars 3 forks source link

Compilation error: ‘shared_ptr’ in namespace ‘std’ does not name a template type #7

Open Deleetdk opened 1 year ago

Deleetdk commented 1 year ago

Running Mint 21 (Ubuntu 22.04). cmake ran fine, make gives some c errors.

user@computer:/iLASH/build$ cmake ..
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0")  
-- Configuring done
-- Generating done
-- Build files have been written to: /iLASH/build

user@computer:/iLASH/build$ make
[ 11%] Building CXX object CMakeFiles/ilash.dir/src/main.cpp.o
[ 22%] Building CXX object CMakeFiles/ilash.dir/src/context.cpp.o
[ 33%] Building CXX object CMakeFiles/ilash.dir/src/filereader.cpp.o
[ 44%] Building CXX object CMakeFiles/ilash.dir/src/minhasher.cpp.o
[ 55%] Building CXX object CMakeFiles/ilash.dir/src/experiment.cpp.o
In file included from /iLASH/src/experiment.cpp:7:
/iLASH/src/headers/lsh_slave.h:26:10: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
   26 |     std::shared_ptr<std::queue<std::unique_ptr< std::string>>> linesQ;
      |          ^~~~~~~~~~
/iLASH/src/headers/lsh_slave.h:19:1: note: ‘std::shared_ptr’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
   18 | #include <fstream>
  +++ |+#include <memory>
   19 | #include <unordered_map>
/iLASH/src/headers/lsh_slave.h:27:10: error: ‘atomic’ in namespace ‘std’ does not name a template type
   27 |     std::atomic<bool> * runFlag; //This flag tells the program when to stop listening.
      |          ^~~~~~
/iLASH/src/headers/lsh_slave.h:19:1: note: ‘std::atomic’ is defined in header ‘<atomic>’; did you forget to ‘#include <atomic>’?
   18 | #include <fstream>
  +++ |+#include <atomic>
   19 | #include <unordered_map>
/iLASH/src/headers/lsh_slave.h:29:59: error: ‘std::shared_ptr’ has not been declared
   29 |     LSH_Slave(Corpus *corpus, std::mutex *linesLock, std::shared_ptr<std::queue<std::unique_ptr<std::string>>>, std::atomic<bool> *);
      |                                                           ^~~~~~~~~~
/iLASH/src/headers/lsh_slave.h:29:69: error: expected ‘,’ or ‘...’ before ‘<’ token
   29 | Slave(Corpus *corpus, std::mutex *linesLock, std::shared_ptr<std::queue<std::unique_ptr<std::string>>>, std::atomic<bool> *);
      |                                                             ^

/iLASH/src/experiment.cpp:22:57: error: ‘shared_ptr’ has not been declared
   22 | void lsh_thread(Corpus *corpus, std::mutex * linesLock, shared_ptr<queue<unique_ptr<std::string>>> linesQ, atomic<bool> *runFlag){
      |                                                         ^~~~~~~~~~
/iLASH/src/experiment.cpp:22:67: error: expected ‘,’ or ‘...’ before ‘<’ token
   22 | sh_thread(Corpus *corpus, std::mutex * linesLock, shared_ptr<queue<unique_ptr<std::string>>> linesQ, atomic<bool> *runFlag){
      |                                                             ^

/iLASH/src/experiment.cpp: In function ‘void lsh_thread(Corpus*, std::mutex*, int)’:
/iLASH/src/experiment.cpp:23:43: error: ‘linesQ’ was not declared in this scope
   23 |     LSH_Slave slave(corpus,linesLock,move(linesQ),runFlag);
      |                                           ^~~~~~
/iLASH/src/experiment.cpp:23:51: error: ‘runFlag’ was not declared in this scope
   23 |     LSH_Slave slave(corpus,linesLock,move(linesQ),runFlag);
      |                                                   ^~~~~~~
/iLASH/src/experiment.cpp: In member function ‘void Experiment::read_bulk(const char*, const char*)’:
/iLASH/src/experiment.cpp:45:19: error: ‘make_shared’ was not declared in this scope
   45 |     auto linesQ = make_shared<queue<unique_ptr<string>>>(); //Samples will be loaded in the this queue
      |                   ^~~~~~~~~~~
/iLASH/src/experiment.cpp:16:1: note: ‘std::make_shared’ is defined in header ‘<memory>’; did you forget to ‘#include <memory>’?
   15 | #include <atomic>
  +++ |+#include <memory>
   16 | 
/iLASH/src/experiment.cpp:45:56: error: expected primary-expression before ‘>’ token
   45 |     auto linesQ = make_shared<queue<unique_ptr<string>>>(); //Samples will be loaded in the this queue
      |                                                        ^
/iLASH/src/experiment.cpp:45:58: error: expected primary-expression before ‘)’ token
   45 |     auto linesQ = make_shared<queue<unique_ptr<string>>>(); //Samples will be loaded in the this queue
      |                                                          ^
make[2]: *** [CMakeFiles/ilash.dir/build.make:132: CMakeFiles/ilash.dir/src/experiment.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/ilash.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Instructions say cmake of >= 3.5, but there's no such thing as far as I can tell: https://cmake.org/download/. Newest stable is 3.25. Installed is 3.22:

user@computer:/iLASH/build$ cmake --version
cmake version 3.22.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
roohy commented 1 year ago

@pettyalex Do you have any comments on this issue? I have tried compiling it but it does not compile on our computing cluster due to the same errors (and cmake) version. I thought you might have a better idea on how to fix this. I know there is a cmake 3.5 available; however 3.3 is the latest version available on both computing clusters that I have access to. Is there a way to revert the minimum required version to 3.25 or 3.3?

pettyalex commented 1 year ago

Cmake 3.5 was released 6 years ago: https://cmake.org/files/v3.5/

cmake 3.22 and 3.25 are much, much newer than cmake 3.5, so that's not the problem.

To me, this looks like a missing #include in ilash, probably because of efforts to reduce internal dependencies within libstdc++ over the last few years. I've seen this in several applications, ilash probably uses some things without actually #include -ing the headers that define them.

I'll take a look, this should be easy to reproduce and fix on Ubuntu 22.04. To prevent and fix these kinds of problems, there's a tool called "include what you use" to make sure that you include what you use: https://include-what-you-use.org/

roohy commented 1 year ago

Thank you so much Alex!! I will also try to learn and use the "include what you use" tool tonight.

pettyalex commented 1 year ago

It's not particularly user friendly, kind of annoying to work with. It's very useful for these types of problems, though!

On Thu, Nov 10, 2022 at 10:45 AM Roohy (Ruhollah) Shemirani < @.***> wrote:

Thank you so much Alex!! I will also try to learn and use the "include what you use" tool tonight.

— Reply to this email directly, view it on GitHub https://github.com/roohy/iLASH/issues/7#issuecomment-1310583691, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYR5RORWBHOGI2LUFENPLTWHURDNANCNFSM6AAAAAAR4I4RHM . You are receiving this because you were mentioned.Message ID: @.***>

pettyalex commented 1 year ago

Well, there's a fix for this problem.

I'm attaching the whole output from include-what-you-use if you want to go fishing for the rest: iwyu-output.txt

If you'd like, I can run the tool's auto-fix mode and commit that

roohy commented 1 year ago

Great! Thank you, Alex! And yes, I would really appreciate it if you could please add them in your pull request and commit them.

pettyalex commented 1 year ago

I think it'd be wisest to fix this first ASAP for @Deleetdk , and then I'll look at integrating include-what-you-use into cmake the right way rather than just doing a one time fixup, if you're interested

pettyalex commented 1 year ago

Oh, and if you want to see all of the gory details behind why this broke, check it out here: https://github.com/statgen/savvy/issues/26#issuecomment-1231094453

roohy commented 1 year ago

I agree. I will add merge your current commit immediately then.
Thanks for the details! I will read it ASAP.