I have a problem during linking my umat() procedure written in C++. I am using Windows 10, Abaqus 2022 and Microsoft Visual Studio 2022 Community (compiler cl version 19.36.32537 for x64). Compilation completes fine but the linker aborts with the following error messages.
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_initialize referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_uninitialize referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_uninitialize_critical referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_thread_attach referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __vcrt_thread_detach referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _is_c_termination_complete referenced in function __scrt_dllmain_uninitialize_c
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_initialize referenced in function __scrt_initialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize referenced in function __scrt_uninitialize_crt
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize_critical referenced in function __scrt_dllmain_uninitialize_critical
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_attach referenced in function __scrt_dllmain_crt_thread_attach
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_detach referenced in function __scrt_dllmain_crt_thread_detach
standardU.dll : fatal error LNK1120: 11 unresolved externals
Abaqus Error: Problem during linking - Abaqus/Standard User Subroutines.
This error may be due to a mismatch in the Abaqus user subroutine arguments.
These arguments sometimes change from release to release, so user subroutines
used with a previous release of Abaqus may need to be adjusted.
Abaqus/Analysis exited with errors
Passing /verbose:lib into the linker's options reports that the mentioned msvcrt.lib is taken from "E:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\lib\x64\msvcrt.lib". This path looks like OK for me.
The compiler and linker are called via Abaqus Commands' terminal with the following options (specified in "E:\SIMULIA\EstProducts\2022\win_b64\SMA\site\win86_64.env").
compile_cpp=['cl', '/c', '/W0', '/MD', '/TP',
'/EHsc', '/DNDEBUG', '/DWIN32', '/DTP_IP', '/D_CONSOLE',
'/DNTI', '/DFLT_LIC', '/DOL_DOC', '/D__LIB__', '/DHKS_NT',
'/D_WINDOWS_SOURCE', '/DFAR=', '/D_WINDOWS', '/DABQ_WIN86_64', '/std:c++20', '%P',
'/O1', # <-- Optimization
# '/Zi', # <-- Debug symbols
'/I%I', '/I'+abaHomeInc]
...
link_sl=['LINK',
'/verbose:lib',
'/nologo', '/NOENTRY', '/INCREMENTAL:NO', '/subsystem:console', '/machine:AMD64',
'/NODEFAULTLIB:LIBC.LIB', '/NODEFAULTLIB:LIBCMT.LIB',
'/DEFAULTLIB:OLDNAMES.LIB', '/DEFAULTLIB:LIBIFCOREMD.LIB', '/DEFAULTLIB:LIBIFPORTMD.LIB', '/DEFAULTLIB:LIBMMD.LIB',
'/DEFAULTLIB:kernel32.lib', '/DEFAULTLIB:user32.lib', '/DEFAULTLIB:advapi32.lib',
'/FIXED:NO', '/dll',
#'/debug', # <-- Debugging
'/def:%E', '/out:%U', '%F', '%A', '%L', '%B',
'oldnames.lib', 'user32.lib', 'ws2_32.lib', 'netapi32.lib',
'advapi32.lib', 'msvcrt.lib', 'vcruntime.lib', 'ucrt.lib']
Is there a way to fix the above problems (or, perhaps, am I misunderstood something)? I am hope for your help.
The errors occur particularly when I am trying to construct an object as static one within the umat() body. There are no such problems with initializing static primitive types or non-static objects; jobs run and finish almost fine in their cases (except for warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators).
Update. I've created a minimalistic main.cpp file to reproduce the same errors independently on Abaqus.
class C {
public:
C() {};
~C() {};
int i = 0;
};
int main() {
static C c; // removing "static" produces no errors
return 0;
}
I've also prepared a .bat file to compile and link main.cpp with the required above-specified options:
call "e:\Intel\OneAPI\setvars.bat"
call "e:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\cl.exe" /c /W0 /MD /TP /EHsc /DNDEBUG /DWIN32 /DTP_IP /D_CONSOLE /DNTI /DFLT_LIC /DOL_DOC /D__LIB__ /DHKS_NT /D_WINDOWS_SOURCE /DFAR= /D_WINDOWS /DABQ_WIN86_64 /std:c++20 main.cpp /O1
call "e:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\link.exe" /verbose:lib /nologo /NOENTRY /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC.LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /out:test.dll main.obj oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib msvcrt.lib vcruntime.lib ucrt.lib
Executing it leads to the same LNK2019 errors. I've also found that removing /NOENTRY from the linker's options allows it to finish without problems. However, doing so in the Abaqus-provided .env-file leads to an error in the resulting .dll: standardU.dll : fatal error LNK1169: one or more multiply defined symbols found. I have no idea how it can be fixed and appreciate any hints.