views:

113

answers:

4

Hi!

I have written some classes, the back end of a project in C++ (win32 project) and then wanted to add a GUI to it. Visual C++ seemed to be a good solution but after having the GUI part done I couldn't integrate the plain C++ code. Does someone have any experience with that? I get 'unresolved externals' error. Apperantly the .cpp files are not linked in the last step. 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?

Thanks for the help, i've been playing with it for some time already but couldn't find any working solution.

Zoltan

A: 

"project A" needs to import the headers of "Project B" and it also needs to link against "project B".

Hassan Syed
A: 

How are you importing these older classes into your C++ GUI project? 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.

Scott Smith
A: 

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.

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.

Eric Fortin
A: 

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.
  • 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. If it's not going to be used by anything else I probably wouldn't bother and just link statically, but you certainly can.

Montdidier