ampl / mp

An open-source library for mathematical programming
https://mp.ampl.com
Other
229 stars 42 forks source link

Precompiled binaries for Windows #107

Open dpo opened 8 years ago

dpo commented 8 years ago

I'd like to check if you're interested in packaging (or helping) an updated WinRPM for the ASL. My end goal is for Julia users to have the ASL installed automatically on Windows. I can take care of OSX via Homebrew, but I'm Windows illiterate with no access to a Windows machine. My attempts so far at updating the WinRPM have failed for reasons that escape me. There's an issue here: https://github.com/JuliaSmoothOptimizers/AmplNLReader.jl/issues/13 and bits of a discussion here: https://github.com/JuliaPackaging/Homebrew.jl/issues/122#issuecomment-248806703

I attempted to build under MSYS on Appveyor but that fails too: https://ci.appveyor.com/project/dpo/amplnlreader-jl/build/1.0.114#L924

If you have experience building ASL on Windows, I would really appreciate any help.

Thanks.

dpo commented 8 years ago

Is it possible to obtain a libasl.dll with MS Visual Studio? I get loads of error messages of the form

"C:\Users\appveyor\.julia\v0.4\AmplNLReader\deps\src\mp-3.1.0\build\ALL_BUILD.v
cxproj" (default target) (1) ->
"C:\Users\appveyor\.julia\v0.4\AmplNLReader\deps\src\mp-3.1.0\build\test\util-t
est.vcxproj" (default target) (51) ->
  LINK : fatal error LNK1104: cannot open file '..\lib\Debug\mp.lib' [C:\Users\
appveyor\.julia\v0.4\AmplNLReader\deps\src\mp-3.1.0\build\test\util-test.vcxpro
j]

I ran

cmake -DCMAKE_INSTALL_PREFIX=$prefix -DBUILD_SHARED_LIBS=True ..
msbuild ALL_BUILD.vcxproj

If I omit -DBUILD_SHARED_LIBS=True, all builds well but I get asl.lib and Julia doesn't seem to want to import it.

Thanks.

vitaut commented 8 years ago

Building a shared library won't work on Windows because it requires explicit exports.

dpo commented 8 years ago

Cross-compiling is the only option then? Could you have a look at https://github.com/JuliaSmoothOptimizers/AmplNLReader.jl/issues/13 and let me know if you have any ideas.

vitaut commented 8 years ago

It might be possible to build with gcc (e.g. mingw) which has an option to export everything, but I haven't tried that.

dpo commented 8 years ago

I've tried MinGW and MSYS on Windows, and the MinGW cross-compiler on Linux. All fail. How hard would it be to implement dlls?

vitaut commented 8 years ago

Not sure. Might be as simple as marking the functions that you are interested in as exported. Unfortunately I no longer work on this project so can't help there.

dpo commented 8 years ago

That's too bad. Will someone else pick up the project? Good luck in your new adventures.

fdabrandao commented 8 years ago

Hi @dpo, I am the person that is now charge of this project. I am still getting to know the project, so new features (specially for Windows) may take some time to be added.

dpo commented 8 years ago

@fdabrandao Pleased to meet you. I'm not convinced new features are required. If we could manage to cross-compile with MinGW, that would be sufficient for us. Let me know if/when you can have a look. There's a bit of information in the issue mentioned above. Don't hesitate to ask more for more details. The main idea is to build a shared library on Windows so it can be imported from code written in the Julia language.

dpo commented 8 years ago

I got somewhat further with the MSYS build but it fails with the error

[00:03:53] [ 55%] Building C object src/asl/CMakeFiles/amplodbc.dir/tables/amplodbc.c.obj
[00:03:53] In file included from C:/Program Files/Microsoft SDKs/Windows/v7.0/Include/windef.h:177:0,
[00:03:53]                  from C:/Program Files/Microsoft SDKs/Windows/v7.0/Include/windows.h:155,
[00:03:53]                  from C:/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/src/asl/tables/amplodbc.c:28:
[00:03:53] C:/Program Files/Microsoft SDKs/Windows/v7.0/Include/winnt.h:135:2: error: #error "No Target Architecture"
[00:03:53]  #error "No Target Architecture"
[00:03:53]   ^

Here's the complete log (very long): https://gist.github.com/ce3b1ac3228524abb622dbfa36f2516f

Is it possible to build the ASL only, with no other module or extension?

fdabrandao commented 8 years ago

I am still not very familiar with the way cmake modules were implemented in this project. Nevertheless, I would suggest you to add the following to the beginning of src/asl/CMakeLists.txt:

check_module(asl build_asl)
if (NOT build_asl)
  return ()
endif ()

You should then be able to build ASL only by running cmake -DBUILD=asl .; make Please let me know this works so that I can add it to the project.

dpo commented 8 years ago

Thanks. Your suggestion works fine on OSX, but I don't strictly need it there. When I try on Windows with msys, I hit the following problem:

-- Performing Test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX -- compiled but failed to run
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- failed to compile
...
CMake Error at thirdparty/benchmark/src/CMakeLists.txt:17 (message):
  Failed to determine the source files for the regular expression backend

I hit the same kind of difficulty compiling with the MinGW compiler.

dpo commented 8 years ago

Here's a little more information. This is the contents of CMakeError.log:

Performing C++ SOURCE FILE Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 failed with the following output:
Change Dir: C:/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/build/CMakeFiles/CMakeTmp

Run Build Command:"C:/msys64/usr/bin/make.exe" "cmTC_6d441/fast"
/usr/bin/make -f CMakeFiles/cmTC_6d441.dir/build.make CMakeFiles/cmTC_6d441.dir/build
make[1]: Entering directory '/c/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_6d441.dir/src.cxx.obj
/C/msys64/mingw32/bin/g++.exe     -Wall -Wextra -pedantic -std=c++11 -Wall -Wextra -Wshadow -pedantic -pedantic-errors -DHAVE_CXX_FLAG_WSHORTEN_64_TO_32 -Wshorten-64-to-32   -o CMakeFiles/cmTC_6d441.dir/src.cxx.obj -c /C/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/build/CMakeFiles/CMakeTmp/src.cxx
g++.exe: error: unrecognized command line option '-Wshorten-64-to-32'
CMakeFiles/cmTC_6d441.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_6d441.dir/src.cxx.obj' failed
make[1]: *** [CMakeFiles/cmTC_6d441.dir/src.cxx.obj] Error 1
make[1]: Leaving directory '/c/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_6d441/fast' failed
make: *** [cmTC_6d441/fast] Error 2

Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test HAVE_CXX_FLAG_WTHREAD_SAFETY failed with the following output:
Change Dir: C:/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/build/CMakeFiles/CMakeTmp

Run Build Command:"C:/msys64/usr/bin/make.exe" "cmTC_ac34d/fast"
/usr/bin/make -f CMakeFiles/cmTC_ac34d.dir/build.make CMakeFiles/cmTC_ac34d.dir/build
make[1]: Entering directory '/c/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_ac34d.dir/src.cxx.obj
/C/msys64/mingw32/bin/g++.exe     -Wall -Wextra -pedantic -std=c++11 -Wall -Wextra -Wshadow -pedantic -pedantic-errors -Wfloat-equal -Wzero-as-null-pointer-constant -fstrict-aliasing -Wstrict-aliasing -DHAVE_CXX_FLAG_WTHREAD_SAFETY -Wthread-safety   -o CMakeFiles/cmTC_ac34d.dir/src.cxx.obj -c /C/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/build/CMakeFiles/CMakeTmp/src.cxx
g++.exe: error: unrecognized command line option '-Wthread-safety'
CMakeFiles/cmTC_ac34d.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_ac34d.dir/src.cxx.obj' failed
make[1]: *** [CMakeFiles/cmTC_ac34d.dir/src.cxx.obj] Error 1
make[1]: Leaving directory '/c/Users/appveyor/.julia/v0.4/AmplNLReader/deps/src/mp-3.1.0/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_ac34d/fast' failed
make: *** [cmTC_ac34d/fast] Error 2

Source file was:
int main() { return 0; }
tkelman commented 8 years ago

many of the try_run tests could probably be relaxed to try_compile for cross compiling. otherwise you have to tell cmake what the exit code of the test executable would have been if ran on the target system instead of the build system. i have a few of these in my spec file on opensuse but in recent versions more checks have been added. cmake can be really picky about how you specify these flags