'QRCodeReader' was not declared in this scope

104 views
Skip to first unread message

Vinicius

unread,
Jul 4, 2010, 2:16:29 PM7/4/10
to zxing
Hi Guys!!

I`m starting use ZXing for iPhone and i was trying compile a project
using the ScanTest as example. But i`m having some problems when i try
use QRCodeReader as below:

#import "QRCodeReader.h"

...

QRCodeReader *qrCodeReader = [[QRCodeReader alloc] init];


and i received this message 'QRCodeReader' was not declared in this
scope.

yes i already include ZXingWidget in my project and i already link the
headers.



I`'m sorry for my poor english...

Thanks in advance!

Romain

unread,
Jul 4, 2010, 3:34:11 PM7/4/10
to zxing
Maybe renaming your file from .m into .mm should help.

Vinicius

unread,
Jul 4, 2010, 11:53:03 PM7/4/10
to zxing
Thx for your answer, but i already did that and it didnt work.... i
renamed the file where i'm using QRCodeReader and the main.m i renamed
to main.mm

Romain

unread,
Jul 5, 2010, 3:30:32 AM7/5/10
to zxing

Strange. Could be that your import is not resolved as you expect.
What I would do : rename QRCodeReader.h into something else and check
that your import fails. My guess is that your not importing the objc
QRcodereader but the c++ one.

Romain

Vinicius

unread,
Jul 5, 2010, 7:05:45 AM7/5/10
to zxing
Hmmm...... maybe... ill try that, but if the problem is this, how can
i fix this?!

Romain

unread,
Jul 5, 2010, 9:27:19 AM7/5/10
to zxing

Don't worry. It is a typical compiling error. Nothing original that
can't be fixed here. It léans that in importes files, the class
qrcodereader has not been declared, which is why I think you did not
import the right file

Vinicius

unread,
Jul 5, 2010, 9:59:24 AM7/5/10
to zxing
Ok i undestand but i'm using the ScanTest example to make my app... i
will paste my code here and you tell what i did wrong


#import "myQrCodeViewController.h"
#import "QRCodeReader.h"

@interface myQrCodeViewController()

@end


@implementation myQrCodeViewController

@synthesize resultsText;
@synthesize resultsToDisplay;


- (IBAction)scanPressed:(id) sender {

ZXingWidgetController *widController = [[ZXingWidgetController alloc]
initWithDelegate:self showCancel:YES OneDMode:NO];
QRCodeReader *qrCodeReader = [[QRCodeReader alloc] init];
NSSet *readers = [[NSSet alloc] initWithObjects:qrCodeReader, nil];
[qrCodeReader release];

widController.readers = readers;
[readers release];

NSBundle *mainBundle = [NSBundle mainBundle];
[widController setSoundToPlay:[[NSURL fileURLWithPath:[mainBundle
pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO] retain]];
[self presentModalViewController:widController animated:YES];

[widController release];

when i try compile this i receive: 'QRCodeReader' was not declared in
this scope.....

how i'm importing the wrong file?? If the exists QRCodeReader.h and
i'm certainly using that.... but there is another in cpp class
files.... and i probably loading that instead of objc
QRCodeReader.h... how can i load the right file?!?!

Romain

unread,
Jul 5, 2010, 11:16:48 AM7/5/10
to zxing
Ok,

Having 2 headers with same name was not a great idea.

However, if you have the right project settings, #import
QRCodeReader.h only point to the ObjC one, because the other one
should only be accessible with #include "zxing/qrcode/
QRCodeReader.h" . If you are actually importing the later one, then it
means you have checked "recursive" box when you have specified path
like "../../cpp/core/src" in your project settings.

Did you try to rename the ObjC one to check if the #import was still
working ? Then you should also check that your project settings
disallow recursive mode for cpp sources.

Cheers,

Romain

Vinicius

unread,
Jul 5, 2010, 5:07:05 PM7/5/10
to zxing
ahhh ok! Good idea! I will do that!! But when i renamed the
QRCodeReader.h my the #import doesn't fail.... it means my #import
"QRCodeReader.h" is pointing the cpp one....

I will try uncheck the rescursive mode for cpp sources and see if this
works.

Romain

unread,
Jul 6, 2010, 3:21:13 AM7/6/10
to zxing
I can tell you it will work :)

Vinicius

unread,
Jul 6, 2010, 11:19:25 PM7/6/10
to zxing
Ok it works!! But i had another problem =(
now when i compile, i receive this message of error:

ld: warning: unsigned long const& std::min<unsigned long>(unsigned
long const&, unsigned long const&)has different visibility (default)
in /Users/Vinicius/Projects/iPhone/myProjects/zxing-qrcode/zxing-read-
only/iphone/ZXingWidget/build/Debug-iphonesimulator/
libZXingWidget.a(QRCodeReader-F470BE6889D3F76D.o) and (hidden) in /
Users/Vinicius/Projects/iPhone/myProjects/myQrCode/build/
myQrCode.build/Debug-iphonesimulator/myQrCode.build/Objects-normal/
i386/myQrCodeViewController.o

ld: warning: unsigned long const& std::min<unsigned long>(unsigned
long const&, unsigned long const&)has different visibility (default)
in /Users/Vinicius/Projects/iPhone/myProjects/zxing-qrcode/zxing-read-
only/iphone/ZXingWidget/build/Debug-iphonesimulator/
libZXingWidget.a(FormatReader.o) and (hidden) in /Users/Vinicius/
Projects/iPhone/myProjects/myQrCode/build/myQrCode.build/Debug-
iphonesimulator/myQrCode.build/Objects-normal/i386/
myQrCodeViewController.o

Undefined symbols:

"_AudioServicesPlaySystemSound", referenced from:
-[ZXingWidgetController presentResultForString:] in
libZXingWidget.a(ZXingWidgetController.o)

"_AudioServicesCreateSystemSoundID", referenced from:
-[ZXingWidgetController viewWillAppear:] in
libZXingWidget.a(ZXingWidgetController.o)

"_iconv_close", referenced from:

zxing::qrcode::DecodedBitStreamParser::append(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, unsigned char const*,
unsigned long, char const*)in
libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)

zxing::qrcode::DecodedBitStreamParser::append(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, unsigned char const*,
unsigned long, char const*)in
libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)

"_iconv", referenced from:

zxing::qrcode::DecodedBitStreamParser::append(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, unsigned char const*,
unsigned long, char const*)in
libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)
"_AudioServicesDisposeSystemSoundID", referenced from:
-[ZXingWidgetController dealloc] in
libZXingWidget.a(ZXingWidgetController.o)

"_iconv_open", referenced from:

zxing::qrcode::DecodedBitStreamParser::append(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, unsigned char const*,
unsigned long, char const*)in
libZXingWidget.a(DecodedBitStreamParser-64E27B33E79CBC52.o)

ld: symbol(s) not found
collect2: ld returned 1 exit status

Vinicius

unread,
Jul 8, 2010, 12:17:28 AM7/8/10
to zxing
anyone know how resolve that? Someon already had this problem?
Reply all
Reply to author
Forward
0 new messages