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

Unclear how to create shared dynamic libraries on Windows #103

Open
dbischof90 opened this issue Oct 24, 2023 · 19 comments
Open

Unclear how to create shared dynamic libraries on Windows #103

dbischof90 opened this issue Oct 24, 2023 · 19 comments
Labels
ci Issues related to CI cmake Issues related to CMake good first issue Good for newcomers help wanted Extra attention is needed tests needed Issues that necessitate or motivate new tests windows Issues related to Windows

Comments

@dbischof90
Copy link

Hi,

I'm currently trying to wrap PRIMA into a C# interface and, well, building is already an issue. :)
Judging from the CMakeFiles, I thought I'd only have to switch on BUILD_SHARED_LIBS but maybe I'm missing something.

My output right now is

PS C:\MyWS\prima> cmake -S . -B build -DCMAKE_INSTALL_PREFIX=install -DBUILD_SHARED_LIBS=1
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22621.
-- The Fortran compiler identification is Intel 2021.10.0.20230609
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Determine Intel Fortran Compiler Implicit Link Path
-- Determine Intel Fortran Compiler Implicit Link Path - done
-- Check for working Fortran compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/2023.2.1/windows/bin/intel64/ifort.exe - skipped
-- The C compiler identification is MSVC 19.29.30151.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (15.4s)
-- Generating done (0.1s)
-- Build files have been written to: C:/MyWS/prima/build
PS C:\MyWS\prima> cmake --build build --target install

Microsoft Visual Studio 2019 Version 16.11.28.
Copyright (C) Microsoft Corp. Alle Rechte vorbehalten.
Erstellen gestartet...
1>------ Erstellen gestartet: Projekt: ZERO_CHECK, Konfiguration: Debug x64 ------
1>1>Checking Build System
2>------ Erstellen gestartet: Projekt: primaf, Konfiguration: Debug x64 ------
Compiling with Intel® Fortran Compiler Classic 2021.10.0 [Intel(R) 64]...
consts.F90
pintrf.f90
huge.F90
infos.f90
debug.F90
inf.F90
memory.F90
redrho.f90
infnan.F90
string.f90
ratio.f90
linalg.f90
history.f90
selectx.f90
checkexit.f90
preproc.f90
fprint.f90
powalg.f90
evaluate.f90
trustregion.f90
univar.f90
trustregion.f90
message.f90
geometry.f90
trustregion.f90
trustregion.f90
xinbd.f90
update.f90
update.f90
shiftbase.f90
getact.f90
update.f90
geometry.f90
update.f90
initialize.f90
geometry.f90
initialize.f90
geometry.f90
uobyqb.f90
rescue.f90
update.f90
geometry.f90
trustregion.f90
initialize.f90
initialize.f90
initialize.f90
uobyqa.f90
lincob.f90
lincoa.f90
cobylb.f90
bobyqb.f90
newuob.f90
cobyla.f90
bobyqa.f90
newuoa.f90
Performing Pre-Link Event...
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.
Linking...
Microsoft (R) Incremental Linker Version 14.29.30151.0
Copyright (C) Microsoft Corporation.  All rights reserved.
/OUT:C:\MyWS\prima\build\bin\Debug\primaf.dll
/VERSION:0.0
/DEF:C:\MyWS\prima\fortran\primaf-Intel.def
/MANIFEST
/MANIFESTFILE:primaf.dir\Debug\primaf.dll.intermediate.manifest
"/MANIFESTUAC:level='asInvoker' uiAccess='false'"
/DEBUG
/PDB:C:\MyWS\prima\build\bin\Debug\primaf.pdb
/IMPLIB:C:\MyWS\prima\build\fortran\Debug\primaf.lib
/DLL
user32.lib
/machine:x64
/debug
/INCREMENTAL
primaf.dir\Debug\consts.obj
primaf.dir\Debug\pintrf.obj
primaf.dir\Debug\huge.obj
primaf.dir\Debug\infos.obj
primaf.dir\Debug\debug.obj
primaf.dir\Debug\inf.obj
primaf.dir\Debug\memory.obj
primaf.dir\Debug\redrho.obj
primaf.dir\Debug\infnan.obj
primaf.dir\Debug\string.obj
primaf.dir\Debug\ratio.obj
primaf.dir\Debug\linalg.obj
primaf.dir\Debug\history.obj
primaf.dir\Debug\selectx.obj
primaf.dir\Debug\checkexit.obj
primaf.dir\Debug\preproc.obj
primaf.dir\Debug\fprint.obj
primaf.dir\Debug\powalg.obj
primaf.dir\Debug\evaluate.obj
primaf.dir\Debug/uobyqa/trustregion.f90.obj
primaf.dir\Debug\univar.obj
primaf.dir\Debug/bobyqa/trustregion.f90.obj
primaf.dir\Debug\message.obj
primaf.dir\Debug/cobyla/geometry.f90.obj
primaf.dir\Debug/newuoa/trustregion.f90.obj
primaf.dir\Debug/cobyla/trustregion.f90.obj
primaf.dir\Debug\xinbd.obj
primaf.dir\Debug/uobyqa/update.f90.obj
primaf.dir\Debug/cobyla/update.f90.obj
primaf.dir\Debug\shiftbase.obj
primaf.dir\Debug\getact.obj
primaf.dir\Debug/newuoa/update.f90.obj
primaf.dir\Debug/uobyqa/geometry.f90.obj
primaf.dir\Debug/bobyqa/update.f90.obj
primaf.dir\Debug/cobyla/initialize.f90.obj
primaf.dir\Debug/bobyqa/geometry.f90.obj
primaf.dir\Debug/uobyqa/initialize.f90.obj
primaf.dir\Debug/lincoa/geometry.f90.obj
primaf.dir\Debug\uobyqb.obj
primaf.dir\Debug\rescue.obj
primaf.dir\Debug/lincoa/update.f90.obj
primaf.dir\Debug/newuoa/geometry.f90.obj
primaf.dir\Debug/lincoa/trustregion.f90.obj
primaf.dir\Debug/lincoa/initialize.f90.obj
primaf.dir\Debug/newuoa/initialize.f90.obj
primaf.dir\Debug/bobyqa/initialize.f90.obj
primaf.dir\Debug\uobyqa.obj
primaf.dir\Debug\lincob.obj
primaf.dir\Debug\lincoa.obj
primaf.dir\Debug\cobylb.obj
primaf.dir\Debug\bobyqb.obj
primaf.dir\Debug\newuob.obj
primaf.dir\Debug\cobyla.obj
primaf.dir\Debug\bobyqa.obj
primaf.dir\Debug\newuoa.obj
primaf.dir\Debug\primaf.dll.embed.manifest.res
   Bibliothek "C:\MyWS\prima\build\fortran\Debug\primaf.lib" und Objekt "C:\MyWS\prima\build\fortran\Debug\primaf.exp" werden erstellt.
Embedding manifest...
Microsoft (R) Manifest Tool
Copyright (c) Microsoft Corporation.
All rights reserved.

Build log written to  "file://C:/MyWS/prima/build/fortran/primaf.dir/Debug/BuildLog.htm"
primaf - 0 error(s), 0 warning(s)
3>------ Erstellen gestartet: Projekt: primac, Konfiguration: Debug x64 ------
3>Building Custom Rule C:/MyWS/prima/c/CMakeLists.txt
3>cl : befehlszeile warning D9002: Unbekannte Option "/fpp" wird ignoriert.
3>cl : befehlszeile warning D9002: Unbekannte Option "/libs:dll" wird ignoriert.
3>cl : befehlszeile warning D9002: Unbekannte Option "/threads" wird ignoriert.
3>cl : befehlszeile warning D9002: Unbekannte Option "/heap-arrays" wird ignoriert.
3>cl : befehlszeile warning D9002: Unbekannte Option "/assume:recursion" wird ignoriert.
3>cl : befehlszeile warning D9002: Unbekannte Option "/debug:full" wird ignoriert.
3>cl : befehlszeile warning D9002: Unbekannte Option "/dbglibs" wird ignoriert.
3>prima.c
3>primac.def : error LNK2001: Nicht aufgelöstes externes Symbol "bobyqa_c".
3>primac.def : error LNK2001: Nicht aufgelöstes externes Symbol "cobyla_c".
3>primac.def : error LNK2001: Nicht aufgelöstes externes Symbol "lincoa_c".
3>primac.def : error LNK2001: Nicht aufgelöstes externes Symbol "newuoa_c".
3>primac.def : error LNK2001: Nicht aufgelöstes externes Symbol "uobyqa_c".
3>C:/MyWS/prima/build/c/Debug/primac.lib : fatal error LNK1120: 5 nicht aufgelöste Externe
3>Die Erstellung des Projekts "primac.vcxproj" ist abgeschlossen -- FEHLER.
4>------ Erstellen gestartet: Projekt: ALL_BUILD, Konfiguration: Debug x64 ------
4>Building Custom Rule C:/MyWS/prima/CMakeLists.txt
5>------ Erstellen gestartet: Projekt: INSTALL, Konfiguration: Debug x64 ------
5>1>
5>-- Install configuration: "Debug"
5>-- Installing: C:/MyWS/prima/install/lib/primaf.lib
5>-- Installing: C:/MyWS/prima/install/bin/primaf.dll
5>-- Installing: C:/MyWS/prima/install/bin/primac.dll
5>-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-targets.cmake
5>-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-targets-debug.cmake
5>-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-config.cmake
5>-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-config-version.cmake
5>-- Installing: C:/MyWS/prima/install/include/prima/mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/bobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/bobyqb_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/checkexit_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/cobyla_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/cobylb_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/consts_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/debug_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/evaluate_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/fprint_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/geometry_bobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/geometry_cobyla_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/geometry_lincoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/geometry_newuoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/geometry_uobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/getact_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/history_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/huge_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/infnan_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/infos_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/inf_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/initialize_bobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/initialize_cobyla_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/initialize_lincoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/initialize_newuoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/initialize_uobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/linalg_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/lincoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/lincob_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/memory_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/message_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/newuoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/newuob_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/pintrf_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/powalg_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/preproc_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/ratio_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/redrho_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/rescue_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/selectx_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/shiftbase_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/string_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/trustregion_bobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/trustregion_cobyla_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/trustregion_lincoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/trustregion_newuoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/trustregion_uobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/univar_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/uobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/uobyqb_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/update_bobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/update_cobyla_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/update_lincoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/update_newuoa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/update_uobyqa_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/mod/Debug/xinbd_mod.mod
5>-- Installing: C:/MyWS/prima/install/include/prima/prima.h
========== Erstellen: 4 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========

I've seen in #28 that this was discussed already, I suspect that I'm just not passing the correct build flags. Any ideas?

@jschueller
Copy link
Collaborator

isnt that a dynamic lib ?
Installing: C:/MyWS/prima/install/bin/primac.dll

@dbischof90
Copy link
Author

dbischof90 commented Oct 24, 2023

Correct - but it's empty (0B). If you check the middle of the log you'll see that the part you contributed somehow doesn't compile because of "unknown options (/fpp etc) and "unresolved external symbols" (German translation).

Just out of the blue, while my C is a bit rusty, is it possible that the header file is not found during the linking? The Fortran part seems to work out fine.

@jschueller
Copy link
Collaborator

weird, I dont see the fortran sources of primac being compiled, only prima.c, and also fortran flags seem incorrectly being passed to the cl C compiler: "/heap-arrays" wird ignoriert.

@dbischof90
Copy link
Author

True. So the Fortran part seems to work so the differences between the make files could be it.

@zaikunzhang I think you wrote the Fortran part - any ideas? You wrote a note in the Makefile that the exports must be treated differently, could that be something?

Not sure how to debug this, I'd be very thankful for some explicit help 😄 no real experience with CMake unfortunately.

@zaikunzhang
Copy link
Member

zaikunzhang commented Oct 24, 2023

True. So the Fortran part seems to work so the differences between the make files could be it.

@zaikunzhang I think you wrote the Fortran part - any ideas? You wrote a note in the Makefile that the exports must be treated differently, could that be something?

Not sure how to debug this, I'd be very thankful for some explicit help 😄 no real experience with CMake unfortunately.

Hi @dbischof90 , the CMake building system was by @jschueller, except that I made some minor revisions to the comments, only wordings. I am ignorant about CMake. I hope @jschueller will figure out the problem. Thank you.

BTW, this may be a reminder that we should test both the shared and the static libraries in the CI. Do we have that already?

In my experience, it has always been a good idea to make as many tests as possible, including some "unnecessary" tests (see the discussion on tests). Many problems and bugs have been spotted and fixed thanks to some "stupid" tests. If we don't have some tests like "oh that test, it is not needed, because I know it will pass", we are not testing sufficiently. That kind of test is more likely to surprise me, due to my limited knowledge, or because compilers/platforms do not behave as expected or even incorrectly (compilers have bugs, and PRIMA has revealed MANY). Maybe we are in such a situation again.

Thanks.

@zaikunzhang zaikunzhang added the cmake Issues related to CMake label Oct 24, 2023
@jschueller
Copy link
Collaborator

jschueller commented Oct 25, 2023

It could be that combining intel fortran and visual studio compiler is not possible because linker arguments and abi are not compatible, could you try using the intel C compiler instead ? It would involve changing the cmake generator, for example Ninja.

@amontoison
Copy link
Member

amontoison commented Oct 25, 2023

On Windows, we need an import library (.lib) if we want to compile with MSVC.
Some cross-compilers like MinGW are smart enough to not require it.
I suggest to try the icc compiler with the CMake flag -DCMAKE_C_COMPILER=icc.

@dbischof90
Copy link
Author

Okay, apologies, then I was indeed at the right address first. The tests did also help initially to figure out how to set up the Intel compiler for me, they also act as some form of documentation in the ideal case, which the maintainers achieved here very well so far.

Having well-documented examples and tests on how to create shared libraries will help other people write diverse language wrappers too and the more systems they can target, the more coverage you can generate.

@dbischof90
Copy link
Author

So, I got a little further.

I installed the Intel oneAPI C and Fortran compilers and, after setting the environment variables correctly (by using the "oneAPI command prompt", which sets the variables and paths accordingly (Windows...)) I could build at least.

The first observation is that on Windows, according to https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-0/use-cmake-with-the-compiler.html, the only supported build tool for the oneAPI Intel compiler is Ninja. I installed that too and then got

:: initializing oneAPI environment...
   Initializing Visual Studio command-line environment...
   Visual Studio version 16.11.28 environment configured.
   "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\"
   Visual Studio command-line environment initialized for: 'x64'
:  compiler -- latest
:  debugger -- latest
:  dev-utilities -- latest
:  mpi -- latest
:  tbb -- latest
:: oneAPI environment initialized ::

C:\Program Files (x86)\Intel\oneAPI>cd C:\MyWS\prima

C:\MyWS\prima>cmake -DCMAKE_INSTALL_PREFIX=install  -GNinja -DBUILD_SHARED_LIBS=1 -B build -S .
-- The Fortran compiler identification is IntelLLVM 2023.2.0 with MSVC-like command-line
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/ifx.exe - skipped
-- Assuming Intel symbol mangling
-- The C compiler identification is IntelLLVM 2023.2.0 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/icx.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (2.7s)
-- Generating done (0.1s)
-- Build files have been written to: C:/MyWS/prima/build

C:\MyWS\prima>cmake --build build --target install
[65/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\consts.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\consts.F90" 2
------------------------------------------------------------------------------------^
[67/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\huge.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\huge.F90" 2
----------------------------------------------------------------------------------^
[70/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\inf.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\inf.F90" 2
---------------------------------------------------------------------------------^
[71/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\debug.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\debug.F90" 2
-----------------------------------------------------------------------------------^
[72/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\infnan.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\infnan.F90" 2
------------------------------------------------------------------------------------^
[76/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\memory.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\memory.F90" 2
------------------------------------------------------------------------------------^
[127/128] Install the project...
-- Install configuration: "Release"
-- Installing: C:/MyWS/prima/install/lib/primaf.lib
-- Installing: C:/MyWS/prima/install/bin/primaf.dll
-- Installing: C:/MyWS/prima/install/lib/primac.lib
-- Installing: C:/MyWS/prima/install/bin/primac.dll
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-targets.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-targets-release.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-config.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-config-version.cmake
-- Installing: C:/MyWS/prima/install/include/prima/mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/bobyqb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/checkexit_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/cobylb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/consts_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/debug_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/evaluate_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/fprint_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/getact_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/history_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/huge_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/infnan_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/infos_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/inf_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/linalg_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/lincob_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/memory_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/message_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/newuob_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/pintrf_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/powalg_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/preproc_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/ratio_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/redrho_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/rescue_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/selectx_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/shiftbase_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/string_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/univar_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/uobyqb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/xinbd_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/prima.h

That gave me (besides some warnings) two non-empty .dll files which I however still can't load (tried in Python just to see if all was good). Upon further inspection with DependencyWalker, the following situation emerged:

grafik

So it seems that

  1. for the Intel compiler, some of the FORTRAN flags might not be working. However, the DLL seems to be fine otherwise.
  2. compiling the C wrapper seems to lead to missing dependency and there seems to be at least one circular dependency.

Not so easy apparently.

@jschueller
Copy link
Collaborator

jschueller commented Oct 25, 2023

It looks fine, you can try to compile and run the tests to be sure

@dbischof90
Copy link
Author

It looks fine, you can try to compile and run the tests to be sure

So I can now at least confirm that your example successfully compiles! Starting from a "clean slate":

C:\MyWS\prima>cmake -DCMAKE_INSTALL_PREFIX=install  -GNinja -DBUILD_SHARED_LIBS=OFF -B build -S .
-- The Fortran compiler identification is IntelLLVM 2023.2.0 with MSVC-like command-line
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/ifx.exe - skipped
-- The C compiler identification is IntelLLVM 2023.2.0 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/icx.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (2.9s)
-- Generating done (0.0s)
-- Build files have been written to: C:/MyWS/prima/build

C:\MyWS\prima>cmake --build build --target install
[65/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\consts.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\consts.F90" 2
------------------------------------------------------------------------------------^
[67/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\huge.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\huge.F90" 2
----------------------------------------------------------------------------------^
[70/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\inf.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\inf.F90" 2
---------------------------------------------------------------------------------^
[71/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\debug.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\debug.F90" 2
-----------------------------------------------------------------------------------^
[72/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\infnan.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\infnan.F90" 2
------------------------------------------------------------------------------------^
[76/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\memory.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\memory.F90" 2
------------------------------------------------------------------------------------^
[127/128] Install the project...-- Install configuration: "Release"
-- Installing: C:/MyWS/prima/install/lib/primaf.lib
-- Installing: C:/MyWS/prima/install/lib/primac.lib
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-targets.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-targets-release.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-config.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-config-version.cmake
-- Installing: C:/MyWS/prima/install/include/prima/mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/bobyqb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/checkexit_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/cobylb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/consts_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/debug_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/evaluate_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/fprint_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/getact_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/history_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/huge_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/infnan_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/infos_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/inf_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/linalg_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/lincob_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/memory_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/message_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/newuob_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/pintrf_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/powalg_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/preproc_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/ratio_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/redrho_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/rescue_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/selectx_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/shiftbase_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/string_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/univar_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/uobyqb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/xinbd_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/prima.h


C:\MyWS\prima>cd c/examples/cobyla

C:\MyWS\prima\c\examples\cobyla>cmake -S . -B build -DCMAKE_INSTALL_PREFIX=install -DPRIMA_DIR=./../../../install/lib/cmake/prima/ -GNinja
-- The C compiler identification is IntelLLVM 2023.2.0 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/icx.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (1.4s)
-- Generating done (0.0s)
-- Build files have been written to: C:/MyWS/prima/c/examples/cobyla/build

C:\MyWS\prima\c\examples\cobyla>cmake --build build --target install
[2/3] Install the project...-- Install configuration: "Debug"
-- Installing: C:/MyWS/prima/c/examples/cobyla/install/bin/cobyla_example.exe


C:\MyWS\prima\c\examples\cobyla>C:/MyWS/prima/c/examples/cobyla/install/bin/cobyla_example.exe

Return from COBYLA because the trust region radius reaches its lower bound.
Number of function values = 35   Least value of F = -9.500855780525992E+000   Constraint violation =  0.000000000000000E+000
The corresponding X is:  2.990120684861312E+000   1.992427939779597E+000
The constraint value is:
-8.990120684861312E+000  -7.992427939779597E+000  -3.009879315138688E+000  -4.007572060220403E+000
-1.009879315138688E+000  -1.007572060220403E+000  -5.017451375359091E+000  -8.940919475015008E-002
x*={2.99012, 1.99243} f*=-9.50086 cstrv=0 nlconstr=-0.0894092 rc=0 msg='Trust region radius reaches its lower bound' evals=35

Note that I put -GNinja -DBUILD_SHARED_LIBS=OFF at the very top (in accordance to the documentation). So I can in fact compile now and have the toolchain figured out, that's part of the solution.

My goal now is to make this accessible from C#. Hence if I put -GNinja -DBUILD_SHARED_LIBS=1 and leave out the test part I would expect to get DLLs which I can access from dotnet - here that seems to be not there yet. What am I missing here?

@jschueller
Copy link
Collaborator

show us the logs

@dbischof90
Copy link
Author

Building with

C:\MyWS\prima>cmake -DCMAKE_INSTALL_PREFIX=install  -GNinja -DBUILD_SHARED_LIBS=1 -B build -S .
-- The Fortran compiler identification is IntelLLVM 2023.2.0 with MSVC-like command-line
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/ifx.exe - skipped
-- Assuming Intel symbol mangling
-- The C compiler identification is IntelLLVM 2023.2.0 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/icx.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (2.7s)
-- Generating done (0.0s)
-- Build files have been written to: C:/MyWS/prima/build

C:\MyWS\prima>cmake --build build --target install
[65/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\consts.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\consts.F90" 2
------------------------------------------------------------------------------------^
[68/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\huge.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\huge.F90" 2
----------------------------------------------------------------------------------^
[70/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\inf.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\inf.F90" 2
---------------------------------------------------------------------------------^
[71/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\debug.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\debug.F90" 2
-----------------------------------------------------------------------------------^
[72/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\infnan.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\infnan.F90" 2
------------------------------------------------------------------------------------^
[76/128] Building Fortran object fortran\CMakeFiles\primaf.dir\common\memory.F90.obj
fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\ppf.h(158): warning #5117: Bad # preprocessor line
# 2 "fortran\CMakeFiles\primaf.dir\common\C:\MyWS\prima\fortran\common\memory.F90" 2
------------------------------------------------------------------------------------^
[127/128] Install the project...-- Install configuration: "Release"
-- Installing: C:/MyWS/prima/install/lib/primaf.lib
-- Installing: C:/MyWS/prima/install/bin/primaf.dll
-- Installing: C:/MyWS/prima/install/lib/primac.lib
-- Installing: C:/MyWS/prima/install/bin/primac.dll
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-targets.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-targets-release.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-config.cmake
-- Installing: C:/MyWS/prima/install/lib/cmake/prima/prima-config-version.cmake
-- Installing: C:/MyWS/prima/install/include/prima/mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/bobyqb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/checkexit_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/cobylb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/consts_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/debug_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/evaluate_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/fprint_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/geometry_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/getact_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/history_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/huge_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/infnan_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/infos_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/inf_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/initialize_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/linalg_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/lincob_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/memory_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/message_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/newuob_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/pintrf_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/powalg_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/preproc_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/ratio_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/redrho_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/rescue_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/selectx_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/shiftbase_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/string_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/trustregion_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/univar_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/uobyqb_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_bobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_cobyla_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_lincoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_newuoa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/update_uobyqa_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/mod/xinbd_mod.mod
-- Installing: C:/MyWS/prima/install/include/prima/prima.h

PS C:\MyWS\prima> cd .\install\bin\
PS C:\MyWS\prima\install\bin> ls


    Verzeichnis: C:\MyWS\prima\install\bin


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        25.10.2023     15:20          68096 primac.dll
-a----        25.10.2023     15:20        1745408 primaf.dll

I now just try to load the primac.dll into Python with ctypes.

PS C:\MyWS\prima\install\bin> ipython.exe
Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct  2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from ctypes import CDLL
   ...: import time

In [2]: import os

In [3]: lib = CDLL(os.path.join(os.getcwd(), 'primac.dll'))
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[3], line 1
----> 1 lib = CDLL(os.path.join(os.getcwd(), 'primac.dll'))

File C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\ctypes\__init__.py:376, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    373 self._FuncPtr = _FuncPtr
    375 if handle is None:
--> 376     self._handle = _dlopen(self._name, mode)
    377 else:
    378     self._handle = handle

FileNotFoundError: Could not find module 'C:\MyWS\prima\install\bin\primac.dll' (or one of its dependencies). Try using the full path with constructor syntax.

I am definitely in the correct directory, hence my guess was that (or one of its dependencies) is the relevant bit here. That lead me to Dependency Walker mentioned above and the screenshot I posted, which also tells me that a required dependency is not available - almost all of those come out of KERNEL32.DLL as it seems so that does not seem to be linked together correctly. That's however also really just a guess, I only use Windows at work and am currently experimenting there with getting this thing to run.

@jschueller
Copy link
Collaborator

jschueller commented Oct 25, 2023

all prima dlls must be in PATH, try to load primaf.dll first

@dbischof90
Copy link
Author

dbischof90 commented Oct 25, 2023

Same issue.

In [7]: lib = CDLL(os.path.join(os.getcwd(), 'primaf.dll'))
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[7], line 1
----> 1 lib = CDLL(os.path.join(os.getcwd(), 'primaf.dll'))

File C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\ctypes\__init__.py:376, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    373 self._FuncPtr = _FuncPtr
    375 if handle is None:
--> 376     self._handle = _dlopen(self._name, mode)
    377 else:
    378     self._handle = handle

FileNotFoundError: Could not find module 'C:\MyWS\prima\install\bin\primaf.dll' (or one of its dependencies). Try using the full path with constructor syntax.

There's also the option to add DLL directories via https://docs.python.org/3/library/os.html#os.add_dll_directory but that did also not help.

As you see from the output, it's also not really clear to me what's missing either. If you have some more pointers I'm happy to try out things and report back, I'm sure I'm not the only person who'd like to write a custom wrapper on Windows. I'd really prefer that over rewriting it all in C# 🫠

@zaikunzhang zaikunzhang added help wanted Extra attention is needed windows Issues related to Windows labels Oct 26, 2023
@zaikunzhang
Copy link
Member

zaikunzhang commented Oct 26, 2023

BTW, this may be a reminder that we should test both the shared and the static libraries in the CI. Do we have that already?

Hi @jschueller , have we tested shared libraries in our CI? If not yet, could we maybe add such tests?

I suggest that all possibilities should be tested when introducing a new feature / component. This is nontrivial to do and it takes a lot of time, but it is what I have always tried to achieve during the development of PRIMA (see how many tests PRIMA has now). We should not expect that it can be done in one shot, but we should add new tests when we realize that something is missing.

IMHO, it is normal that tests keep being augmented over time --- it is indeed quite abnormal if they remain the same after being introduced unless the development of the software has terminated.

See also "What kind of tests are sufficient for the porting or translation of PRIMA?".

cc: @emmt @amontoison @nbelakovski @ragonneau @Lht97 @OptHuang

Thanks.

@zaikunzhang zaikunzhang added tests needed Issues that necessitate or motivate new tests ci Issues related to CI good first issue Good for newcomers labels Oct 26, 2023
@jschueller
Copy link
Collaborator

jschueller commented Oct 26, 2023

yes, its the default mode, but we didnt test MS visual C / intel fortran combination

@zaikunzhang
Copy link
Member

Hi @dbischof90 , @jschueller (many thanks!) has added new CI tests for MS C compiler in combinations with intel fortran compilers: #105 . Could you check whether the configuration of the tests help you to configure the tool chain on your side? Thanks.

@dbischof90
Copy link
Author

dbischof90 commented Oct 30, 2023

Hi!
So this configuration creates DLLs successfully on my work laptop and judging from the output, those are fine (as in 'not empty'). I could unfortunately not find out how to call them externally (neither from Python nor from C# nor from VB.NET), so I can't say whether or not that works as intended. The errors I'm getting could point to some dependencies missing but that seems to be more a setup issue on my side - I can't tell.

Since I'm not very experienced yet in dotnet nor in windows programming in general, I will put this on the side for now and go with native reimplementation I found online (which I know will be inferior to this setup but I can't get it to run). Judging from the little code that the Julia wrapper consists of, it can't be difficult to write a wrapper library but I'm currently not able to figure out how to do this for Windows systems so this is ultimately unsuccessful for me.

Thank you all for your help in this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Issues related to CI cmake Issues related to CMake good first issue Good for newcomers help wanted Extra attention is needed tests needed Issues that necessitate or motivate new tests windows Issues related to Windows
Projects
None yet
Development

No branches or pull requests

4 participants