[英]Is it possible to compile C++ that's using a .NET DLL with GCC?
I want to use the AML.Engine.dll ( https://github.com/AutomationML/AMLEngine2.1 ) in a C++ project.我想在 C++ 项目中使用 AML.Engine.dll ( https://github.com/AutomationML/AMLEngine2.1 )。 I have gotten it to work with the Microsoft C++ Compiler, but also need it to work with GCC but couldn't do so yet.
我已经让它与 Microsoft C++ 编译器一起工作,但还需要它与 GCC 一起工作,但还不能这样做。 Are there any compiler settings necessary to do so?
是否有必要的编译器设置? Or is it just not possible with GCC?
还是 GCC 不可能?
The code below shows a simple demo project that I tried to get to work.下面的代码显示了一个我尝试开始工作的简单演示项目。
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#using <AML.Engine.dll>
#using <System.dll>
#using <System.Xml.dll>
#using <System.Xml.Linq.dll>
using namespace Aml::Engine::CAEX;
int main()
{
// create a new empty document
auto caexDocument = CAEXDocument::LoadFromFile("BSM_Project_210219_V3.1.aml");
CAEXDocument^ doc = CAEXDocument::New_CAEXDocument();
for each(auto instanceHierachy in caexDocument->CAEXFile->InstanceHierarchy){
for each(auto element in instanceHierachy->InternalElement){
System::Console::WriteLine( element->Name) ;
System::Console::WriteLine( "----------------------------------------------------------") ;
for each(auto ielement in element->InternalElement){
System::Console::WriteLine( ielement->Name) ;
}
}
}
}
There are 3 was to use a random dll in a .NET programm and vice versa.有 3 个是在 .NET 程序中使用随机 dll ,反之亦然。
Option 2 can run into binarity missmatch issues.选项 2 可能会遇到二进制不匹配问题。 Option 3 is almost guaranteed to.
选项 3 几乎可以保证。
It is not really clear if your C++ programm is C++ .NET (a case 1 scenario) or what I call native C++ (wich is any C++ except .NET). It is not really clear if your C++ programm is C++ .NET (a case 1 scenario) or what I call native C++ (wich is any C++ except .NET). By design, .NET/MSIL are source language agnostic.
按照设计,.NET/MSIL 与源语言无关。 It being .NET defines more about the limitations then the language does.
它是 .NET 定义了比语言更多的限制。 I can not tell if the System.Xml.Linq.dll was written in C++ .NET, C#, F# or VB .NET.
I can not tell if the System.Xml.Linq.dll was written in C++ .NET, C#, F# or VB .NET. And I do not need to know to use it.
而且我不需要知道使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.