linking errors

G

Guest

Hi there,

I've been working with dynamic libraries for a quite big software and now
and then I may get some weird linking errors, like following

MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _fprintf already defined in
libcmtd.lib(fprintf.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _swprintf already defined in
libcmtd.lib(swprintf.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _free already defined in
libcmtd.lib(dbgheap.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _malloc already defined in
libcmtd.lib(dbgheap.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _printf already defined in
libcmtd.lib(printf.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _strchr already defined in
libcmtd.lib(strchr.obj)
MSVCRTD.lib(MSVCR71D.dll) : error LNK2005: _sprintf already defined in
libcmtd.lib(sprintf.obj)

The symbols invovled in the linking errors are actually some basic c++
library functions and I used them in many other places. The problem
disappeared for some unknown reason before, but this time they just refuse to
go. Any idea what's causing the problem and what I should do to get rid of
this kind of problem. Suggestions are really appreciated. Thanks.

rich
 
M

Marcus Heege

Are all your cpp files compiled with the same CRT library setting (e. g.
/MD)?
 
G

Guest

I guess so. In this specific solution, I have two projects and I set both of
them as /MTd (this is the required setting). But I am not sure if one/some of
the cpp files are using other CRT library setting, while I didn't realize it?
Is there any way I can check? By the way, last time I had a similar problelm
and the way I found to handle it was remove specific files from a project and
then add them back. I know it doesn't make much sense, but the error doesn't
make sense either to me.

Regards, rich
 
G

Guest

Hi Marcus, Thanks a lot for your advice. I just checked and found one of my
cpp files are using a different CRT library. Thanks again.

rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top