Artelnics / opennn

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

Master branch doesn't compile #156

Closed gradew closed 3 years ago

gradew commented 3 years ago

Some examples are missing (like airline_passengers), as well as the functions.cpp file in the opennn/ directory. To this day, the only version I could compile successfully is 4.0.

Am I missing something? :)

jandres-artelnics commented 3 years ago

Hi @gradew ,

You're right, airline_passengers example is not developed that and should not be inside examples.pro , not even commented.

Thank you for reporting the issue, we're gonna correct that.

Regarding the functions.cpp file, this file is no longer part of opennn. The 4.9 version should work properly without this file. I'd say that some temp files like opennn.pro.user may be the problem. Could you remove this file and try compiling again?

If you keep on having problems, contact us again.

Thank you.

gradew commented 3 years ago

Hello!

Thank you for your quick reply! :)

Before I continue, I should mention I'm currently testing this on Windows, with Visual Studio and cmake.

So here is the complete list of missing projects: airline_passengers pollution_forecasting simple_function_regression simple_pattern_recognition temperature_forecasting

Once I've removed them from examples/CMakeLists.txt, another problem pops up:

CMake Error at opennn/CMakeLists.txt:9 (add_library): Cannot find source file:

functions.cpp

I've removed the reference to functions.cpp in the CMakeLists.txt file, as well as: k_means.cpp metrics.cpp transformations.cpp

And now everything seems to compile :) Thanks for the hint! I haven't looked at the .pro files yet however.

I'll try running a project now, but it looks like my issues are resolved :)

gradew commented 3 years ago

Confirmed, it all works perfectly now!

jandres-artelnics commented 3 years ago

Great!

I'll close the issue but please feel free to open a new issue if any problem appears.

We're also available at info@opennn.net.

Thank you for using OpenNN

MrChuse commented 3 years ago

It isn't working properly for me, though. I just want to look at the examples but they aren't built properly. After removing all the subdirectories except for iris_plant in the examples/CMakeLists.txt I get cannot find -l../../opennn/Release/opennn

After some thinking I changed ../../opennn/Release/opennn to opennn in the examples/iris_plant/CMakeLists.txt, line 9 (because I think that target_link_libraries should receive name of the library, not its path) and the error changed to data_set.cpp: undefined reference to omp_get_max_threads and the same error but for loss_index.cpp, optimization_algorithm.cpp, perceptron_layer.cpp, testing_analysis.cpp, learning_rate_algorithm.cpp also there is statistics.cpp: undefined reference to OpenNN::maximum(Eigen::Tensor<int, 1, 0, int> const&)

Maybe I am getting wrong what exactly link_directories and target_link_libraries do but I tried everything that came to my mind.

Please help me, what should I do?

jandres-artelnics commented 3 years ago

Hi @MrChuse ,

I'm working on the CMake file since there were some errors as you described. It needed to be updated.

The error data_set.cpp: undefined reference to omp_get_max_threads seems to be related to the instalation of openMP. Do you have openMP installed? It's tricky when using mac or linux.

Regarding the error statistics.cpp: undefined reference to OpenNN::maximum(Eigen::Tensor<int, 1, 0, int> const&), where is the call that is failing?

jandres-artelnics commented 3 years ago

Hi @MrChuse ,

Master branch have changed and now Cmake is updated.

If you're using windows, cmake and visualstudio it should be working.

I'm opening bash and using "cmake ." in the opennn folder. Then I open the ".sln" file using visualstudio, changing to "Release" (default is debug) and "Ctrl + B" to compile "ALL_BUILD".

After doing that, you will be able to find the ".exe" files for each example inside the folder named after the example and inside the folder Release. For instance: "...\opennn\examples\breast_cancer\Release"

If you're using mac it should be working too.

I tried the same but using "make" instead of visualstudio and the compilation was done properly. You may find some issues with the path of the datasets but changing that in the main.cpp of the example it will work fine.

Please tell me if you're still having troubles.

Thank you for using OpenNN.

MrChuse commented 3 years ago

So, I just run cmake -G "MinGW Makefiles" -DCMAKE_TYPE_BUILD=Release .. and mingw32-make.exe using the updated master branch. The first command warns me that CMAKE_TYPE_BUILD was not used by the project (and the build files have been written to opennn/build) The second command fails with [70%] Linking CXX executable airfoil_self_noise.exe : cannot find -l../opennn/Release/opennn

After I change line 9 in opennn/examples/airfoil_self_noise/CMakeLists.txt to set (PROJECT_LINK_LIBS opennn), I get undefined reference to `omp_get_max_threads'

I don't know whether I have OpenMP installed or not but as I've searched, MinGW is not listed in the OpenMP Compilers & Tools. I also tried to install pthreads-w32 using mingw-get but the problem didn't disappear. (I tried using -lgomp -lpthreadGC2 or -fopenmp flags, doesn't work)

jandres-artelnics commented 3 years ago

MinGW may be the cause of your troubles, can you try with other compiler?

MrChuse commented 3 years ago

I didn't want to work with Visual Studio but I think I will. So, when I press ctrl+B on the Release mode I get three things built successfully (I don't know which exactly) and 10 have errors (examples I think, all of them have fatal error LNK1181: cannot open file "..\..\opennn\Release\opennn.lib"). I wonder if I should remove \Release\opennn from CMakeLists.txt everywhere.. I will test it later today

jandres-artelnics commented 3 years ago

Hi @MrChuse ,

You're right, airfoil_self_noise example CMakeLists.txt had a typo (already corrected).

Regarding :

fatal error LNK1181: cannot open file "..\..\opennn\Release\opennn.lib")

Once you open the .sln on Visual Studio, compile "opennn" first and then the example you want to compile.

MrChuse commented 3 years ago

Once you open the .sln on Visual Studio, compile "opennn" first and then the example you want to compile.

That's why it wasn't working, I didn't see that coming! On the second time it has built all the examples successfully. MNIST, apparently, is missing some files (there is mnist_train_1.csv instead of mnist_train.csv) but I renamed the file and it started working. No problems there. Thank you very much for your work. You may close the issue.

Side question: how do I launch the examples (or my project with opennn) in the Visual studio? If I press Local Windows Debugger or use the example's context menu -> Debug -> Start New Instance, I get Cannot open data file: ../data/iris_plant_original.csv error. Doesn't Visual Studio launch them from /Release directory? Of course, I can launch the app using explorer or cmd, so this question is only about convenience, not about workability

MrChuse commented 3 years ago

I don't know whether I should say it here or create a new issue, but the add_subdirectory(blank) is also missing in the root CMakeLists.txt.

jandres-artelnics commented 3 years ago

Hi @MrChuse ,

The paths that are set are the ones thata work fine when using Qt but it may need some fix if using cmake since we're making cmake from a different directory. Regarding VisualStudio, we don't use it here so I'm not able to give you a good answer.

I'll close the issue. If you face more trouble please feel free to open another issue.

Thank you for using OpenNN.