AnyarInc / Ascent

A fast and flexible C++ simulation engine and differential equation solver.
Apache License 2.0
123 stars 15 forks source link

Help getting lorenz example to run #1

Closed woodwards closed 6 years ago

woodwards commented 6 years ago

Sorry to bother you. I am trying to get the lorenz example working. I am using the CodeBlocks IDE with GNU GCC. I have downloaded Ascent and put it in C:\ascent. I am not using the makefile CMakeLists.txt, CodeBlocks should handle this automatically I think.

When I build I get the following errors:

||=== Build: Debug in lorenz_ascent (compiler: GNU GCC Compiler) ===|
C:\ascent\ascent\containers\stack.h|95|error: wrong number of template arguments (1, should be 2)|
C:\ascent\ascent\containers\stack.h|25|error: provided for 'template<class T, class stack_t> struct asc::stack_iterator'|
C:\ascent\ascent\containers\stack.h|107|error: 'const_iterator' does not name a type|
C:\ascent\ascent\containers\stack.h|112|error: 'const_iterator' does not name a type|
C:\Users\WoodwardS\Documents\Cpp\lorenz_ascent\main.cpp||In function 'int main()':|
C:\Users\WoodwardS\Documents\Cpp\lorenz_ascent\main.cpp|46|error: use of deleted function 'asc::RecorderT<T, block_size>::RecorderT() [with T = double; unsigned int block_size = 4096u]'|
C:\ascent\ascent\Recorder.h|44|note: 'asc::RecorderT<T, block_size>::RecorderT() noexcept [with T = double; unsigned int block_size = 4096u]' is implicitly deleted because its exception-specification does not match the implicit exception-specification 'noexcept (<uninstantiated>)'|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

(I am very new to C++ so please forgive my ignorance.)

stephenberry commented 6 years ago

No problem asking for help. It looks like this is coming from std::decay_t as a C++14 addition. My guess is that you're compiling with the C++11 standard. The solution may be as simple as changing the compiler flag to use a more recent version of C++.

Compiler flags look like: -std=c++14 or -std=c++17

woodwards commented 6 years ago

Thanks Stephen! I've included the -std=c++14 compiler flag as per

https://stackoverflow.com/questions/31171979/enabling-std-c14-flag-in-codeblocks

and it did make a difference. Now I get only one error:

||=== Build: Debug in lorenz_ascent (compiler: GNU GCC Compiler) ===|
C:\Users\WoodwardS\Documents\Cpp\lorenz_ascent\main.cpp||In function 'int main()':|
C:\Users\WoodwardS\Documents\Cpp\lorenz_ascent\main.cpp|46|error: use of deleted function 'asc::RecorderT<T, block_size>::RecorderT() [with T = double; unsigned int block_size = 4096u]'|
C:\ascent\ascent\Recorder.h|44|note: 'asc::RecorderT<T, block_size>::RecorderT() noexcept [with T = double; unsigned int block_size = 4096u]' is implicitly deleted because its exception-specification does not match the implicit exception-specification 'noexcept (<uninstantiated>)'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
stephenberry commented 6 years ago

Okay, I tested this in Compiler Explorer and found that I get the error you are seeing if I use a version of the GCC Compiler before 5.1

5.1 and beyond compiles, while 4.9.4 and below gives the error.

Are you able to use a more recent compiler?

I could remove the noexcept qualifier on the RecorderT constructor and this would fix the problem. But, I'd want to look into whether this error really makes sense.

woodwards commented 6 years ago

I am using the the version of gcc (4.9.3) that comes with RTools, which is something I use quite a bit. I'm a bit nervous about breaking RTools if I update gcc.

https://cran.r-project.org/bin/windows/Rtools/

Apparently it is possible to install two versions of gcc but it looks a little fiddly.

https://gcc.gnu.org/faq.html#multiple

Any suggestions?

stephenberry commented 6 years ago

I decided I'm fine with removing the explicit noexcept qualifier. I just committed this change, so if you update your Ascent repository the code should build with GCC 4.9.1 and beyond.

woodwards commented 6 years ago

Excellent, it works!!!

stephenberry commented 6 years ago

Fantastic! I'm closing this issue, but feel free to bring up any issues or questions you have in the future.