I have 2 projects. I'm using VC++ 2010 express.

The first is a static library which generates a lib file called stdlib.lib.
The second is a dll project which links to stdlib.lib.

When I try to compile, I get linker errors that say unresolved reference and they refer
to functions that are inside stdlib.lib. I have no idea why this is happening because
I've linked in stdlib.lib.

This is some of the code from stdlib.lib(too much to show all):

#ifndef KEYVALUE_H
#define KEYVALUE_H
#ifdef _WIN32
#pragma once
#endif

#include "utlvector.h"
#include "ifilesystem.h"

#define MAX_IDENTIFIER_LENGTH 256
#define MAX_VALUE_LENGTH 1024

class KeyValue{
	char m_pIdentifier[MAX_IDENTIFIER_LENGTH];
	char m_pValue[MAX_VALUE_LENGTH];
	bool m_bParseSubKeys;
	CUtlVector< KeyValue > m_SubKeys;
public:
	KeyValue( void );
	KeyValue( char *pFilename, IBaseFileSystem *pFileSystem );
	KeyValue( int nFileHandle, IBaseFileSystem *pFileSystem );
	~KeyValue( void );

	void Reset( void );
	void Cleanup( void );

	char *GetIdentifier( void );
	char *GetValue( void );
	CUtlVector< KeyValue > &GetSubKeys( void );

	bool ParseFromFile( int nFileHandle, IBaseFileSystem *pFileSystem );
	bool ParseFromFile( char *pFilename, IBaseFileSystem *pFileSystem );
	bool ParseFromFileManual( char *pFilename, IBaseFileSystem *pFileSystem );
	bool ParseFromString( char *pString, bool *bGetNext = NULL );

	KeyValue GetSubKey( char *pSubKeyName );
	KeyValue GetSubKey( int nIndex );
	char *GetSubKeyValue( char *pSubKeyName );
	char *GetSubKeyValue( int nIndex );

	int IndexOf( char *pSubKeyName );

	int NumSubKeys( void );

	bool IsParsingSubKeys( void );

	bool operator==( KeyValue &other );

	bool IsValidIndex( int nIndex );
	bool ValidateKeyname( char *pName );
};

#endif

Here is some code that uses it from the dll:

KeyValue kGameData;
	kGameData.ParseFromFileManual( "gameinfo.txt", filesystem );

	char *pGameDir = kGameData.GetSubKeyValue( "game" );

	if( !pGameDir )
		pGameDir = "charge";

Pfft borring. Go practise your drums! :D

Do all functions from stdlib.lib give you a linker error?

On a side note, Ed does not get warm and fuzzies from the name "stdlib.lib" because there is already a compiler-supported stdlib.h, which might have a corresponding stdlib.lib.

Not all of them, just those inside the KeyValue class. I'll try naming it something else then compiling.

EDIT: Just tried renaming but still got the same errors.

> Not all of them, just those inside the KeyValue class.
Are you sure all of the methods are implemented and everything is being exported to the DLL?

All the methods are being implemented, I just double checked :)
I'm not sure if they are being exported but I looked inside the .lib file and the KeyValue methods are there. Is there anything I need to do to the dll/the dll project to get it to work?

EDIT: I just did a ctrl+f in notepad when I opened the .lib file and it couldn't find the text 'KeyValue' would this mean they're not being exported?

Can you post the linker errors? Also the command lines (from the VS build logs).

--edit--
And certainly DO NOT use stdlib as the name!! As already said by Ed..
Don't post the errors unless you've changed the name.

I just did a ctrl+f in notepad when I opened the .lib file and it couldn't find the text 'KeyValue' would this mean they're not being exported?

No.

Rather use dumpbin, see its /LINKERMEMBER option.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.