Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Error when make: syntax error while compiling "threadpool.cpp" #76

Open
chrisweird7 opened this issue Apr 27, 2022 · 6 comments
Open

Error when make: syntax error while compiling "threadpool.cpp" #76

chrisweird7 opened this issue Apr 27, 2022 · 6 comments

Comments

@chrisweird7
Copy link

chrisweird7 commented Apr 27, 2022

I followed the instruction to generate the Makefile and succeeded.

While the make process, some error occurred while compiling the "threadpool.cpp", I think it's a syntax error.

I know almost nothing about c++, but I'm very interested in glass3, so please help.

The detailed error information are as follows:

[ 17%] Performing build step for 'util'
Scanning dependencies of target util
[ 3%] Building CXX object CMakeFiles/util.dir/src/baseclass.cpp.o
[ 6%] Building CXX object CMakeFiles/util.dir/src/cache.cpp.o
[ 9%] Building CXX object CMakeFiles/util.dir/src/config.cpp.o
[ 12%] Building CXX object CMakeFiles/util.dir/src/date.cpp.o
[ 16%] Building CXX object CMakeFiles/util.dir/src/fileutil.cpp.o
[ 19%] Building CXX object CMakeFiles/util.dir/src/geo.cpp.o
[ 22%] Building CXX object CMakeFiles/util.dir/src/glassid.cpp.o
[ 25%] Building CXX object CMakeFiles/util.dir/src/glassmath.cpp.o
[ 29%] Building CXX object CMakeFiles/util.dir/src/logger.cpp.o
[ 32%] Building CXX object CMakeFiles/util.dir/src/queue.cpp.o
[ 35%] Building CXX object CMakeFiles/util.dir/src/stringutil.cpp.o
[ 38%] Building CXX object CMakeFiles/util.dir/src/taper.cpp.o
[ 41%] Building CXX object CMakeFiles/util.dir/src/threadbaseclass.cpp.o
[ 45%] Building CXX object CMakeFiles/util.dir/src/threadpool.cpp.o
In file included from /home/chris/github/neic-glass3-master/util/src/threadpool.cpp:1:
/home/chris/github/neic-glass3-master/util/include/threadpool.h:77:19: error: ‘std::function’ has not been declared
77 | void addJob(std::function<void()> newJob);
| ^~~~~~~~
/home/chris/github/neic-glass3-master/util/include/threadpool.h:77:27: error: expected ‘,’ or ‘...’ before ‘<’ token
77 | void addJob(std::function<void()> newJob);
| ^
/home/chris/github/neic-glass3-master/util/include/threadpool.h:106:18: error: ‘function’ is not a member of ‘std’
106 | std::queue<std::function<void()>> m_JobQueue;
| ^~~~~~~~
/home/chris/github/neic-glass3-master/util/include/threadpool.h:17:1: note: ‘std::function’ is defined in header ‘’; did you forget to ‘#include ’?
16 | #include
+++ |+#include
17 | #include
/home/chris/github/neic-glass3-master/util/include/threadpool.h:106:18: error: ‘function’ is not a member of ‘std’
106 | std::queue<std::function<void()>> m_JobQueue;
| ^~~~~~~~
/home/chris/github/neic-glass3-master/util/include/threadpool.h:106:18: note: ‘std::function’ is defined in header ‘’; did you forget to ‘#include ’?
/home/chris/github/neic-glass3-master/util/include/threadpool.h:106:32: error: template argument 1 is invalid
106 | std::queue<std::function<void()>> m_JobQueue;
| ^
/home/chris/github/neic-glass3-master/util/include/threadpool.h:106:32: error: template argument 2 is invalid
/home/chris/github/neic-glass3-master/util/include/threadpool.h:106:33: error: expected unqualified-id before ‘>’ token
106 | std::queue<std::function<void()>> m_JobQueue;
| ^~
/home/chris/github/neic-glass3-master/util/src/threadpool.cpp:25:6: error: no declaration matches ‘void glass3::util::ThreadPool::addJob(std::function<void()>)’
25 | void ThreadPool::addJob(std::function<void()> newjob) {
| ^~~~~~~~~~
In file included from /home/chris/github/neic-glass3-master/util/src/threadpool.cpp:1:
/home/chris/github/neic-glass3-master/util/include/threadpool.h:77:7: note: candidate is: ‘void glass3::util::ThreadPool::addJob(int)’
77 | void addJob(std::function<void()> newJob);
| ^~~~~~
/home/chris/github/neic-glass3-master/util/include/threadpool.h:31:7: note: ‘class glass3::util::ThreadPool’ defined here
31 | class ThreadPool : public util::ThreadBaseClass {
| ^~~~~~~~~~
/home/chris/github/neic-glass3-master/util/src/threadpool.cpp: In member function ‘virtual glass3::util::WorkState glass3::util::ThreadPool::work()’:
/home/chris/github/neic-glass3-master/util/src/threadpool.cpp:41:6: error: ‘m_JobQueue’ was not declared in this scope
41 | if (m_JobQueue.empty() == true) {
| ^~~~~~~~~~
/home/chris/github/neic-glass3-master/util/src/threadpool.cpp:50:33: error: ‘m_JobQueue’ was not declared in this scope
50 | std::function<void()> newjob = m_JobQueue.front();
| ^~~~~~~~~~
/home/chris/github/neic-glass3-master/util/src/threadpool.cpp: In member function ‘int glass3::util::ThreadPool::getJobQueueSize()’:
/home/chris/github/neic-glass3-master/util/src/threadpool.cpp:82:35: error: ‘m_JobQueue’ was not declared in this scope
82 | int queuesize = static_cast(m_JobQueue.size());
| ^~~~~~~~~~
make[5]: *** [CMakeFiles/util.dir/build.make:251: CMakeFiles/util.dir/src/threadpool.cpp.o] Error 1
make[4]: *** [CMakeFiles/Makefile2:124: CMakeFiles/util.dir/all] Error 2
make[3]: *** [Makefile:160: all] Error 2
make[2]: *** [CMakeFiles/util.dir/build.make:131: util-prefix/src/util-stamp/util-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:178: CMakeFiles/util.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

@jpatton-USGS
Copy link
Collaborator

What version of GCC are you using? Glass utilizes STL functions that require at least version 5.0.4 of the GNU C/C++ compilers or similar.

@chrisweird7
Copy link
Author

What version of GCC are you using? Glass utilizes STL functions that require at least version 5.0.4 of the GNU C/C++ compilers or similar.

The GCC version on my computer is 10.3.0 i.e. "gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0"

@chrisweird7
Copy link
Author

chrisweird7 commented Apr 29, 2022

In order to apply the glass3, I downloaded VMWare on my computer (Windows System) and build a virtual machine (Ubuntu 20.04). I installed gcc, g++ and so on by "apt install" instructions, so I think they are all up to date.

@jpatton-USGS
Copy link
Collaborator

In that case, I would install gcc 5.x, which is the current c++ compiler used by the NEIC

@chrisweird7
Copy link
Author

In that case, I would install gcc 5.x, which is the current c++ compiler used by the NEIC

Thank you very much for the suggestions. I changed the gcc into 5.x version at last. Actually, it's a tough work for me. After dozens of attemps, I find Fedora 23 is more suitable for the compile environment, and successfully installed gcc 5.x.

Yes, now the problem is solved. But then another error struck me. I searched the Internet for relevant solutions but still failed to work it out. The error is as follows, I eager for some more suggestions to deal with it. Thank you again!

error

@jpatton-USGS
Copy link
Collaborator

So, what you are encountering is an error in building the glass3 unit tests, which require the google test package to be installed. However, the unit tests are primarily useful when we are developing changes or fixes to the algorithm, and are not required for building the application or using it. You can disable the building of the unit tests by adding the option -DRUN_TESTS=0 to your cmake command.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants