Hi,
I've recently met a problem with polink when trying to link a .obj file (ASM) with a static library compiled using Visual C++ 2005 Express (C compilation mode, no choice to use anything else than VCE).
At the beginning, I was thinking that the problem was coming from VCE, but after long hours of debugging, I think now that it is a problem in polink.
When I create some switch/case in my static library code, it generates labels like $LN1@function, $LN2@function, etc, one for each case. I can see these names in the ASM listing output of the library.
If I have only one switch/case in my library, no problem, but if I have two switch/case or more, the problem is that when I try to use polink with this static library, it detects some duplicated symbols :
POLINK: error: Symbol '$LN2' is multiply defined: 'Switch.lib(Debug.obj)' and 'Switch.lib(Debug.obj)'.
And when I take a look to the ASM source, there are no $LN2 symbol, but $LN2@function1 and $LN2@function2 labels.
The C code of the library is that (example) :
extern int SwitchTest(char op)
{
int value;
switch (op)
{
case 0:
value = 1;
case 1:
value = 2;
case 2:
value = 3;
case 3:
value = 4;
default:
value = 0;
}
return value;
}
extern int SwitchTest2(char op)
{
int value;
switch (op)
{
case 0:
value = 5;
case 1:
value = 6;
case 2:
value = 7;
case 3:
value = 8;
default:
value = 0;
}
return value;
}
Here is an archive with all the files needed to reproduce the problem :
http://rapidshare.com/files/153267174/SwitchSymbols.rar.html.
- SwitchLib.c, the code for the library.
- SwitchLib.lib, the compiled library.
- Test.asm, a simple code using SwitchLib.lib (FAsm syntax).
- Test.obj, the compiled code.
- msvcrt.lib, libcmt.lib, and oldnames.lib.
To link, I use the following command line :
polink test.obj msvcrt.lib switchlib.lib /SUBSYSTEM:console /ENTRY:_main