[英]Integrate C++ Win32 Console project classes into Visual C++ (Windows forms application) project in Visual Studio 2008
I have written some classes, the back end of a project in C++ (win32 project) and then wanted to add a GUI to it. 我已经写了一些类,是C ++中一个项目的后端(win32项目),然后想要向其中添加一个GUI。 Visual C++ seemed to be a good solution but after having the GUI part done I couldn't integrate the plain C++ code. Visual C ++似乎是一个很好的解决方案,但是在完成GUI部分之后,我无法集成纯C ++代码。 Does someone have any experience with that? 有人对此有经验吗? I get 'unresolved externals' error. 我收到“无法解决的外部因素”错误。 Apperantly the .cpp files are not linked in the last step. 显然,.cpp文件在最后一步未链接。 I guess some project settings also need to be changed, could someone explain which exactly? 我想某些项目设置也需要更改,有人可以确切解释一下吗?
I was also thinking about compiling the classes into a .dll and importing that to the visual C++ project, is that possible somehow or can the two projects be compiled together? 我也在考虑将这些类编译为.dll并将其导入到可视C ++项目中,是否可能以某种方式将这两个项目编译在一起?
Thanks for the help, i've been playing with it for some time already but couldn't find any working solution. 感谢您的帮助,我已经使用它一段时间了,但是找不到任何可行的解决方案。
Zoltan 佐尔坦
“项目A”需要导入“项目B”的标题,并且还需要链接到“项目B”。
How are you importing these older classes into your C++ GUI project? 您如何将这些较旧的类导入C ++ GUI项目? As a library, or just as source files? 作为库还是作为源文件?
If just source files, you can just add the files to your project and compile them along with the new files. 如果只是源文件,则只需将文件添加到项目中,然后将其与新文件一起编译即可。
If your backend code is integrated as a separate project producing a library, you need to add a dependency on this project to your GUI app. 如果您的后端代码集成为一个单独的项目(生成一个库),则需要将此项目的依赖项添加到GUI应用程序。
If you did not integrated the project to your GUI solution, you need to set include directories, add the lib in linker->input and also let VS know how to find it by settings an additional library directory in linker options. 如果您没有将项目集成到GUI解决方案中,则需要设置包含目录,在链接器->输入中添加lib,并让VS知道如何通过在链接器选项中设置其他库目录来找到它。
Given there isn't enough details to really be able to tell what is going there are a number of possibilities off the top of my head. 鉴于没有足够的细节来真正分辨出发生了什么,所以我想到了很多可能性。
It's entirely possible to build a dll with he backend part if you wish. 如果您愿意,完全可以用他的后端部分构建dll。 If it's not going to be used by anything else I probably wouldn't bother and just link statically, but you certainly can. 如果它不会被其他任何东西使用,我可能不会打扰,只是静态链接,但是您当然可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.