Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPRAL build in Windows #137

Open
bharswami opened this issue Sep 18, 2023 · 39 comments
Open

SPRAL build in Windows #137

bharswami opened this issue Sep 18, 2023 · 39 comments
Labels

Comments

@bharswami
Copy link

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
Copy link
Contributor

jfowkes commented Sep 18, 2023

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
Copy link
Author

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

@jfowkes
Copy link
Contributor

jfowkes commented Sep 18, 2023

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

@bharswami
Copy link
Author

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

@jfowkes
Copy link
Contributor

jfowkes commented Sep 18, 2023

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
Copy link
Author

bharswami commented Sep 18, 2023

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
Copy link
Contributor

jfowkes commented Sep 18, 2023

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
Copy link
Author

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
Copy link
Contributor

jfowkes commented Sep 19, 2023

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

@bharswami
Copy link
Author

bharswami commented Sep 19, 2023

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
Copy link
Author

bharswami commented Sep 19, 2023 via email

@amontoison
Copy link
Member

@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
Copy link
Author

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

@amontoison
Copy link
Member

amontoison commented Sep 21, 2023

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

@bharswami
Copy link
Author

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
Copy link
Member

amontoison commented Sep 21, 2023

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

@amontoison
Copy link
Member

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

@bharswami
Copy link
Author

.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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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

@bharswami
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

@amontoison
Copy link
Member

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

@bharswami
Copy link
Author

bharswami commented Sep 22, 2023

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?

@jfowkes jfowkes changed the title SPRAL build in WIndows SPRAL build in Windows Sep 22, 2023
@amontoison
Copy link
Member

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

@bharswami
Copy link
Author

bharswami commented Oct 30, 2023 via email

@bharswami
Copy link
Author

bharswami commented Nov 8, 2023 via email

@amontoison
Copy link
Member

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

@bharswami
Copy link
Author

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
Copy link
Contributor

jfowkes commented Nov 8, 2023

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
Copy link
Author

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$libmetis__ikvsorti]+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
Copy link
Contributor

jfowkes commented Nov 9, 2023

@amontoison could you advise?

@amontoison
Copy link
Member

amontoison commented Nov 9, 2023

@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
Copy link
Author

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
Copy link
Contributor

jfowkes commented Nov 15, 2023

@amontoison can you advise?

@amontoison
Copy link
Member

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants