0

I am trying to build OpenNN library according to instructions here. But after

make opennn

I get the following output (not full):

[2%] Built target tinyxml2 
[4%] Building CXX object opennn/CMakeFiles/opennn.dir/variables.cpp.o
In file included from /home/wolfgang/Downloads/OpenNN/opennn/variables.h:32:0,
             from /home/wolfgang/Downloads/OpenNN/opennn/variables.cpp:16:
/home/wolfgang/Downloads/OpenNN/opennn/vector.h: In member function ‘bool OpenNN::Vector<T>::Lillieforts_normality_test() const’:
/home/wolfgang/Downloads/OpenNN/opennn/vector.h:1144:20: error: ‘erfc’ is not a member of ‘std’
     Fx = 0.5 * std::erfc((mean - (*this)[i])/(standard_deviation*std::sqrt(2)));

the above output ends with

make[3]: *** [opennn/CMakeFiles/opennn.dir/variables.cpp.o] Error 1
make[2]: *** [opennn/CMakeFiles/opennn.dir/all] Error 2
make[1]: *** [opennn/CMakeFiles/opennn.dir/rule] Error 2
make: *** [opennn] Error 2

I think I should use -std=c++11 or something but I do not know exactly how. I tried to add this line

CXXFLAGS += -std=c++11

to Makefile but it does not work.


I do not know about cmake and make anything. But thing that those errors were caused by incompatibility with older c++xx.

paraxod
  • 331
  • 2
  • 13
  • When you add `CXXFLAGS += -std=c++11` do the errors change at all? What compiler and version are you using? – NathanOliver Sep 22 '17 at 11:42
  • The same output after adding flags. Usually I use g++ 4.8.4. But here I do not use g++ explicitly. I mean all I do is `cmake -DCMAKE_BUILD_TYPE=Release ..` and then `make opennn`. – paraxod Sep 22 '17 at 11:50
  • I assume you already have `#include ` in your code, but [this issue](https://stackoverflow.com/questions/1033898/why-do-you-have-to-link-the-math-library-in-c) could be related to yours. – Bob__ Sep 22 '17 at 13:23
  • You may be interested to find an other math library than the one shipped in the c++ standard library, it is just too small! If you use the *error function*, maybe soon, you will need the *inverse error function* and this is not provided in even in c++17 !!! – Oliv Sep 22 '17 at 13:46
  • Did you modify the source code of opennn with respect to the version that is found online at the address https://github.com/orian/opennn that you refer to? – Pierre de Buyl Sep 22 '17 at 19:58

2 Answers2

0

Remove std::, try this:

Fx = 0.5 * erfc((mean - (*this)[i])/(standard_deviation*std::sqrt(2)));
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
0

Solution A - update CMake

You need at least version 3.1 of CMake, so you need to update it if yours is lower.

I encountered this problem on Ubuntu 14.04 which uses version 2.8 by default (package name "cmake"); uninstall it and install "cmake3" instead (on Ubuntu 14.04, "cmake3" contains CMake 3.5).

So for Ubuntu 14.04, the official documentation contains error and "sudo apt-get install cmake" should be replaced with "sudo apt-get install cmake3"; but beware that this might not apply for different (newer) systems.

Solution B - edit CMakeLists

This works with older CMake version (at least 2.6).

Update "CMakeLists.txt" file in root directory of OpenNN source repository; add line "set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")" under line "set (CMAKE_CXX_STANDARD 11)" (should be 5th line).

Explanation

OpenNN uses "set (CMAKE_CXX_STANDARD 11)" to tell the CMake that C++11 standard should be used. However, this is supported since CMake 3.1. This problem is not caught by older CMake, because first line of OpenNN's CMakeLists is "cmake_minimum_required(VERSION 2.6)" which says "minimal version is 2.6". That allows running CMake on OpenNN with CMake version which doesn't supports all used features (by OpenNN) which causes this problem.

Second solution (solution B) just adds the needed "-std=c++11" flag for compiler manually.

Tom
  • 290
  • 1
  • 9