Hello!
I've a link error problem problem with VS .NET 2003.
I give you the complete description of a simple test (to simplify) :
First, I make a WIN32 static library supporting MFC and using precompiled
header. It contains :
*****
testlib.h:
#pragma once
class CTestLib
{
public:
CTestLib(void){}
~CTestLib(void){}
int gettruc(wchar_t const * truc);
int gettrucbis(int truc);
};
****
testlib.cpp:
#include "StdAfx.h"
#include ".\testlib.h"
int CTestLib::gettruc(wchar_t const * truc)
{
return 0;
}
int CTestLib::gettrucbis(int truc)
{
return truc;
}
This project compiles and links.
In second time, I naturally want to use my static library... In fact, I need
it in a DLL. So my second project is a DLL MFC (normal dll using a MFC
shared DLL). I have a function which uses the object of my library :
****
test.h:
void coucou(LPVOID t);
****
test.cpp:
#include "stdafx.h"
#include "test.h"
#include "..\lib\testlib.h"
void coucou(LPVOID t)
{
CTestLib ti;
int i = ti.gettruc(NULL);
int i2 = ti.gettrucbis(2);
}
And I include the previous .lib file in the project options.
This project compile but does not link on ly for "gettruc" function:
"Création de la bibliothèque Debug/dll.lib et de l'objet Debug/dll.exp
test.obj : error LNK2019: symbole externe non résolu "public: int __thiscall
CTestLib::gettruc(wchar_t const *)" (?gettruc@CTestLib@@QAEHPB_W@Z)
référencé dans la fonction "void __cdecl coucou(void *)"
(?coucou@@YAXPAX@Z)"
So it is surprising that with a int parameter, it works, but not with a
wchar_t parameter. And I have the same problem with other parameter :
LPCWSTR, CAtlStringW, CAtlArray, etc.
I noticed that the decorated name in the .lib generated in the first project
are not exactly the same that those generated in the second project to link
with the library. So It's normal that it doesn't link. But I don't know why
and how to cure this problem.
Thanks for your help !!!!!!