0

I am having difficulty figuring out my unresolved external errors.

I have 2 different solutions that both share a core project. Solution #1 is called SnapGame and Solution #2 is called SnapEditor. The core project is called SnapCore.

My SnapGame solution is a Win32 application. It compiles, references, and links the SnapCore project with no issues.

The SnapEditor solution is a Windows Forms Application. It compiles and references the SnapCore project. However, it will not link with it properly. I get unresolved external errors any time I try to reference anything from the SnapCore project.

The SnapCore project has some GDI+ support classes. All classes in the SnapCore project are under the SnapCore namespace.

Here is the file Form1.cpp:

#include "stdafx.h"
#include "App.h"
#include "Orient.h"

using namespace SnapCore;
using namespace SnapEdit;

void Form1::Init()
{
SnapCore::Orient    orient;

new App();
}

Here are the linker errors I get:

1>Form1.obj : warning LNK4248: unresolved typeref token (01000049) for 'Gdiplus.GpCachedBitmap'; image may not run
1>Form1.obj : error LNK2028: unresolved token (0A000019) "public: __clrcall SnapCore::App::App(void)" (??0App@SnapCore@@$$FQAM@XZ) referenced in function "public: void __clrcall SnapEdit::Form1::InitSnapCore(void)" (?InitSnapCore@Form1@SnapEdit@@$$FQ$AAMXXZ)
1>Form1.obj : error LNK2028: unresolved token (0A00001A) "public: __clrcall SnapCore::Orient::Orient(void)" (??0Orient@SnapCore@@$$FQAM@XZ) referenced in function "public: void __clrcall SnapEdit::Form1::InitSnapCore(void)" (?InitSnapCore@Form1@SnapEdit@@$$FQ$AAMXXZ)
1>Form1.obj : error LNK2019: unresolved external symbol "public: __clrcall SnapCore::App::App(void)" (??0App@SnapCore@@$$FQAM@XZ) referenced in function "public: void __clrcall SnapEdit::Form1::InitSnapCore(void)" (?InitSnapCore@Form1@SnapEdit@@$$FQ$AAMXXZ)
1>Form1.obj : error LNK2019: unresolved external symbol "public: __clrcall SnapCore::Orient::Orient(void)" (??0Orient@SnapCore@@$$FQAM@XZ) referenced in function "public: void __clrcall SnapEdit::Form1::InitSnapCore(void)" (?InitSnapCore@Form1@SnapEdit@@$$FQ$AAMXXZ)
1>C:\Work\PC\SnapEdit\SnapEdit\Debug\SnapEdit.exe : fatal error LNK1120: 4 unresolved externals

I can't figure out why my SnapGame solution links with no troubles, but the SnapEditor solution will not.

Any help would be appreciated.

SnapGames
  • 375
  • 3
  • 10
  • Have you specified that SnapEditor is dependent upon SnapCore? – Mordachai Nov 19 '11 at 23:04
  • Yes. Under Project Dependecies for theSnapEdit solution, the SnapEdit project is dependent upon the SnapCore project and the SnapCore project has no dependency. – SnapGames Nov 19 '11 at 23:07

1 Answers1

0

If I understand you right, SnapEditor is a managed application. It can't simply refer to a native library, like SnapCore. Use P/Invoke, or write a managed wrapper.

Community
  • 1
  • 1
kol
  • 27,881
  • 12
  • 83
  • 120
  • If this is the issue (likely), then you could be compiling your core as a managed project as well. You may need some #defines or what have you to allow it to be compiled by both managed and non-managed clients.... – Mordachai Nov 19 '11 at 23:10
  • This is whole issue is new for me, so I apologize for all my questions. I googled the P/Invoke option and IJW. It seems like P/Invoke needs to work off of a DLL? However, my SnapCore project builds a lib. Besides, P/Invoke, IJW, and writing managed wrappers all seem like solutions that require a great deal of work. Mordachai, are you suggesting that I can make my SnapCore lib compile into a managed c++ lib instead of an unmanaged c++ lib? If that is the case, then I think that would be a much simpler option. – SnapGames Nov 19 '11 at 23:33
  • 1
    If SnapCore is pure C++, that is, it does not call any Win32 API functions directly, then you can simply recompile it for .NET. – kol Nov 19 '11 at 23:52
  • Ok, I figured it out :) I found that if I set my SnapCore project to build with 'pure CLR' then everything works for my SnapEdit solution. This of course breaks everything for my SnapGame solution though. So the fix was to create 2 new build targets for my SnapCore project, CLRDebug and CLRRelease. Thanks everyone for your help on this, I had been banging my head against the keyboard for hours. – SnapGames Nov 19 '11 at 23:57