tags:

views:

31

answers:

2

I have a library which is compiled in VS 2005 and I am trying to link it with one of the old VC 6 workspace, while linking I am getting following errors.

error LNK2001: unresolved external symbol _sprintf_s
error LNK2001: unresolved external symbol _strncpy_s
error LNK2001: unresolved external symbol _strcpy_s    
error LNK2001: unresolved external symbol _strcat_s    
error LNK2001: unresolved external symbol __time64    
unresolved external symbol __alloca_probe_16    
unresolved external symbol _main    
fatal error LNK1120: 7 unresolved externals    
Error executing link.exe.

Please help me in getting away with this error.

+2  A: 

_strcpy_s is not defined in the VC6 libraries, it was added in VS2005 (or maybe VS2002/2003 ?). I don't think there's a way around it.

AFAIK, it's not usual to use a library from an earlier version of the compiler with an older version of the compiler.

Max
+1  A: 

I assume the above is a result of you statically linking the executable?

The _s functions are "safe" functions that Microsoft added to the runtime library to make it harder to write code with buffer overflows. They were added after VC6 (either in VS.NET or VS2003) and the functions are not present in the VC6 runtime libraries, so that is why your link is failing. The only two ways to get around this are either to build the whole set of binaries with VS2005 or with VC6. The latter is probably not a good idea as it would require you reworking the library to use the standard C functions instead.

It is generally not a good idea to mix compiler versions in static libraries and executables as the runtime libraries do change and you're left with problems like these.

You could turn your library into a DLL, but that's opening another can of worms...

Timo Geusch