[ back to toc ]

building a library in VC6

Date: 2002/01/14 14:33

Q:
Hello, and thanks in advance for your help.

I am trying to create a library (.lib) file using VC6. I created a "Static
Library" project, created a .c source code file, and put my one function
in it. I compile it, and it generates a .lib file.

Now, to use it in another project, I have added the directory the .lib
file is in to the Library directories list under Tools | Options |
Directories. It seems to be finding the .lib file OK.

The problem is that my EXE program fails in the link step with error
LNK2001: unresolved external symbol __imp__TestFunction. If I run DUMPBIN
/SYMBOLS on the .lib file, it has the symbol _TestFunction defined, but
not __imp__TestFunction.

How do I get the names to match up? Looking at other .lib files I use,
they have both _<functionname> and __imp__<functionname> defined, so it
appears that I'm not doing something to get VC6 to define both names when
I build my .lib file.

I'm using "__declspec(dllexport) void TestFunction" in the .c file to
create the .lib file, and I've tried everything (including
__declspec(dllimport)) in my .exe project.

Any help you can give me would be great!

Thanks,
*NAME-DELETED*
A:
When creating a LIB file also create a DEF file that lists the functions
that you want to be exported from the library file.

See the documentation.

regards,
Peter

[ back to toc ]