Would someone be kind enough to tell me what silly mistake I am making
Error Message is fatal error LNK1120: 1 unresolved externals
#pragma once
using namespace System;
namespace StationObjects
{
public __gc class StationObj
{
public:
StatioObj(void){}
~StationObj(void){}
};
__gc class PressObj : public StationObj
{
public:
PressObj(void){}
~PressObj(void){}
};
}

Problem with VC++ 2003.Net Inheritance and destructors
Yew Thean Hoo
You can just disable precompiled headers.
Ok, I tried the following and it worked as expected:
1) cl /CLR /c i.cpp
2) lib i.obj
where i.cpp and i.h look like the following:
//i.cpp
#using <mscorlib.dll>
using namespace System;
//#include "stdafx.h"
#include "i.h"
using namespace StationObjects;
//i.h
#pragma once
namespace StationObjects
{
public __gc class StationObj
{
public:
StationObj(void){}
~StationObj(void){}
};
__gc class PressObj : public StationObj
{
public:
PressObj(void){}
~PressObj(void){}
};
}
The only difference is the stdafx.h (what does yours look like). Also, could you please try the exact above sample from the VC command window and see if you get any errors.
Thanks,
Ayman Shoukry
VC++ Team
IbrahimSA
// This is the main DLL file.
#include "stdafx.h"using namespace System;
public __gc class StationObjects
{
public:
StationObjects()
{
Int32 x = 1;
} // ~StationObjects()
//{
//}
// TODO: Add your methods for this class here.
};
public
__gc class PressObj : public StationObjects{
public:
PressObj()
{
}
~PressObj()
{
}
};
This will compile but gives an error when you build it. If I comment out the destructor I can build it with out the error. To me this is very weird. It must have something to do with the way managed garbage collection works because unmanaged code works fine. For now I am going to build my class objects without destructors.
I really hope you can answer this one.
amidar
If this helps
YKen
//a.cpp
#pragma once
#using <mscorlib.dll>
using namespace System;
namespace StationObjects
{
public __gc class StationObj
{
public:
StationObj(void){}
~StationObj(void){}
};
__gc class PressObj : public StationObj
{
public:
PressObj(void){}
~PressObj(void){}
};
}
Thanks,
Ayman Shoukry
VC++ Team
IvanLieb
I tried to compile my other file the same way and it tells me Build.Compile is unavailable. It also does not give the compile option in the top menu. Also I cannot seem to use the cl i.cpp/CLR command line for your code it tells me cl is not a recognized command.
A secondary problem that I am having is that every time I start VISIO Standard it asks me if I want to configure Visual Studio and then it does it's thing asking for the VS disk to be inserted and does its thing. But it does this every time I start Visio.
I don't know if both problems are related or not.
Help
SanderV
Is there a way I can send you the whole program so you can take a good look at what I am doing wrong.
Please Help!!!!!
chrisan
I just tried the below sample and it worked with no errors:
The compilation command I used was cl /LD /CLR a.cpp and a.dll was generated.
//a.cpp
//#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
public __gc class StationObjects
{
public:
StationObjects()
{
Int32 x = 1;
}
~StationObjects()
{
}
// TODO: Add your methods for this class here.
};
public __gc class PressObj : public StationObjects
{
public:
PressObj()
{
}
~PressObj()
{
}
};
Could you tell me what is in stdafx.h and also what is the compilation command line used (you can get this by viewing the build log file).
Also, you can use the command prompt compilation (cl.exe) by starting visual studio command prompt from the windows Start menu:
Start->All Programs->Microsoft visual Studio .Net 2003->Visual Studio .Net Tools->Visual Studio .Net 2003 command Prompt
This will start a command prompt with the compiler tools (cl.exe) in the path already.
Thanks,
Ayman Shoukry
VC++ Team
JaganG
The above code was a .h file and the cpp file is below:
#using <mscorlib.h>
using namespace System;
#include "stdafx.h"
#include "TestInheritance.h"
using namespace StationObjects;
I am trying to create an object library.
The error message is:
error LNK2001: unresolved external symbol "void__cdedl_CxxCallUnwindDtor(void(__thiscall*)(void*)"( __CxxCallUnwindDtor@@$$JOYAXP6EXPAX@Z0@Z)
error LNK1120: 1 unresolved externals
I am using the Visual Studio IDE to build the solution by selecting build from the menu.
Please help. I know I am doing something silly but I cannot seem to solve this.