Re: ZXing Link Error on Visual C++ 2010

463 views
Skip to first unread message

Steven Parkes

unread,
Jun 4, 2013, 12:11:42 PM6/4/13
to NeoDreamer, zx...@googlegroups.com
MS does some weird non-standard/incompatible stuff if you don't add /Za to your project.

On Jun 4, 2013, at 8:03 AM, NeoDreamer <asu...@gmail.com> wrote:

> I was build ZXing static library by CMAKE and Visual C++ 2010.
> After that I got the "libzxing.lib"
>
> And then I try to use libzxing.lib on Visual C++ Project.
> but I get the error message
> libzxing.lib(DecodeHints.obj) : error LNK2005: "public: static unsigned int const zxing::DecodeHints::CHARACTER_SET" (?CHARACTER_SET@DecodeHints@zxing@@2IB) already defined in stdafx.obj
>
> What I have to do for remove the error message.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "zxing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

NeoDreamer

unread,
Jun 6, 2013, 11:43:35 AM6/6/13
to zx...@googlegroups.com, NeoDreamer
Thanks your answer.

But I do not add "/Za" option to my project.
and same after add "/Za" option.

Steven Parkes

unread,
Jun 6, 2013, 1:40:53 PM6/6/13
to NeoDreamer, zx...@googlegroups.com
I'm not familiar enough with VS to help beyond what I've said (which I know isn't much). Somebody else on the list might have a better idea ...

hico

unread,
Aug 13, 2013, 7:16:21 AM8/13/13
to zx...@googlegroups.com
I also have this problem.
Does somebody resolved this weird issue ?

Sebastian Göbel

unread,
Aug 13, 2013, 10:13:47 AM8/13/13
to zx...@googlegroups.com
The CHARACTER_SET parameter is defined and initialized in DecodeHints.h:

static const DecodeHintType CHARACTER_SET = 1 << 30;

In DecodedHints.cpp is an (unnecessary?) redefinition of this parameter and the visual compiler is not happy about:

line 32: const DecodeHintType DecodeHints::CHARACTER_SET;

Just remove (comment out) this line and rebuild the lib.

hico

unread,
Aug 13, 2013, 11:05:06 AM8/13/13
to zx...@googlegroups.com
Well, actually, you do not need to remove this line.
However, the initialization must be done in the CPP file, not in the .h.
It solved the problem for me ;)

wael...@gmail.com

unread,
Jan 23, 2014, 5:54:04 PM1/23/14
to zx...@googlegroups.com
HI Guys,
I made the modification mentioned before but i still get this Error
if anyone no how to solve it please help!

Joonggun Ha

unread,
Apr 24, 2014, 4:39:57 AM4/24/14
to zx...@googlegroups.com
Did you fix the problem?

Could you send me the lib files(include .dll and .h)?
I could not make lib file cuz of errer.

Pls, help me~!

Message has been deleted

9629...@qq.com

unread,
Apr 22, 2015, 10:35:41 AM4/22/15
to zx...@googlegroups.com
On Tuesday, June 4, 2013 at 11:03:13 PM UTC+8, NeoDreamer wrote:
> I was build ZXing static library by CMAKE and Visual C++ 2010.
> After that I got the "libzxing.lib"
>
>
> And then I try to use libzxing.lib on Visual C++ Project.
> but I get the error message 
> libzxing.lib(DecodeHints.obj) : error LNK2005: "public: static unsigned int const zxing::DecodeHints::CHARACTER_SET" (?CHARACTER_SET@DecodeHints@zxing@@2IB) already defined in stdafx.obj
>
>
> What I have to do for remove the error message.

将“DecodeHints.h”文件中第57行: static const DecodeHintType CHARACTER_SET = 1 << 30 语句的赋值操作放在“DecodeHints.cpp”中实现,问题即可解决。
Reply all
Reply to author
Forward
0 new messages