[英]Is there a Linux equivalent of DllImport in .NET Core?
I am working on a .NET Core project.我正在处理一个 .NET Core 项目。 This should run on Linux without problems.
这应该在 Linux 上运行没有问题。 However, I need to call a library that has been created with C++.
但是,我需要调用一个用 C++ 创建的库。 Traditionally, C# developers do this with DllImport&DllExport .
传统上,C# 开发人员使用DllImport&DllExport执行此 操作。
However, I do not want to import or export dll's in a production environment.但是,我不想在生产环境中导入或导出 dll。 Over there it needs to run on Linux.
在那里,它需要在 Linux 上运行。 Is there a Linux equivalent of DllImport/DllExport?
是否有 Linux 等效的 DllImport/DllExport? On Linux, so files are used instead of dll files .
在 Linux 上,因此使用文件而不是 dll 文件。 I am not smart when it comes to low level things so I look for a quick solution and a clear example.
当涉及到低级别的事情时,我并不聪明,所以我寻找一个快速的解决方案和一个明确的例子。 Something like an "SoImport"?
像“SoImport”这样的东西?
You can use .so file also in DllImport.您也可以在 DllImport 中使用 .so 文件。
[DllImport ("libc.so")]
private static extern int getpid ();
From the dlopen(3) man page, the necessary shared libraries needed by the program are searched for in the following order:从 dlopen(3) 手册页,按以下顺序搜索程序所需的必要共享库:
More details can be found here library handling可以在此处找到更多详细信息库处理
edit:编辑:
DllImport will fail if libc.so
contains any unresolved symbols.如果
libc.so
包含任何未解析的符号,则 DllImport 将失败。 Please verify with请与
ldd -r -d libc.so
and make sure no unresolved symbols are present there.并确保那里没有未解析的符号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.