Unresolved external

T

TBass

In Visual Studio 2008, I created a Windows Form project, made some
menus.

Then I created a class using Add Class under the project menu. Here's
the class definition:

ref class CSkatterCipher
{
public:
CSkatterCipher(void);
void GetRandom( int *t, unsigned int MaxVal );
bool CreateCipher( String ^szFileName );


protected:

static const int SKATTER_VERSION_HI = 1;
static const int SKATTER_VERSION_LO = 0;
static const int SKATTER_NUMROTORS = 255;

static array<unsigned int> ^primeArray =
{ 57397, 57413, 57427, 57457, 57467, 57487, 57493, 57503,
57527, 57529,
57847, 57853, 57859, 57881, 57899, 57901, 57917, 57923,
57943, 57947,
59149, 59159, 59167, 59183, 59197, 59207, 59209, 59219,
59221, 59233,
59239, 59243, 59263, 59273, 59281, 59333, 59341, 59351,
59357, 59359,
62081, 62099, 62119, 62129, 62131, 62137, 62141, 62143,
62171, 62189,
2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729,
2731, 2741,
3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251,
3253, 3257,
4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391,
4397, 4409,
4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649,
4651, 4657,
7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187,
7193, 7207,
11779, 11783, 11789, 11801, 11807, 11813, 11821, 11827,
11831, 11833,
11839, 11863, 11867, 11887, 11897, 11903, 11909, 11923,
11927, 11933,
12491, 12497, 12503, 12511, 12517, 12527, 12539 };

bool createCipherFile( String ^szFileName );

int writeFileHeader( void );
int closeCipherFile( void );
int createCipherRotor( int *t );
int createIndexRotor( int *rotor );
int writeRotor( int *rotor );
int createSeed( long *t );


void addText( FileStream^ fs, String^ value );


FileStream ^m_hFile;
String ^m_OutFileName;


};

After that, I programmed the functions in the corresponding cpp file.

For one of the menu items, I added this code:

{

CSkatterCipher ^mycipher = gcnew CSkatterCipher();

int i;
mycipher->GetRandom( &i, 255 );

MessageBox::Show( "Random Number: " + i.ToString() );

}

But when I build, I get linker errors for every function in the
CSkatterCipher class:

Error 1 error LNK2020: unresolved token (06000001)
Skatter.CSkatterCipher::.ctor Skatter.obj
Error 2 error LNK2020: unresolved token (06000002)
Skatter.CSkatterCipher::GetRandom Skatter.obj

.....

For a total of 12 errors.

Huh? If I complile the SkatterCipher.cpp file on its own, it compiles
with no errors or warnings. It seems like that obj file hasn't been
added into the project for build, but I can't find where I can check
the expected list of obj files or dependences. And I can find the
dependency order dialog I used to check in Visual Studio 2003.

Can someone please tell me what I'm doing wrong, or point me in a
direction to check?

Thanks in advance,
T
 
M

Mark_Parker

The code you show doesn't have definitions for the member functions of your
CSkatterCipher class. You show declarations of these functions, but their
definitions (i.e., the code for them) are nowhere in evidence. Somewhere else
in your application there are calls to these functions, but the linker is
unable to find the code to execute. That's what the linker is complaining
about when it gives you unresolved token errors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top