ralna / spral

Sparse Parallel Robust Algorithms Library
https://ralna.github.io/spral/
Other
104 stars 27 forks source link

SPRAL build in Windows #137

Open bharswami opened 11 months ago

bharswami commented 11 months ago

Hi, I am trying to build SPRAL in Windows Visual Studio 2022. Can anyone share the proj files with the necessary cpps and headers? Or could someone tell me what files are needed in the projects?

jfowkes commented 11 months ago

SPRAL requires autotools to generate the necessary build files so I suggest that you generate these in Linux by running ./autogen.sh on WSL or a Linux machine and copy them over to Windows as described in #75.

We are working on moving SPRAL over to a meson based build system that will avoid all this and work on Windows.

bharswami commented 11 months ago

Does autogen.sh give libraries or project files for Visual Studio?

jfowkes commented 11 months ago

We do not supply libraries or project files for Visual Studio as we do not support Visual Studio.

bharswami commented 11 months ago

I don’t use Linux. So could you please tell me what autogen.sh actually does?

jfowkes commented 11 months ago

It generates the necessary files for you to be able to start compilation, see here for more details: https://en.wikipedia.org/wiki/GNU_Autotools

bharswami commented 11 months ago

Do they generate file that I can compile with other files in a Visual Studio environment? I know you said you don’t support Visual Studio. Just clarifying.

jfowkes commented 11 months ago

Yes once you have the build files generated you should be able to compile SPRAL under Visual Studio provided you can install the necessary dependencies METIS and hwloc in your Visual Studio environment.

bharswami commented 11 months ago

I don’t have access to a Linux machine. If it’s not too much to ask, can you provide them to me or add it to a repository and give me a link?

jfowkes commented 11 months ago

In that case I suggest you use WSL: https://learn.microsoft.com/en-us/windows/wsl/about

bharswami commented 11 months ago

Thanks jfowkes. I am trying as we type. I will still like to build SPRAL from the code in Windows Visual Studio. I have been trying but some "tests" (ldlt_app.cpp) are giving errors. The project is building fine though. The error is an out-of-bounds index for a vector. I am trying several ways to identify the source of the error. Could you help me in this?

bharswami commented 11 months ago

I have ./autogen.sh 'd the repository as suggested. I am getting a bunch of files. [image: image.png] Which among these should I use in my VS project.

On Tue, Sep 19, 2023 at 1:32 PM Jari @.***> wrote:

In that case I suggest you use WSL: https://learn.microsoft.com/en-us/windows/wsl/about

— Reply to this email directly, view it on GitHub https://github.com/ralna/spral/issues/137#issuecomment-1725017252, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHO5AOPRNQVLGQNBEBMWG3X3FGRFANCNFSM6AAAAAA44Y6MYM . You are receiving this because you authored the thread.Message ID: @.***>

amontoison commented 11 months ago

@bharswami I cross-compiled SPRAL on Windows for you: SPRAL.v2023.9.7.x86_64-windows.tar.gz You will find static and shared libraries (libspral.a and libspral.dll) as well as all dependencies required by SPRAL (deps folder).

bharswami commented 11 months ago

Thanks a ton. But windows statis libraries *.lib files?

amontoison commented 11 months ago

MinGW generates static libraries on Windows as *.a but you can rename them *.lib.

bharswami commented 11 months ago

I doubt if it works that way. I am getting the following error on compiling (after renaming it to *.lib). spralltestfull_dlls is my project name. Severity Code Description Project File Line Suppression State Error LNK1143 invalid or corrupt file: no symbol for COMDAT section 0x8 spraltestfull_dlls D:\Bharath\OptiToolbox\ipopt\spraltestfull_dlls\libspral.lib(guess_topology.o) 1

amontoison commented 11 months ago

Can you try with the dynamic shared library? Ipopt is compiled with libspral.dll in Julia and it's working.

amontoison commented 11 months ago

Can you also provide your compilers (C, C++ and Fortran)?

bharswami commented 11 months ago

.dll needs .lib. Both are needed while compiling. Can you provide the *.lib files for the 'deps' dlls you sent me? I am using Intel Compiler for FORTRAN and MSVC compiler for C++.

amontoison commented 11 months ago

Oh, you need the import libraries (.lib or .dll.a) and not static libraries .a. I can send you the .dll.a files but you must use gfortran because I cross-compiled with gfortran. Shared libraries compiled with ifort or ifx are not compatible.

bharswami commented 11 months ago

Send me the import libraries. I will try. I doubt if I will need to compile in FORTRAN. But is it possible for you to compile with ifort?

amontoison commented 11 months ago

SPRAL.v2023.9.7.x86_64-w64-mingw32-libgfortran5.tar.gz No, only gcc / gfortran / g++ is available in the cross-compiler.

bharswami commented 11 months ago

I am still getting the same error. Severity Code Description Project File Line Suppression State Error LNK1143 invalid or corrupt file: no symbol for COMDAT section 0x8 spraltestfull_dlls D:\Bharath\OptiToolbox\ipopt\spraltestfull_dlls\libspral.a(guess_topology.o) 1
You have not sent all the lib files. Any reason for that?

bharswami commented 11 months ago

I am only building a C++ project (running test ssids.cpp). So I won't need a FORTRAN compiler. I am giving the path to the dlls to the C++ compiler.

bharswami commented 11 months ago

Can you please send me the *.o files generated by the cross-compiler?

amontoison commented 11 months ago

Yes, I can. I hope that it will help you. spral.zip

bharswami commented 11 months ago

Does the function ldlt_app_tests(), in file ldlt_app.cpp, run fine at your end? Can you please confirm? Can you send me the file dependencies for ldlt_app.cpp?

amontoison commented 10 months ago

@bharswami Can you try to compiler SPRAL with the new Meson build system on Windows?

bharswami commented 10 months ago

Sure. Give me a day’s time as I am also with another assignment.

On Mon, Oct 30, 2023 at 2:25 AM Alexis Montoison @.***> wrote:

@bharswami https://github.com/bharswami Can you try to compiler SPRAL with the new Meson build system on Windows?

— Reply to this email directly, view it on GitHub https://github.com/ralna/spral/issues/137#issuecomment-1784222458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHO5ALWEGA4CSJKKCJIPK3YB27DHAVCNFSM6AAAAAA44Y6MYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUGIZDENBVHA . You are receiving this because you were mentioned.Message ID: @.***>

bharswami commented 10 months ago

I am sorry for the delay in replying. I have been busy with the placement season here. I don't know if you still like me to build the new repository. Do you have the Meson build system as a Visual Studio project? Or is it using a makefile? How do I build it on my windows PC? Please let me know.

On Mon, Oct 30, 2023 at 12:59 PM Bharath ae15d019 @.***> wrote:

Sure. Give me a day’s time as I am also with another assignment.

On Mon, Oct 30, 2023 at 2:25 AM Alexis Montoison @.***> wrote:

@bharswami https://github.com/bharswami Can you try to compiler SPRAL with the new Meson build system on Windows?

— Reply to this email directly, view it on GitHub https://github.com/ralna/spral/issues/137#issuecomment-1784222458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHO5ALWEGA4CSJKKCJIPK3YB27DHAVCNFSM6AAAAAA44Y6MYOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUGIZDENBVHA . You are receiving this because you were mentioned.Message ID: @.***>

amontoison commented 10 months ago

Can you build and test SPRAL on your windows PC with the meson build system? https://github.com/ralna/spral#installation

bharswami commented 10 months ago

I am having trouble installing OpenBLAS on my windows PC. meson.build:59:13: ERROR: Fortran shared or static library 'openblas' not found Could you highlight the steps to do this on Windows? I was able to find only the binaries online, but not install/add them to the path.

jfowkes commented 10 months ago

I believe you can pass the paths as options to meson setup as follows:

meson setup builddir -Dlibblas=openblas -Dliblapack=openblas -Dlibblas_path=path/to/blas -Dlibblas_include=path/to/blas_headers -Dliblapack_path=path/to/lapack

All the meson options we support are described in meson_options.txt

bharswami commented 10 months ago

We should also add paths to metis and hwloc. There were some errors, a lot of repeated ones. I think it is possibly because of using mingw compiler. Is it possible to change it to Visual Studio? Some warnings/errors on doing meson compile -C builddir:

  1. Warning: corrupt .drectve at end of def file 2 c:/users/admin/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot export fprintf: symbol not defined
  2. c:/users/admin/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Bharath/OptiToolbox/Solvers/Source/ipopt/Ipopt-stable-3.14/src/Algorithm/LinearSolvers/metis-5.1.0/build/libmetis/Release/metis.lib(metis.dir/Release/ometis.obj):(.text$mn+0xe5): undefined reference to `printf'
  3. c:/users/admin/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Bharath/OptiToolbox/Solvers/Source/ipopt/Ipopt-stable-3.14/src/Algorithm/LinearSolvers/metis-5.1.0/build/libmetis/Release/metis.lib(metis.dir/Release/gklib.obj):(.text$mn+0x253): undefined reference to `__security_check_cookie'
  4. c:/users/admin/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Bharath/OptiToolbox/Solvers/Source/ipopt/Ipopt-stable-3.14/src/Algorithm/LinearSolvers/metis-5.1.0/build/libmetis/Release/metis.lib(metis.dir/Release/gklib.obj):(.xdata[$unwind$libmetisikvsorti]+0xc): undefined reference to `GSHandlerCheck'
  5. c:/users/admin/gcc/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/Bharath/OptiToolbox/Solvers/Source/ipopt/Ipopt-stable-3.14/src/Algorithm/LinearSolvers/metis-5.1.0/build/libmetis/Release/metis.lib(metis.dir/Release/balance.obj):(.text$mn+0x171): undefined reference to `printf'
jfowkes commented 10 months ago

@amontoison could you advise?

amontoison commented 10 months ago

@bharswami Did you compile METIS with MinGW? I suspect that it was compiled by a different compiler. Yes, you can compile SPRAL with a different compiler, you just need to setup CC, CXX and FC at the setup phase of Meson:

CC=gcc CXX=g++ FC=gfortran meson setup builddir
CC=icc CXX=icpc FC=ifort meson setup builddir
...
bharswami commented 9 months ago

CC=gcc CXX=g++ FC=ifort meson setup builddir I am getting the following error if I set the flags: 'CC' is not recognized as an internal or external command, operable program or batch file. Do you know what is the equivalent flag for visual studio?

jfowkes commented 9 months ago

@amontoison can you advise?

amontoison commented 9 months ago

In that case you need to define CC, CXX and FC as environment variables. I'm not a windows user but I think that the compiler for Visual Studio is msvc.

bharswami commented 9 months ago

I added them to the environment variables. I am still getting the error.