Building NOMAD from the source with Java interface
Closed this issue · 6 comments
Hello,
I attempted to build NOMAD 4.4.0 with the Java interface enabled on Windows 10 using the following commands:
cmake -DBUILD_INTERFACE_JAVA=ON -S . -B build/release
cmake --build build/release --config Release --parallel
However, I encountered the following error:
Building Java objects for jNomad_jar.jar
D:\nomad-v.4.4.0\build\release\interfaces\jNomad\EvalPointList.java:221: error: removeLast() in EvalPointList cannot
implement removeLast() in List
public void removeLast() {
^
return type void is not compatible with EvalPoint
where E is a type-variable:
E extends Object declared in interface List
D:\nomad-v.4.4.0\build\release\interfaces\jNomad\EvalPointList.java:225: error: removeFirst() in EvalPointList cannot
implement removeFirst() in List
public void removeFirst() {
^
return type void is not compatible with EvalPoint
where E is a type-variable:
E extends Object declared in interface List
2 errors
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): e
rror MSB8066: Custom build for 'D:\nomad-v.4.4.0\build\release\CMakeFiles\29454df769d132c90bfcd09c1009a74c\java_compile
d_jNomad_jar.rule;D:\nomad-v.4.4.0\build\release\CMakeFiles\29454df769d132c90bfcd09c1009a74c\java_class_filelist.rule;D
:\nomad-v.4.4.0\build\release\CMakeFiles\d4b1a921b892436b8eb85efbada52299\jNomad.jar.rule;D:\nomad-v.4.4.0\build\releas
e\CMakeFiles\c4cb09faa0662c2aa5c2f91567d87567\jNomad_jar.rule;D:\nomad-v.4.4.0\interfaces\jNomad\CMakeLists.txt' exited
with code 1. [D:\nomad-v.4.4.0\build\release\interfaces\jNomad\jNomad_jar.vcxproj]
Here are my setup:
OS: Windows 10
cmake version 3.30.2
Visual Studio 17 2022
Java: java 22.0.1 2024-04-16
NOMAD version: 4.4.0
Could you please advise me on how to resolve this issue and successfully compile it?
The problem seems the related to code produced by Swig.
To make sure I can replicate the problem, could you tell me which version of SWIG you are using.
SWIG Version 4.2.1
Compiled with i686-w64-mingw32-g++ [i686-w64-mingw32]
Configured options: +pcre
Test of SWIG Version 4.2.1 on Mac OSX using AppleClang 14 is ok.
I don't have access to a Windows computer right now but I will ask for access to perform the test (one or two days).
As you have Visual Studio installed, maybe you can try to run the build procedure using Visual Studio C++ compiler (cl.exe).
I have had trouble with mingw g++. It is suppose to work with the provided CMake file but it is never smooth and I usually do not recommend it.
SWIG Version 4.2.1
Compiled with i686-w64-mingw32-g++ [i686-w64-mingw32]
Configured options: +pcre
Just to clarify, the quoted lines are the output of the command swig -version
.
If I understand you correctly, I tried building the code again using Visual Studio 17 2022 and encountered the same error. Here are the screenshots.
I was able to replicate the problem. But with my version of Visual Studio I have many less warnings. This is something we will look for the next release.
The problem you have is with the code created by swig for EvalPointList. However, the EvalPointList is not used.
So, I patched the Master branch to prevent the creation of EvalPointList. The build works on my machine.
I merged the modifs into the Master branch (#178).
Also, when testing the Rosenbrock example on windows, I had to modify the Examples/Rosenbrock.java to find the jNomad.dll.
Thank you, Christophe, for the explanation and help. NOMAD with the Java interface now compiles successfully.