问题描述
大家好
我在CP上发现了一篇非常有趣的文章: []
效果令人惊叹,我真的希望能够在C#应用程序中使用它们我正在做(关于表格,我应该考虑)。只是为了好玩,真的 - 因为我喜欢这些效果...
AFAIK,可以将C ++代码编译成dll并在C#项目中使用它,但我从来没有真正尝试过它。
我开始想:到底怎么样,C ++与C#有多么不同?当然,必须有可能找到如何做到这一点,而不必学习一种全新的(旧的)语言...... - 我错了! C ++令人困惑,包含所有不同的文件和内容。我离开了我的联盟。
有些C ++可以指出我正确的方向吗?如何将C ++代码编译为可以在C#项目中使用的DLL?
我尝试将所有文件添加到Win32项目中,我设法我自己解决了一些简单的问题(方法重载),但是当我现在编译时,我只得到:
错误LNK1169:找到一个或多个多重定义的符号c: \users\johnny \Documents\_Visual Studio Projects\VisualSfx \Debug \ VisualSfx.dll 1 1 VisualSfx
和
错误LNK2005:_DllMain @ 12已经在MSVCRTD.lib(dllmain.obj)中定义了c:\ Users \ Johnhn\Documents\_Visual Studio Projects \ VisualSfx \\ \\ VisualSfx \ mfcs120ud.lib(dllmodul.obj)VisualSfx
如何解决?
Hi all
I found a very interesting article here on CP: Really cool visual FX[^]
The effects are stunning, and I would REALLY like to be able to use them in a C# application I'm doing (for the About form, I should think). Just for fun, really - and because I like the effects...
AFAIK, it's possible to compile C++ code to a dll and use it in a C# project, but I have never actually tried it.
I started out thinking: "What the hell, how different can C++ be from C#? Surely, it must be possible to find out how to do it without having to learn an entirely new (old) language..." - I WAS WRONG! C++ is so f***ing confusing, with all the diffent files and stuff. I'm way out of my league.
Can some C++ wiz please point me in the right direction? How do I compile the C++ code to a dll that can be used in a C# project?
I tried adding all the files to a Win32 project, and I managed to resolve a few simple issues myself (method overloading), but when I compile now, I only get:
"error LNK1169: one or more multiply defined symbols foundc:\users\johnny\Documents\_Visual Studio Projects\VisualSfx\Debug\VisualSfx.dll11VisualSfx"
and
"error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)c:\Users\Johnny\Documents\_Visual Studio Projects\VisualSfx\VisualSfx\mfcs120ud.lib(dllmodul.obj)VisualSfx"
How do I resolve that?
推荐答案
这篇关于在C#应用程序中使用C ++代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!