Discussion:
Building DLL using WDK tool
(too old to reply)
Alok
2010-07-12 11:42:03 UTC
Permalink
Hi,
When I build one dll using WDK, it gives me following error

\atlsd.lib(externs.obj) : error LNK2005: "char const * const
\atlsd.lib(externs.obj) : error LNK2005: "char const
*g_pszUpdateEventName" (?g_pszUpdateEventName@@3PBDB) already defined
in atls.lib

To ressolve this issue I found somewhere in a blog that use /
FORCE:MULTIPLE option for linker. This is for visual studio.

If this the solution for this error, then could somebody suggest me
how to give this option in SOURCES file while using WDK to create the
dll?

Thanks in advance
-Alok
Jonathan Wilson
2010-07-12 14:06:03 UTC
Permalink
Post by Alok
Hi,
When I build one dll using WDK, it gives me following error
\atlsd.lib(externs.obj) : error LNK2005: "char const * const
\atlsd.lib(externs.obj) : error LNK2005: "char const
in atls.lib
Your problem seems to be that you are linking to both atlsd.lib and atls.lib
This suggests that some files in your project are being built in debug mode
(and linking to atlsd.lib) and others in release mode (and linking to atls.lib)
Alok
2010-07-13 03:39:28 UTC
Permalink
Post by Jonathan Wilson
Hi,
When I build one dll  using WDK, it gives me following error
\atlsd.lib(externs.obj) : error LNK2005: "char const * const
\atlsd.lib(externs.obj) : error LNK2005: "char const
in atls.lib
Your problem seems to be that you are linking to both atlsd.lib and atls.lib
This suggests that some files in your project are being built in debug mode
(and linking to atlsd.lib) and others in release mode (and linking to atls.lib)
Thanks for the reply.Yes, very true. But how can I force to the build
tool to ignore the error.

-Alok
Alok
2010-07-13 04:51:39 UTC
Permalink
Post by Alok
Post by Jonathan Wilson
Hi,
When I build one dll  using WDK, it gives me following error
\atlsd.lib(externs.obj) : error LNK2005: "char const * const
\atlsd.lib(externs.obj) : error LNK2005: "char const
in atls.lib
Your problem seems to be that you are linking to both atlsd.lib and atls.lib
This suggests that some files in your project are being built in debug mode
(and linking to atlsd.lib) and others in release mode (and linking to atls.lib)
Thanks for the reply.Yes, very true. But how can I force to the build
tool to ignore the error.
-Alok
I would add few more information.

1. I do not get any error in case of free build
2. In checked build: I treid the following
a) added this option in SOURCES
LINKER_FLAGS=$(LINKER_FLAGS) /FORCE:MULTIPLE
b) After adding above option I got new error, which says
warning got converted into error and no output file wil be generated
c) Then I removed MSC_WARNING_LEVEL = /W4 /Wp64 /WX from sorces,
but the error remains same.
Tim Roberts
2010-07-13 05:28:34 UTC
Permalink
Post by Alok
Post by Jonathan Wilson
Hi,
When I build one dll  using WDK, it gives me following error
\atlsd.lib(externs.obj) : error LNK2005: "char const * const
\atlsd.lib(externs.obj) : error LNK2005: "char const
in atls.lib
Your problem seems to be that you are linking to both atlsd.lib and atls.lib
This suggests that some files in your project are being built in debug mode
(and linking to atlsd.lib) and others in release mode (and linking to atls.lib)
Thanks for the reply.Yes, very true. But how can I force to the build
tool to ignore the error.
You should not be ignoring the error. The error message is trying to tell
you about a PROBLEM. The fact that you want to "solve" this by ignoring
the error is a sign of inexperience.

The two ATL DLLs will have different sets of local state. By ignoring the
error, you are instead signing up for a difficult-to-find runtime error
later on, when the two sets of state collide with each other.

If you really do want to run your nuclear reactor without the containment
vessel in place, you can always use

LINKER_FLAGS = $(LINKER_FLAGS) /force:multiple

but you will be sorry later.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Alok
2010-07-13 06:22:47 UTC
Permalink
Post by Alok
Post by Jonathan Wilson
Hi,
When I build one dll  using WDK, it gives me following error
\atlsd.lib(externs.obj) : error LNK2005: "char const * const
\atlsd.lib(externs.obj) : error LNK2005: "char const
in atls.lib
Your problem seems to be that you are linking to both atlsd.lib and atls.lib
This suggests that some files in your project are being built in debug mode
(and linking to atlsd.lib) and others in release mode (and linking to atls.lib)
Thanks for the reply.Yes, very true. But how can I force to the build
tool to ignore the error.
You should not be ignoring the error.  The error message is trying to tell
you about a PROBLEM.  The fact that you want to "solve" this by ignoring
the error is a sign of inexperience.
The two ATL DLLs will have different sets of local state.  By ignoring the
error, you are instead signing up for a difficult-to-find runtime error
later on, when the two sets of state collide with each other.
If you really do want to run your nuclear reactor without the containment
vessel in place, you can always use
   LINKER_FLAGS = $(LINKER_FLAGS) /force:multiple
but you will be sorry later.
--
Providenza & Boekelheide, Inc.- Hide quoted text -
- Show quoted text -
My itention is certainly not to ignore the problem. However it is that
I have less experinece in using the WDK tool.
I used /FORCE option becuase few functions were getting redefined
(atlsd.lib, atlsd.lib). but this is based on the whether the driver is
getting built in free or checked mode. and Any one of the these two
lib will be used based on built type.

Please give me some pointers which could help me resove the issue. I
would like to tell that this does not happen in case of free built.

Thanks,
-Alok
Tim Roberts
2010-07-15 03:16:06 UTC
Permalink
Post by Alok
My itention is certainly not to ignore the problem. However it is that
I have less experinece in using the WDK tool.
The issue is not unique to the WDK.
Post by Alok
I used /FORCE option becuase few functions were getting redefined
(atlsd.lib, atlsd.lib). but this is based on the whether the driver is
getting built in free or checked mode. and Any one of the these two
lib will be used based on built type.
Please give me some pointers which could help me resove the issue. I
would like to tell that this does not happen in case of free built.
You need to figure out why you have both "atls.lib" and "atlsd.lib". My
guess is that you are linking to some non-Microsoft library that is using
ATL, and you are using the checked build of that library in both the
checked and free builds of your product. There are two ways to solve that.
The best way is to build a free build of that library, and use the free
version when you do your free build. The less good way is to suppress
atls.lib altogether, by doing this:

LINKER_FLAGS = $(LINKER_FLAGS) /NOD:atls.lib

Now, everything should come from atlsd.lib.
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Loading...