Artelnics / opennn

OpenNN - Open Neural Networks Library
http://www.opennn.net
GNU Lesser General Public License v3.0
1.12k stars 354 forks source link

Error during build #295

Open manumastro opened 4 months ago

manumastro commented 4 months ago

hi, I am trying to build the library but I always run into the same error. i have tried with both qt creator and visual studio as suggested on the website but to no avail. I really want to start using this library but I am probably doing something wrong, I am new to c++. Cattura

manumastro commented 4 months ago

I will add that I am using the latest version cloned from the master

shleym2000 commented 4 months ago

Could be a version of C++ you use in your compiling environment.

You are passing std:wstring object to open() command. But the signature of this command requires char pointer in C++ 98: void open (const char* filename, ios_base::openmode mode = ios_base::in); In C++11 there are 2 possibilities and you really need the second one to kick in:

void open (const char* filename, ios_base::openmode mode = ios_base::in); void open (const string& filename, ios_base::openmode mode = ios_base::in); It might work if you would set the compiling code standard from default to C++11 or C++14.

manumastro commented 4 months ago

Okay, thank you I tried to set the C++ version to 11 in opennn.pro file since i'm using qt creator but with no success. I'll try to do this in visual studio and i'll let you know

manumastro commented 4 months ago

Could be a version of C++ you use in your compiling environment.

You are passing std:wstring object to open() command. But the signature of this command requires char pointer in C++ 98: void open (const char* filename, ios_base::openmode mode = ios_base::in); In C++11 there are 2 possibilities and you really need the second one to kick in:

void open (const char* filename, ios_base::openmode mode = ios_base::in); void open (const string& filename, ios_base::openmode mode = ios_base::in); It might work if you would set the compiling code standard from default to C++11 or C++14.

Hi, i tried compiling setting the code standard to C++11 and C++14, but with no success, i get other errors, can you guys please tell me the environment are you using to compile the project? Thank you in advance!

Haasrobertgmxnet commented 3 weeks ago

I have done the follwing steps (x64 and Visual Studio 2022 Community and Windows 11):

  1. Download opennn-6.0.3.zip from OpenNN's Github page.
  2. Extract opennn-6.0.3.zip into a folder opennn (or opennn-6.0.3).
  3. Change to this opennn folder.
  4. Do cmake . in a terminal or Powershell window.
  5. Open the solution opennn.sln in Visual Studio (in my case VS Community 2022).
  6. Select opennn as the start project ("Als Startprojekt festlegen").
  7. Right mouse-click on on the opennn project to open "Properties (Eigenschaften)" in the context menu. The Project Properties Window will open.
  8. In the Project Properties Window you can select "All Configrations (Alle Konfigurationen)" in the drop-down list in the top-left region of the window. But "Release" configuration will work, too.
  9. In the Project Properties Window select "C/C++ All Options (Alle Optionen)" on the left side.
  10. In C/C++ All Options look for "C++ Version/Standard (C++ Sprachstandard)" and set it to "ISO C++ 14 [...] (/std:c++14)" or "ISO C++ 17 [...] (/std:c++17)" to set it to C++ 14 or C++ 17 std. C++ 17 std will avoid the annoying STL 4038 warning. C++ 20 will not work.
  11. In C/C++ All Options look for "Support for Open-MP (Open-MP Unterstützung)" and set it to "No" or "Disable" (/openmp-). Then, in correlations.cpp the "#pragma omp parallel for" in line 664 will no have an effect on compilation and the code in line 666 will not end up in MSVC error C3016. According to the open issues #278 and #287 OpenMP seems not to work, so disabling it explicitly per compiler flag /openmp- is ok, I think.
  12. In the Project Properties Window select "C/C++ Command Line (Befehlszeile)" on the left side.
  13. There in the "Additional options (Zusätzliche Optionen)" text input window you may add the /EHsc flag to avoid the C4530 warning.
  14. Right below click "Apply (Übernehmen)" and then "OK".

That's all and then do a clean and build.