简体   繁体   English

将C ++ Win32 Console项目类集成到Visual Studio 2008中的Visual C ++(Windows窗体应用程序)项目中

[英]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. 鉴于没有足够的细节来真正分辨出发生了什么,所以我想到了很多可能性。

  • The code for your backend part is not being compiled (the cpp files for the project are not part of the GUI project or associated dependencies) if you're not linking the backend separately. 如果不单独链接后端,则不会编译后端部分的代码(该项目的cpp文件不是GUI项目或相关依赖项的一部分)。
  • The library for your backend project is not being linked with; 您的后端项目的库未链接; check the linking section of project properties. 检查项目属性的链接部分。 In the case you are linking separtely. 在这种情况下,您是分开链接的。
  • The backend and frontend libraries have been compiled with different settings and at link time this is causing problems. 后端库和前端库已使用不同的设置进行编译,并且在链接时这会引起问题。 For example debug and release standard libraries, multi-threaded or single threaded libraries; 例如调试和发布标准库,多线程或单线程库; also different string defines can cause problems if they don't match (particularly if you've used template code). 另外,不同的字符串定义如果不匹配也可能导致问题(特别是如果您使用了模板代码)。

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.

相关问题 如何在Visual C ++ 2008中将MFC应用程序项目添加到Win32应用程序项目 - How to add MFC application project to Win32 application project in Visual C++ 2008 Visual Studio 2017 C ++ Win32控制台项目模板 - Visual Studio 2017 c++ win32 console project template 什么是Visual C ++中的Win32项目? - What is win32 project in visual c++? 是否可以在Visual Studio的Win32 C ++应用程序的控制台中进行调试? - Is it possible to debug in console in a Win32 C++ Application in Visual Studio? 使用Visual Studio 2012配置c ++ win32控制台应用程序 - Profile a c++ win32 console application with Visual Studio 2012 安装 C++ 组件后,在 Visual Studio 2015 中看不到 Win32 控制台应用程序 - Not seeing Win32 Console Application in Visual Studio 2015 after installing C++ components 为什么我的 C++/Win32 项目不能在 Visual Studio 之外工作? - Why won't my C++/Win32 project work outside of Visual Studio? 如何在Win32 C ++项目Visual Studio 2010中使用ActiveX dll - How to use ActiveX dll in win32 C++ project visual studio 2010 链接时,Visual Studio Win32 C ++项目非常慢 - Visual Studio Win32 C++ Project very slow when Linking 如何在Visual Studio C ++ Win32项目中填充组合框 - How to fill combobox in a Visual Studio C++ Win32 project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM