引用 C++/CLI .exe 项目时出现链接错误
我正在使用 VS2010,在我的解决方案中,我的 C++/CLI 项目之一引用了另一个项目。但只有当引用的项目被编译为静态库时,它才能正确链接。
我在托管 .NET 语言中阅读了所有内容,.EXE、库和 .dll 是同一件事,只有一个标志或类似的东西作为区别。像这样,我无法弄清楚为什么我有所有这些链接错误,因为我如何编译我的项目并不重要。
好吧,也许我假设有什么问题。如果是这样,我如何在其他 .exe 项目中引用 .exe 项目,以便我可以使用相同的类和方法,而无需重新编译它。
提前致谢,
西奥
I'm using VS2010 and in my solution one of my C++/CLI projects references the other. But it can only link correctly when the project being referenced is compiled as a Static Lib.
I read all over that in managed .NET languages, .EXEs, libs and .dlls are the same thing, with a single flag or something like that as difference. Being like that, I can't figure out why I have all these linking errors, since it shouldn't matter how I compile my project.
Well, probably I'm assuming something wrong. If so, how can I reference a .exe project in an other .exe project so I can use the same classes and methods without having to recompile it.
Thanks in advance,
Theo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然引用 EXE 项目并在运行时加载它(就像它是 DLL 一样)对于纯托管代码来说是可以的,但这对于 C++/CLI 项目来说效果不佳。 CRT 将无法正确初始化,没有可运行的 DllMain() 入口点。
您需要创建一个 DLL,使用 CLR 类库项目模板。
之后您会遇到什么编译或链接错误可能是次要的。确保在下一个问题中引用它们,错误消息旨在告诉您出了什么问题。
While referencing an EXE project and loading it at runtime as though it were a DLL is okay for pure managed code, that is not going to work out well for a C++/CLI project. The CRT won't be initialized correctly, there is no DllMain() entry point that will run.
You'll need to create a DLL, use the CLR Class Library project template.
What ever compile or link errors you'll get after that might be secondary. Make sure you quote them in your next question, error messages were designed to tell you what is wrong.
右键单击您的项目并在菜单中选择“添加引用...”。
PS:你能显示链接器错误消息吗?
Right click on your project and choose "Add reference..." in the menu.
PS: can you show the linker error messages?