在 AWS 上调用 lambda 函数时出现 DllNotFoundException libgurobi95

DllNotFoundException libgurobi95 when invoking lambda function on AWS

我有一个使用 OPTANO.Modeling.Gurobi NuGet 包(和 OPTANO.Modeling)的 lambda 函数。

当我 运行 在本地使用 Mock Lambda 测试工具时,代码运行完美,但是当我将它发布到 AWS 并调用它时,它 returns 一个错误,具体取决于我的操作方式.

如果我在 Visual Studio 中通过 'Publish to AWS Lambda...' 发布,我会得到以下信息:

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'gurobi95' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgurobi95: cannot open shared object file: No such file or directory
at Gurobi.GurobiDLL.GRBloadenvadv(IntPtr& env, String logfilename, Int32 apitype, Int32 major, Int32 minor, Int32 tech, String server, String router, String password, String group, Int32 priority, Int32 idletimeout, String cloudid, String cloudkey, cbfunc callback, IntPtr usrdata, logcbfunc logcallback, IntPtr logdata)
at Gurobi.GRBEnv..ctor(String logfilename)
at Gurobi.GRBEnv..ctor()
at OPTANO.Modeling.Optimization.Solver.Gurobi950.GurobiSolver.InitializeEnvironment(GurobiSolverConfiguration configuration)
at OPTANO.Modeling.Optimization.Solver.Gurobi950.GurobiSolver..ctor(GurobiSolverConfiguration configuration)
at Testbed_Primary.Function.FunctionHandler(Boolean writeReportToConsole, Boolean writeWeightsToConsole) in xxxx\Function.cs:line 482
at Testbed_Primary.Function.CalculateStuff() in xxxx\Function.cs:line 118
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
05 May 2022 21:31:49,146 [WARN] (invoke@invoke.c:331 errno: None) run_dotnet(dotnet_path, &args) failed

问题似乎与 gurobi95.dll 有关。有时它会出现在 zip 文件中,有时不会。如果我确保它在 zip 文件中 而不是在 AWS 控制台上使用 'Upload from...' 我得到以下而不是上面的堆栈跟踪。 Cloudwatch 日志组中没有更多详细信息。

Lambda encountered an UnhandledException via 'AppDomain.CurrentDomain.UnhandledException' event:

它似乎发生在代码中的同一点。冒号后面什么都没有。我建议 DLL 有问题,如果使用第一种方法而不是第二种方法上传,AWS 会转储它,如果不是因为它在本地 运行 时工作正常。

我花了很长时间摆弄 DLL 和设置,并搜索有关未找到 DLL 错误的帮助,但我感到困惑。

编辑:将 LD_DEBUG 环境变量设置为 'all cat' 将以下内容输出到 Cloudwatch 日志。我不知道这有助于我诊断问题,因为它似乎没有指示任何错误。我想很多都是无关紧要的。

10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=dotnet [0]
10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZSt8__copy_nIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEmPcET1_T_T0_SC_St26random_access_iterator_tag'
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=dotnet [0]
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZSt4copyIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET0_T_SD_SC_'
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=dotnet [0]
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZSt12__miter_baseIN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEET_SB_'
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=dotnet [0]
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZSt14__copy_move_a2ILb0EN9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEPcET1_T0_SD_SC_'
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=dotnet [0]
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZSt12__niter_baseIPcET_S1_;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZSt12__niter_baseIPcET_S1_'
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=dotnet [0]
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZSt12__niter_baseIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEET_N9__gnu_cxx17__normal_iteratorIS8_T0_EE'
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=dotnet [0]
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZNK9__gnu_cxx17__normal_iteratorIPKcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE4baseEv'
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=dotnet [0]
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZSt13__copy_move_aILb0EPKcPcET1_T0_S4_S3_'
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=dotnet [0]
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=/lib64/libc.so.6 [0]
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=/lib64/ld-linux-x86-64.so.2 [0]
10: symbol=_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_;  lookup in file=/var/runtime/liblambdaruntime.so [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /var/runtime/liblambdaruntime.so [0]: normal symbol `_ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIcEEPT_PKS3_S6_S4_'
10: symbol=memmove;  lookup in file=dotnet [0]
10: symbol=memmove;  lookup in file=/lib64/libpthread.so.0 [0]
10: symbol=memmove;  lookup in file=/lib64/libdl.so.2 [0]
10: symbol=memmove;  lookup in file=/lib64/libstdc++.so.6 [0]
10: symbol=memmove;  lookup in file=/lib64/libm.so.6 [0]
10: symbol=memmove;  lookup in file=/lib64/libgcc_s.so.1 [0]
10: symbol=memmove;  lookup in file=/lib64/libc.so.6 [0]
10: binding file /var/runtime/liblambdaruntime.so [0] to /lib64/libc.so.6 [0]: normal symbol `memmove' [GLIBC_2.2.5]

编辑 2:我已将范围缩小到这行代码,即抛出 DllNotFoundException 的点:

using (GurobiSolver solver = new GurobiSolver())

bin文件夹中有两个文件:libgurobi.so.9.5.0libgurobi95.so。第一个是 41.5MB,我推测包含 Gurobi 运行 次。第二个只是一个包含 ./libgurobi.so.9.5.0.

行的文本文件

这让我“啊哈!”片刻,所以我复制了 libgurobi.so.9.5.0,将其重命名为 libgurobi95.so,并在 zip 文件中用它替换了原始 libgurobi95.so 文件以上传到 AWS。

现在可以了。我不完全理解 为什么 它有效(为什么在 AWS 上 运行ning 与在本地 运行ning 时引用不同?)。这可能与以下事实有关:当我在本地 运行 时,它在 Windows 中 运行ning,但 AWS lambda 在 Linux 中运行 运行(亚马逊 Linux 2), 但我真的不知道。

每次我想更新 lambda 函数时都必须经历那些繁琐的过程,这让我很恼火,但至少它是有效的。