Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

atlmincrt LNK2005 error

55 views
Skip to first unread message

MichaelG

unread,
Feb 24, 2006, 12:56:16 PM2/24/06
to
In VS2005, if I create a new ATL dll project and then set 'Minimize CRT Use
in ATL' to 'Yes' in Release, I get a pile of LNK2005 errors.

eg. Error 1 error LNK2005: __encode_pointer already defined in
atlmincrt.lib(atlinit.obj) LIBCMT.lib

I haven't added any code or changed anything else. Just a clean new ATL
project and I wish to use 'Minimize CRT'.

Something obviously changed in VS2005. It seems odd that something as
simple as this is broken. How do I fix this?

Thanks
Michael


Gary Chang[MSFT]

unread,
Feb 27, 2006, 2:18:59 AM2/27/06
to
Hi Michael,

>eg. Error 1 error LNK2005: __encode_pointer already
>defined in atlmincrt.lib(atlinit.obj) LIBCMT.lib

Such an error could be caused by linking with an inappropriate run-time
library. I suggest you can try to change your project's run-time library
setting in your project property pages at first:

Configuration Properties ->C/C++ -> Code Generation -> Runtime Library type
->...


Thanks!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================

MichaelG

unread,
Feb 27, 2006, 4:53:40 AM2/27/06
to
Hi Gary

I've just tried changing the runtime from /MT to /MD (the only choice
available) but still get piles of errors. As I said, this is a new wizard
generated ATL DLL project and I've changed nothing apart from 'Minimize CRT
Use in ATL'. No code has been added.

I have quite a number of VS2003 ATL projects that I would like to upgrade.

Thanks
Michael

""Gary Chang[MSFT]"" <v-ga...@online.microsoft.com> wrote in message
news:alZqc42O...@TK2MSFTNGXA01.phx.gbl...

David Lowndes

unread,
Feb 27, 2006, 9:00:31 AM2/27/06
to
>In VS2005, if I create a new ATL dll project and then set 'Minimize CRT Use
>in ATL' to 'Yes' in Release, I get a pile of LNK2005 errors.
>
>eg. Error 1 error LNK2005: __encode_pointer already defined in
>atlmincrt.lib(atlinit.obj) LIBCMT.lib

Michael,

I've just tried creating a new ATL project (DLL) in VS2005. It builds
fine for me with the "Mimimize CRT use in ATL" flag set or clear.

Is your installation clean? Have you tried this on another machine?

Dave

Kim Gräsman

unread,
Feb 27, 2006, 9:11:59 AM2/27/06
to
Hi Michael,

> In VS2005, if I create a new ATL dll project and then set 'Minimize
> CRT Use in ATL' to 'Yes' in Release, I get a pile of LNK2005 errors.
>
> eg. Error 1 error LNK2005: __encode_pointer already defined in
> atlmincrt.lib(atlinit.obj) LIBCMT.lib

Have you created an attribute or non-attributed project? I seem to recall
the attributed project type introduces an implicit dependency on the CRT.

--
Best regards,
Kim Gräsman


MichaelG

unread,
Feb 27, 2006, 11:07:37 AM2/27/06
to
Non-Attributed.

I just tried it on my laptop with the same result. Does it work ok on your
machine? The only thing I can think of is that I have WinFX extensions
installed and whether these have changed anything.

Michael


"Kim Gräsman" <k...@mvps.org> wrote in message
news:ba04ee015788f8...@news.microsoft.com...

Kim Gräsman

unread,
Feb 27, 2006, 2:34:05 PM2/27/06
to
Hi Michael,

> Non-Attributed.

Oh, good.

> I just tried it on my laptop with the same result. Does it work ok on
> your machine? The only thing I can think of is that I have WinFX
> extensions installed and whether these have changed anything.

Sorry, I don't have a machine with VS2005 handy, so I can't test it at the
moment.

I think there were some _ATL_MIN_CRT glitches in VC7.1 as well, i.e. including
certain headers introduced a CRT dependency, but I'm pretty sure a fresh
non-attributed project used to work.
I'll see if I can find the time to test on a 2005 machine tomorrow.

--
Best Regards,
Kim Gräsman


Brian Muth

unread,
Feb 27, 2006, 5:44:27 PM2/27/06
to
I played around a bit with it. By default, setting the "Minimize CRT Use in
ATL" works for the default DEBUG setting, but fails for default RELEASE
settings. Switching to /Md gets rid of all but 4 external links, but doesn't
quite solve the issue. Obviously there is still a conflict with another
RELEASE setting.

I'm losing interest but I thought I'd contribute these observations.

By the way, Michael, why do you want to minimize the CRT use? I'm interested
in what motivates people to do this...

Brian


Alexander Nickolov

unread,
Feb 27, 2006, 8:51:32 PM2/27/06
to
Not having to lug around the CRT DLL of course. Can be
quite a liability if your product is downloaded over the Internet...
Note that statically linking CRT does not help either - your
code size still inclreases by the CRT startup code (if you've
been careful not to use any important CRT functions - what
min CRT is all about).

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"Brian Muth" <bm...@mvps.org> wrote in message
news:uy3ce9%23OGH...@TK2MSFTNGP11.phx.gbl...

Brian Muth

unread,
Feb 27, 2006, 10:35:23 PM2/27/06
to

"Alexander Nickolov" <agnic...@mvps.org> wrote in message
news:O$rQBnAPG...@TK2MSFTNGP14.phx.gbl...

> Not having to lug around the CRT DLL of course. Can be
> quite a liability if your product is downloaded over the Internet...
> Note that statically linking CRT does not help either - your
> code size still inclreases by the CRT startup code (if you've
> been careful not to use any important CRT functions - what
> min CRT is all about).
>

msvcr80.dll is 572 Kb. I guess that is a bit of a hike compared with
msvcr71.dll's size of 340 Kb. In the days of dialup, I suppose this was an
issue, but nowadays I wonder about the relevance. It seems most applications
I download are of the order of many (and sometimes 10's of megabytes).

Brian


MichaelG

unread,
Feb 28, 2006, 3:41:25 AM2/28/06
to
Hi Brian,

Well, I have a number of projects that were started in the early days of ATL
when it seemed like a good idea to minimize CRT use. The app was intended
for internet distribution and there was no need to use the CRT. It also had
a certain minimalist appeal. I agree it would be hard to make much of a
case for it now but I still like to write software that is no bigger and no
more complicated than it needs to be.

There is one area where it does make a difference. My msi installer uses
several custom actions packaged in dlls. With AtlMinCrt I can get these
down to 7-11kb each.

Thanks for confirming that there is a problem with the release setting and
it's not just me!

Michael

"Brian Muth" <bm...@mvps.org> wrote in message
news:uy3ce9%23OGH...@TK2MSFTNGP11.phx.gbl...

David Lowndes

unread,
Feb 28, 2006, 5:49:27 AM2/28/06
to
>Thanks for confirming that there is a problem with the release setting and
>it's not just me!

Try switching off the Enable C++ Exceptions setting - that allows a
release build to link OK for me.

Dave

MichaelG

unread,
Feb 28, 2006, 8:45:49 AM2/28/06
to
Yes, that worked for the test project and one other very small project.
However, I still get the LNK2005 errors once I start adding code back in
from my VS2003 project. I've played around with nearly every project
setting now so at this stage I think I'll give up and just put up with the
CRT. I just felt that it should work.

Thanks
Michael


"David Lowndes" <Dav...@example.invalid> wrote in message
news:7ha802928un0j4ko8...@4ax.com...

David Lowndes

unread,
Feb 28, 2006, 11:25:36 AM2/28/06
to
>Yes, that worked for the test project and one other very small project.
>However, I still get the LNK2005 errors once I start adding code back in
>from my VS2003 project. I've played around with nearly every project
>setting now so at this stage I think I'll give up and just put up with the
>CRT.

It does get hard to not introduce use of the run-time - even
unintentionally. I suspect the situation is hard for MS to maintain as
well.

Dave

Alexander Nickolov

unread,
Feb 28, 2006, 12:34:11 PM2/28/06
to
When you have a hard requirement to fit your installation into
1MB _after_ compression, even 10KB uncompressed may
make all the difference...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"Brian Muth" <bm...@mvps.org> wrote in message

news:OxaDDgBP...@TK2MSFTNGP11.phx.gbl...

Gary Chang[MSFT]

unread,
Mar 1, 2006, 5:14:46 AM3/1/06
to
Hi Michael,

I have already repro this problem on my side, I also check it in our
database. It appears to be a VC2005's product issue. I highly suggest you
can file a product bug to our product feedback center, our development team
may communicate with you directly directly on the issue there:

http://lab.msdn.microsoft.com/productfeedback/default.aspx

Meantime, if you need a solution to work around this problem, it is better
for you if one of our PSS support engineers could work with you. This may
need you submit a support incident in Microsoft PSS (Product Support
Service). As a MSDN subscriber, you have two free support incidents.

By the way, if the problem is confirmed by Microsoft PSS as a product
issue, PSS won't charge money. Every MSDN subscriber has two free support
incidents. You could use one of them to contact Microsoft PSS. So you don't
need to pay money yet. Surely if the issue is a product issue, you still
have two free support incidents.

For your reference, I attached steps to contact Microsoft PSS here: You can
contact Microsoft Product Support directly to discuss additional support
options you may have available, by contacting us at 1-(800)936-5800 or by
choosing one of the options listed at :

http://support.microsoft.com/common/international.aspx?rdpath=gp;en-us;offer
prophone


Thanks for your understanding!

0 new messages