<div dir="ltr"><div>Ok, so the test does exhibit different errors when run through the config script, compared to my attempts to isolate it:</div><div><br></div><div>----------------------------<br></div><div><br></div><div>Executing: [compilation command]<br><br>successful compile:<br>Source:<br>#include "confdefs.h"<br>#include "conffix.h"<br>/* Override any gcc2 internal prototype to avoid an error. */<br>char HYPRE_IJMatrixCreate();<br>static void _check_HYPRE_IJMatrixCreate() { HYPRE_IJMatrixCreate(); }<br><br>int main() {<br>_check_HYPRE_IJMatrixCreate();;<br> return 0;<br>}<br><br>Executing: [linker command]<br><br>stdout:<br>LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library<br>LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'HYPRE.lib(dtrmm.c.obj)'<br>LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'HYPRE.lib(dtrmv.c.obj)'<br>LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'HYPRE.lib(lsame.c.obj)'<br>LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'HYPRE.lib(xerbla.c.obj)'<br>LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'HYPRE.lib(lsame.c.obj)'<br>LINK : warning LNK4286: symbol '__stdio_common_vsprintf' defined in 'libucrt.lib(output.obj)' is imported by 'HYPRE.lib(dtrti2.c.obj)'<br>[etc...]<br>HYPRE.lib(par_vector.c.obj) : error LNK2019: unresolved external symbol __imp__wassert referenced in function hypre_ParVectorDestroy<br>HYPRE.lib(vector.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(par_csr_matop.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(par_csr_communication.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(csr_matop.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(merge_sort.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(memory.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(IJMatrix_parcsr.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(par_csr_matrix.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(csr_matrix.c.obj) : error LNK2001: unresolved external symbol __imp__wassert<br>HYPRE.lib(memory.c.obj) : error LNK2019: unresolved external symbol __imp_realloc referenced in function hypre_ReAlloc<br>HYPRE.lib(par_vector.c.obj) : error LNK2001: unresolved external symbol __imp_fopen<br>HYPRE.lib(vector.c.obj) : error LNK2001: unresolved external symbol __imp_fopen<br>HYPRE.lib(IJMatrix.c.obj) : error LNK2001: unresolved external symbol __imp_fopen<br>HYPRE.lib(par_csr_matrix.c.obj) : error LNK2001: unresolved external symbol __imp_fopen<br>HYPRE.lib(csr_matrix.c.obj) : error LNK2001: unresolved external symbol __imp_fopen<br>HYPRE.lib(new_commpkg.c.obj) : error LNK2001: unresolved external symbol __imp_fopen<br>HYPRE.lib(printf.c.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vfscanf referenced in function _vfscanf_l<br>HYPRE.lib(printf.c.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function _vsscanf_l<br>HYPRE.lib(mmio.c.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf<br>HYPRE.lib(mmio.c.obj) : error LNK2019: unresolved external symbol __imp_fgets referenced in function hypre_mm_read_banner<br>HYPRE.lib(mmio.c.obj) : error LNK2019: unresolved external symbol __imp_tolower referenced in function hypre_mm_read_banner<br>C:\cygwin64\tmp\PE0681~1\CONFIG~1.LIB\conftest.exe : fatal error LNK1120: 7 unresolved externals<br>icx: error: linker command failed with exit code 1120 (use -v to see invocation)<br>Possible ERROR while running linker: exit code 96<br>[more warnings etc]</div><div><br></div><div><br></div><div>-------------------------</div><div><br></div><div>I've looked at the oneapi compiler documentation, and it seems like "nodefaultlib", "nostdlib", etc, options only work for linux versions of the compiler,</div><div>so I'm not sure what to do about the first warning. From the errors, it looks like some core c or c++ library that hypre depends on isn't visible. I had some similar</div><div>issues with ptscotch - but in that case I didn't have the warnings, and the errors gave me the names of libraries that were missing, which I lilnked in using the --cflags</div><div>option (maybe --cc-linker-flags would have been neater, but it worked. I've tried both in order to try to get the above working).</div><div><br></div><div><br></div><div>I can go into detail about the compile and linker commands if needed; I'd have to explain more about my choices for --cflags, etc too. I wonder if any of the above output</div><div>shines any light on the hypre-is-shared-library hypothesis.</div><div><br></div><div><br></div><div>Thanks,</div><div><br></div><div>Daniel<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 19, 2023 at 4:58 PM Satish Balay via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I think it should work with static libraries and 64bit compilers.<br>
<br>
That's how I think --download-f2cblaslapack [etc] work.<br>
<br>
Also it works with MS-MPI - even-though its a dll install, the library stub provides this symbol somehow..<br>
<br>
balay@ps5 /cygdrive/c/Program Files (x86)/Microsoft SDKs/MPI/Lib/x64<br>
$ nm -Ao msmpi.lib |grep " MPI_Init"<br>
msmpi.lib:msmpi.dll:0000000000000000 T MPI_Init<br>
msmpi.lib:msmpi.dll:0000000000000000 T MPI_Init_thread<br>
msmpi.lib:msmpi.dll:0000000000000000 T MPI_Initialized<br>
<br>
However - if the library symbol is somehow mangled - this configure mode of checking library functions will fail.<br>
<br>
Checking PETSc dll build:<br>
<br>
balay@ps5 ~/petsc/arch-ci-mswin-uni/lib<br>
$ nm -Ao libpetsc.lib |grep MatCreateSeqAIJWithArrays<br>
libpetsc.lib:libpetsc.dll:0000000000000000 I __imp_MatCreateSeqAIJWithArrays<br>
libpetsc.lib:libpetsc.dll:0000000000000000 T MatCreateSeqAIJWithArrays<br>
<br>
It also has the unmangled symbol - so I guess this mode can work generally with dlls.<br>
<br>
Satish<br>
<br>
<br>
On Wed, 19 Jul 2023, Barry Smith wrote:<br>
<br>
> <br>
> Satish,<br>
> <br>
> So it will always fail on Windows with Windows compilers (both with static and shared libraries)? Is this true for all PETSc external packages? If so, why does the installation documentation say that some external packages can work with Windows compilers? (Presumably PETSc cannot since the configure tests will fail).<br>
> <br>
> Barry<br>
> <br>
> <br>
> > On Jul 19, 2023, at 11:40 AM, Satish Balay <<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>> wrote:<br>
> > <br>
> > BTW: Some explanation of configure:<br>
> > <br>
> > It attempts the following on linux:<br>
> > <br>
> >>>>>>> <br>
> > Source:<br>
> > #include "confdefs.h"<br>
> > #include "conffix.h"<br>
> > /* Override any gcc2 internal prototype to avoid an error. */<br>
> > char HYPRE_IJMatrixCreate();<br>
> > static void _check_HYPRE_IJMatrixCreate() { HYPRE_IJMatrixCreate(); }<br>
> > <br>
> > int main(void) {<br>
> > _check_HYPRE_IJMatrixCreate();<br>
> > return 0;<br>
> > }<br>
> > <<<<<<<<br>
> > <br>
> > Note - it does not include 'HYPRE.h' here - but redefines the prototype as 'char HYPRE_IJMatrixCreate();<br>
> > <br>
> > Compiling it manually:<br>
> > <br>
> >>>>> <br>
> > [balay@pj01 petsc]$ cat conftest.c<br>
> > char HYPRE_IJMatrixCreate();<br>
> > static void _check_HYPRE_IJMatrixCreate() { HYPRE_IJMatrixCreate(); }<br>
> > <br>
> > int main(void) {<br>
> > _check_HYPRE_IJMatrixCreate();<br>
> > return 0;<br>
> > }<br>
> > [balay@pj01 petsc]$ gcc -c conftest.c<br>
> > [balay@pj01 petsc]$ nm -Ao conftest.o |grep HYPRE_IJMatrixCreate<br>
> > conftest.o:0000000000000000 t _check_HYPRE_IJMatrixCreate<br>
> > conftest.o: U HYPRE_IJMatrixCreate<br>
> > [balay@pj01 petsc]$ nm -Ao arch-linux-c-debug/lib/libHYPRE.so |grep HYPRE_IJMatrixCreate<br>
> > arch-linux-c-debug/lib/libHYPRE.so:000000000007f2c2 T HYPRE_IJMatrixCreate<br>
> > [balay@pj01 petsc]$ <br>
> > <<<<<br>
> > <br>
> > Here the "U HYPRE_IJMatrixCreate" in conftest.o matches "T HYPRE_IJMatrixCreate" in libHYPRE.so - so the "link" test in configure succeeds!<br>
> > <br>
> >>>>>>> <br>
> > [balay@pj01 petsc]$ gcc -o conftest conftest.o arch-linux-c-debug/lib/libHYPRE.so<br>
> > [balay@pj01 petsc]$ echo $?<br>
> > 0<br>
> > <<<<<<br>
> > <br>
> > On windows - [due to name mangling by cdecl/stdcall, (/MT vs /MD) etc..] - this might not match - resulting in link failures.<br>
> > <br>
> > Satish<br>
> > <br>
> > <br>
> > On Wed, 19 Jul 2023, Satish Balay via petsc-users wrote:<br>
> > <br>
> >> You could try skipping this test [and assume --with-hypre-include and --with-hypre-lib options are correct] - and see if this works.<br>
> >> <br>
> >> diff --git a/config/BuildSystem/config/packages/hypre.py b/config/BuildSystem/config/packages/hypre.py<br>
> >> index 5bc88322aa2..2d6c7932e17 100644<br>
> >> --- a/config/BuildSystem/config/packages/hypre.py<br>
> >> +++ b/config/BuildSystem/config/packages/hypre.py<br>
> >> @@ -11,7 +11,7 @@ class Configure(config.package.GNUPackage):<br>
> >> self.requiresversion = 1<br>
> >> self.gitcommit = 'v'+self.version<br>
> >> self.download = ['git://<a href="https://github.com/hypre-space/hypre" rel="noreferrer" target="_blank">https://github.com/hypre-space/hypre</a>','<a href="https://github.com/hypre-space/hypre/archive/'+self.gitcommit+'.tar.gz" rel="noreferrer" target="_blank">https://github.com/hypre-space/hypre/archive/'+self.gitcommit+'.tar.gz</a>']<br>
> >> - self.functions = ['HYPRE_IJMatrixCreate']<br>
> >> + self.functions = []<br>
> >> self.includes = ['HYPRE.h']<br>
> >> self.liblist = [['libHYPRE.a']]<br>
> >> self.buildLanguages = ['C','Cxx']<br>
> >> <br>
> >> <br>
> >> Satish<br>
> >> <br>
> >> <br>
> >> On Wed, 19 Jul 2023, Barry Smith wrote:<br>
> >> <br>
> >>> <br>
> >>> You don't indicate what type of libraries you built hypre with; static or shared. My guess is you ended up with shared<br>
> >>> <br>
> >>> I think the answer to your difficulty is hidden in __cdecl (Satish will know much better than me). When you are looking for symbols in Windows shared libraries you have to prepend something to the function prototype to have it successfully found. For example the PETSc include files have these things __declspec(dllimport) The configure test fails because it does not provide the needed prototype. Likely you built PTScotch with static libraries so no problem.<br>
> >>> <br>
> >>> The simplest fix would be to build static hypre libraries. I think it is a major project to get PETSc configure and macro system to work properly with external packages that are in Windows shared libraries since more use of __declspec would be needed.<br>
> >>> <br>
> >>> Barry<br>
> >>> <br>
> >>> The PETSc installation instructions should probably say something about external packages with Windows shared libraries.<br>
> >>> <br>
> >>> <br>
> >>> <br>
> >>> <br>
> >>> <br>
> >>> <br>
> >>> <br>
> >>>> On Jul 19, 2023, at 10:52 AM, Daniel Stone <<a href="mailto:daniel.stone@opengosim.com" target="_blank">daniel.stone@opengosim.com</a>> wrote:<br>
> >>>> <br>
> >>>> Hello,<br>
> >>>> <br>
> >>>> I'm working on getting a petsc build running on windows. One necessary package to include is Hypre. I've been able to build Hypre seperately using cmake, and confirmed that the library works<br>
> >>>> by setting up a VS project to run some of the example programs.<br>
> >>>> <br>
> >>>> My attempted petsc build is being done through cygwin. I've been able to (with varying degrees of difficulty), build a fairly plain petsc, and one that downloads and builds ptscotch (after some modifications<br>
> >>>> to both ptscotch and the config script). I am now attempting to include Hypre (using the --hypre-iclude and --hypre-lib flags, etc). Note that the same compilers are being used for both Hypre and for petsc<br>
> >>>> through cygwin - the new intel oneapi compilers (icx and ifx, after again varying amounts of pain to work around their awkwardness with the config script).<br>
> >>>> <br>
> >>>> I'm seeing a problem when the config script does some tests on the included hypre lib. The source code looks like:<br>
> >>>> <br>
> >>>> #include "confdefs.h"<br>
> >>>> #include "conffix.h"<br>
> >>>> /* Override any gcc2 internal prototype to avoid an error. */<br>
> >>>> <br>
> >>>> #include "HYPRE.h"<br>
> >>>> <br>
> >>>> char HYPRE_IJMatrixCreate();<br>
> >>>> static void _check_HYPRE_IJMatrixCreate() { HYPRE_IJMatrixCreate(); }<br>
> >>>> <br>
> >>>> int main() {<br>
> >>>> _check_HYPRE_IJMatrixCreate();;<br>
> >>>> return 0;<br>
> >>>> }<br>
> >>>> <br>
> >>>> <br>
> >>>> As I understand this is a fairly standard type of stub program used by the config script to check that it is able to link to certain symbols in given libraries. Tests like this have succeeded in my builds that<br>
> >>>> include PTScotch.<br>
> >>>> <br>
> >>>> I keep getting a linker error with the above test, including if I seperate it out and try to build it seperately:<br>
> >>>> <br>
> >>>> unresolved external symbol "char __cdel HYPRE_IJMatrixCreate(void)" ....<br>
> >>>> <br>
> >>>> Ok, it looks like a problem with either the library or linker commands. But here's the interesting thing - If I transplant this code into VS, with the same project setting that allows it to build the much more <br>
> >>>> nontrivial Hypre example programs, I get the same error:<br>
> >>>> <br>
> >>>> Error LNK2001 unresolved external symbol "char __cdecl HYPRE_IJMatrixCreate(void)" (?HYPRE_IJMatrixCreate@@YADXZ) hypretry1 C:\Users\DanielOGS\source\repos\hypretry1\hypretry1\Source.obj 1<br>
> >>>> <br>
> >>>> So it seems like there might be something about this type of stub program that is not working with my Hypre library. I don't fully understand this program - it's able to call the function with no arguments, but<br>
> >>>> it also needs to be linked against a library containing the function, apparently by wrapping it in a static void function? Not something I've seen before. <br>
> >>>> <br>
> >>>> Does anyone have any insight into what might be going wrong - or really just any explaination of how the stub program works so I can figure out why it isn't in this case?<br>
> >>>> <br>
> >>>> Many thanks,<br>
> >>>> <br>
> >>>> Daniel<br>
> >>> <br>
> >>> <br>
> >> <br>
> > <br>
> <br>
<br>
</blockquote></div>