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

cmake built error in static win msvc intel due linking static.lib : wrongname and cant linking mkl when create #895

Closed
realbabilu opened this issue Feb 1, 2025 · 12 comments
Assignees

Comments

@realbabilu
Copy link

realbabilu commented Feb 1, 2025

Describe the bug
Microsoft (R) Program Maintenance Utility Version 14.42.34436.0
Copyright (C) Microsoft Corporation. All rights reserved.

[ 0%] Built target SuiteSparseConfig
[ 1%] Built target SuiteSparseConfig_static
NMAKE : fatal error U1073: don't know how to make 'SuiteSparse_config\suitesparseconfig.lib'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\nmake.exe" -s -f AMD\CMakeFiles\AMD.dir\build.make /nologo -SL AMD\CMakeFiles\AMD.dir\build' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\nmake.exe" -s -f CMakeFiles\Makefile2 /nologo -S all' : return code '0x2'
Stop.
;
it should be 'SuiteSparse_config\suitesparseconfig.lib' SuiteSparse_config\suitesparseconfig._static.lib'
To Reproduce
Steps to reproduce the behavior.
cmake -G "NMake Makefiles" -DBLA_VENDOR=Intel10_64lp -DCMAKE_BUILD_TYPE=RELEASE -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;umfpack" -DCHOLMOD_PARTITION=OFF -DBUILD_STATIC_LIBS=ON -DSUITESPARSE_USE_FORTRAN=on .. -DCMAKE_CXX_COMPILER=icx.exe

Expected behavior
A clear and concise description of what you expected to happen.
in build.make in AMD.dir should be

AMD\amd.dll: SuiteSparse_config\suitesparseconfig_static.lib

\cmake.exe" -E vs_link_dll --intdir=CMakeFiles\AMD.dir --rc=C:\PROGRA2\WI3CF21\10\bin\1002261.0\x64\rc.exe --mt=C:\PROGRA2\WI3CF21\10\bin\1002261.0\x64\mt.exe --manifests -- C:\PROGRA1\MIB0551\2022\PROFES1\VC\Tools\MSVC\14421.344\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\AMD.dir\objects1.rsp @<<
/out:amd.dll /implib:amd.lib /pdb:C:\fortran\SuiteSparse\Build\AMD\amd.pdb /dll /version:3.3 /machine:x64 /INCREMENTAL:NO /Qoption,link,/DEF:CMakeFiles\AMD.dir\exports.def ..\SuiteSparse_config\suitesparseconfig_static.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib

not suitesparseconfig.lib

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] win11
  • compiler [e.g. gcc 7.4, icc 19.0] oneapi 2025
  • BLAS and LAPACK library, if applicable intel_64lp
  • Version [e.g. 22] 2025 i guess

Additional context
Add any other context about the problem here.
colamd,ccolamd,camd also affected.
just edit manually in each build.make for temporary solution. cmake bug?

in cholmod should be

CHOLMOD\cholmod.dll: AMD\amd_static.lib
CHOLMOD\cholmod.dll: COLAMD\colamd_static.lib
CHOLMOD\cholmod.dll: CAMD\camd_static.lib
CHOLMOD\cholmod.dll: CCOLAMD\ccolamd_static.lib

then in cholmod_di_demo
cholmod_static.lib
CHOLMOD\cholmod.dll: AMD\amd_static.lib
CHOLMOD\cholmod.dll: COLAMD\colamd_static.lib
CHOLMOD\cholmod.dll: CAMD\camd_static.lib
CHOLMOD\cholmod.dll: CCOLAMD\ccolamd_static.lib

---if fixed then,,, when linking
Microsoft (R) Program Maintenance Utility Version 14.42.34436.0
Copyright (C) Microsoft Corporation. All rights reserved.

[ 1%] Built target SuiteSparseConfig
[ 1%] Built target SuiteSparseConfig_static
[ 2%] Built target AMD
[ 4%] Built target AMD_static
[ 6%] Built target CAMD
[ 8%] Built target CAMD_static
[ 8%] Built target CCOLAMD
[ 8%] Built target CCOLAMD_static
[ 9%] Built target COLAMD
[ 9%] Built target COLAMD_static
[ 24%] Built target CHOLMOD
[ 38%] Built target CHOLMOD_static
[ 38%] Linking C executable cholmod_di_demo.exe
LINK: command "C:\PROGRA1\MIB0551\2022\PROFES1\VC\Tools\MSVC\14421.344\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cholmod_di_demo.dir\objects1.rsp /out:cholmod_di_demo.exe /implib:cholmod_di_demo.lib /pdb:C:\fortran\SuiteSparse\Build\CHOLMOD\cholmod_di_demo.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console cholmod_static.lib ..\AMD\amd_static.lib ..\COLAMD\colamd_static.lib ..\CAMD\camd_static.lib ..\CCOLAMD\ccolamd_static.lib ..\SuiteSparse_config\suitesparseconfig_static.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=1" failed (exit code 1120) with the following output:
cholmod_static.lib(cholmod_super_numeric.c.obj) : error LNK2019: unresolved external symbol DTRSM referenced in function rd_cholmod_super_numeric_worker

looks like not see intel mkl ??
eventhough cmake config see..
-- Looking for 32-BLAS: Intel10_64lp
-- Found Intel10_64lp 32-bit BLAS
-- Specific BLAS: Intel10_64lp found: TRUE
-- BLAS integer size: 4

@realbabilu realbabilu changed the title cmake built error in static win msvc intel due linking suitesparse_static.lib cmake built error in static win msvc intel due linking static.lib : wrongname and cant linking mkl when create Feb 1, 2025
@mmuetzel
Copy link
Contributor

mmuetzel commented Feb 2, 2025

Thank you for your report.

Which version of CMake do you use?
Could you please check what CMAKE_C_SIMULATE_ID is for your compiler?

mmuetzel added a commit to mmuetzel/SuiteSparse that referenced this issue Feb 3, 2025
MSVC-like compilers use the same default suffix for static libraries and
import libraries.
Instead of checking whether a compiler is MSVC or simulates it, directly
check whether these default suffices clash.

That potentially fixes issue DrTimothyAldenDavis#895. (And even in case it does not, the
updated condition is much more to the point.
@mmuetzel
Copy link
Contributor

mmuetzel commented Feb 3, 2025

See #896 for a potential fix.

@realbabilu: Does that change avoid the issue for you?

@realbabilu
Copy link
Author

Thank you for your report.

Which version of CMake do you use? Could you please check what CMAKE_C_SIMULATE_ID is for your compiler?

C:\Program Files (x86)\Intel\oneAPI>cmake --version
cmake version 3.29.5-msvc4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

@realbabilu
Copy link
Author

realbabilu commented Feb 4, 2025

See #896 for a potential fix.

@realbabilu: Does that change avoid the issue for you?

no. one way around is edit manually the build.make inside cmakefiles
cd\build

cmake -G "NMake Makefiles" -DBLA_VENDOR=Intel10_64lp -DCMAKE_BUILD_TYPE=RELEASE -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;umfpack" -DCHOLMOD_PARTITION=OFF -DBUILD_STATIC_LIBS=ON -DSUITESPARSE_USE_FORTRAN=on .. -DCMAKE_CXX_COMPILER=icx.exe -DCMAKE_C_SIMULATE_ID=MSVC

nmake

...
[ 2%] Building C object AMD/CMakeFiles/AMD.dir/Source/amd_postorder.c.obj
amd_postorder.c
[ 2%] Building C object AMD/CMakeFiles/AMD.dir/Source/amd_preprocess.c.obj
amd_preprocess.c
[ 3%] Building C object AMD/CMakeFiles/AMD.dir/Source/amd_valid.c.obj
amd_valid.c
[ 3%] Building C object AMD/CMakeFiles/AMD.dir/Source/amd_version.c.obj
amd_version.c
[ 3%] Building Fortran object AMD/CMakeFiles/AMD.dir/Source/amdbar.f.obj
NMAKE : fatal error U1073: don't know how to make 'SuiteSparse_config\suitesparseconfig.lib'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\nmake.exe" -s -f AMD\CMakeFiles\AMD.dir\build.make /nologo -SL AMD\CMakeFiles\AMD.dir\build' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\nmake.exe" -s -f CMakeFiles\Makefile2 /nologo -S all' : return code '0x2'
Stop.

@mmuetzel
Copy link
Contributor

mmuetzel commented Feb 4, 2025

@realbabilu: Thank you for providing that information.

I'm not entirely sure what the error don't know how to make 'SuiteSparse_config\suitesparseconfig.lib' is supposed to indicate. suitesparseconfig.lib is the name of the import library corresponding to suitesparseconfig.dll.

Could you please check if you still see this error with a different CMake generator? E.g., could you please test the following:

cmake --fresh -GNinja -DBLA_VENDOR=Intel10_64lp -DCMAKE_BUILD_TYPE=RELEASE -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;umfpack" -DCHOLMOD_PARTITION=OFF -DBUILD_STATIC_LIBS=ON -DSUITESPARSE_USE_FORTRAN=on .. -DCMAKE_CXX_COMPILER=icx.exe
cmake --build .

@realbabilu
Copy link
Author

cmake --fresh -GNinja -DBLA_VENDOR=Intel10_64lp -DCMAKE_BUILD_TYPE=RELEASE -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;umfpack" -DCHOLMOD_PARTITION=OFF -DBUILD_STATIC_LIBS=ON -DSUITESPARSE_USE_FORTRAN=on .. -DCMAKE_CXX_COMPILER=icx.exe
cmake --build

woah no problem here. eventhough i just only changed cmakelist.txt of sparsesuite.config,amd,camd,colamd,ccolamd,cholmod,umfpack. ninja rocks

C:\fortran\SuiteSparse\build>ninja
[1246/1246] Linking C shared library UMFPACK\umfpack.dll

C:\fortran\SuiteSparse\build>dir

@mmuetzel
Copy link
Contributor

mmuetzel commented Feb 4, 2025

Thank you for reporting back.

Yeah, I prefer Ninja over any of the other generators. Especially on Windows.

If it's working with Ninja but not with NMake, I'd be inclined to say that it is an issue with the NMake generator of CMake or with NMake itself. Either way, it's probably not an issue in the build rules of SuiteSparse.

In any case, it is good to know that NMake might be having this issue. 👍

@mmuetzel
Copy link
Contributor

mmuetzel commented Feb 5, 2025

@realbabilu: I forgot to ask: Did you run your test using the Ninja generator with the original CMakeLists.txt files? Or with the ones including the changes from #896?

@realbabilu
Copy link
Author

realbabilu commented Feb 5, 2025

Yesterday was ok with new Cmakefiles.txt
Today is ok also with stable old Cmakefiles.txt
So it can be closed.

How to get compile demo in umfpack with cmake?
ok got it.
cmake --fresh -GNinja -DBLA_VENDOR=Intel10_64lp -DCMAKE_BUILD_TYPE=RELEASE -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;umfpack" -DCHOLMOD_PARTITION=OFF -DBUILD_STATIC_LIBS=ON -DSUITESPARSE_USE_FORTRAN=on .. -DCMAKE_CXX_COMPILER=icx.exe -DSUITESPARSE_HAS_FORTRAN=on -DSUITESPARSE_HAS_FORTRAN=on -DSUITESPARSE_DEMOS=on

@realbabilu
Copy link
Author

realbabilu commented Feb 6, 2025

just asking. why the resulting static_lib is cant direct linked, it need /MD slash in compile which means /MD[d] = use dynamically-loaded, multithread C runtime, but no dll is required to run.

without /MD
ifx umf4hb.f umf4_f77wrapper.obj ....\lib\amd_static.lib ....\lib\umfpack_static.lib ....\lib\colamd_static.lib....\lib\suitesparseconfig_static.lib ....\lib\cholmod_static.lib /Qmkl

Microsoft (R) Incremental Linker Version 14.41.34120.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:umf4hb.exe 
-subsystem:console 
-libpath:F:\Intel\oneAPI\mkl\latest\lib 
umf4hb.obj 
umf4_f77wrapper.obj 
..\..\lib\amd_static.lib 
..\..\lib\umfpack_static.lib 
..\..\lib\colamd_static.lib 
..\..\lib\suitesparseconfig_static.lib 
..\..\lib\cholmod_static.lib 
libmmd.lib(libmmd.dll) : error LNK2005: hypot already defined in libmmt.lib(hypot_iface_c99.obj)
umfpack_static.lib(umfpack_di_load_numeric.c.obj) : error LNK2019: unresolved external symbol __imp_fread referenced in function umfpack_di_load_numeric
umfpack_static.lib(umfpack_di_load_symbolic.c.obj) : error LNK2001: unresolved external symbol __imp_fread
umfpack_static.lib(umfpack_di_load_numeric.c.obj) : error LNK2019: unresolved external symbol __imp_ferror referenced in function umfpack_di_load_numeric
umfpack_static.lib(umfpack_di_load_symbolic.c.obj) : error LNK2001: unresolved external symbol __imp_ferror
umf4hb.exe : fatal error LNK1120: 2 unresolved externals

so
ifx umf4hb.f umf4_f77wrapper.obj ....\lib\amd_static.lib ....\lib\umfpack_static.lib ....\lib\colamd_static.lib....\lib\suitesparseconfig_static.lib ....\lib\cholmod_static.lib /Qmkl /MD
then no error.

second, can umfpack can eat directly rectangular B matrix or right hand side matrix, instead per column.

@mmuetzel
Copy link
Contributor

mmuetzel commented Feb 6, 2025

just asking. why the resulting static_lib is cant direct linked, it need /MD slash in compile which means /MD[d] = use dynamically-loaded, multithread C runtime, but no dll is required to run.

See: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html#variable:CMAKE_MSVC_RUNTIME_LIBRARY

@realbabilu
Copy link
Author

cmake --fresh -GNinja -DBLA_VENDOR=Intel10_64lp -DCMAKE_BUILD_TYPE=RELEASE -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;umfpack" -DCHOLMOD_PARTITION=OFF -DBUILD_STATIC_LIBS=ON -DSUITESPARSE_USE_FORTRAN=on .. -DCMAKE_CXX_COMPILER=icx.exe -DSUITESPARSE_HAS_FORTRAN=on -DSUITESPARSE_HAS_FORTRAN=on -DSUITESPARSE_DEMOS=on -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded

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

No branches or pull requests

3 participants