Although I've seen similar hints and examples, I've yet to get this to work - must be something simple I'm missing (or messing up ). I have two simple dlls, and I want to be able to call a function in one from the other:

Here is the first one : seconddll.cpp
Code:
#include "stdafx.h"
#define BUILD_SECONDDLL
#include "seconddll.h"

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}


// This is an example of an exported variable
SECONDDLL_API int nSeconddll=0;

// This is an example of an exported function.
SECONDDLL_API int fnSeconddll(void)
{
	return 43;
}

// This is the constructor of a class that has been exported.
// see seconddll.h for the class definition
CSeconddll::CSeconddll()
{ 
	return; 
}
and its corresponding header seconddll.h:

Code:
#ifdef BUILD_SECONDDLL
#define SECONDDLL_API __declspec(dllexport) 
#else
#ifdef USE_SECONDDLL
#define SECONDDLL_API __declspec(dllimport)
#else
#define SECONDDLL_API 
#endif
#endif


// This class is exported from the seconddll.dll
class SECONDDLL_API CSeconddll {
public:
	CSeconddll(void);
	// TODO: add your methods here.
};

extern SECONDDLL_API int nSeconddll;

SECONDDLL_API int fnSeconddll(void);
Here is the other dll that calls a function from the one above (dlltest.cpp):
Code:
// dlltest.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"

#define USE_SECONDDLL
#include "seconddll.h"

#define DLLTEST_EXPORTS
#include "dlltest.h"





BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}


// This is an example of an exported variable
DLLTEST_API int nDlltest=0;

// This is an example of an exported function.
DLLTEST_API int fnDlltest(void)
{
	return 42;
}

// This is an example of an exported function.
DLLTEST_API int fnDlltest2nd(void)
{
	int i = fnSeconddll();  // ---->>> trying to call function from another dll
	
	return i;
	
}

// This is the constructor of a class that has been exported.
// see dlltest.h for the class definition
CDlltest::CDlltest()
{ 
	return; 
}
and its corresponding header file (dlltest.h):
Code:
#ifdef BUILD_SECONDDLL
#define SECONDDLL_API __declspec(dllexport) 
#else
#ifdef USE_SECONDDLL
#define SECONDDLL_API __declspec(dllimport)
#else
#define SECONDDLL_API 
#endif
#endif

// This class is exported from the seconddll.dll
class SECONDDLL_API CSeconddll {
public:
	CSeconddll(void);
	// TODO: add your methods here.
};

extern SECONDDLL_API int nSeconddll;

SECONDDLL_API int fnSeconddll(void);
I have copied secondll.dll and seconddll.lib to the appropriate directories, but still get this message when compiling dlltest.cpp:

dlltest.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl fnSeconddll(void)" (__imp_?fnSeconddll@@YAHXZ)
Debug/dlltest.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Any help?