我正在使用 Chris Branson 的 RedLaser MonoTouch 绑定(bind)和来自这里的示例:
https://github.com/chrisbranson/RedLaserSample
首先,为了帮助那些在这个示例项目中也遇到问题的人,我必须更新 makefile 以构建 RedLaser.dll MonoTouch 绑定(bind)和示例 MonoDevelop csproj 以获得实际的应用程序编译。
Chris 提供的 makefile 解压缩了 RedLaser SDK 下载,但 RedLaser 更改了它们的命名约定,因此它不再起作用。我简化了它,而是要求用户手动将 libRedLaserSDK.a 文件放入构建目录:
BTOUCH=/Developer/MonoTouch/usr/bin/btouch
BUILDVER=build139
VERSION=3.2.4
BINDIR=./bin/
all: $(BINDIR)RedLaser.dll
$(BINDIR)libRedLaserSDK.a:
@echo "You'll need to obtain a copy of RedLaserDevSDK-$(VERSION).zip from"
@echo "http://redlaser.com/sdk/index.php"
@echo Locate the libRedLaserSDK.a file and place within
@echo $(BINDIR)
@echo
@open http://redlaser.com/sdk/index.php
@exit 1
$(BINDIR)RedLaser.dll: Makefile AssemblyInfo.cs RedLaser.cs enums.cs $(BINDIR)libRedLaserSDK.a
$(BTOUCH) --out=$@ -e RedLaser.cs enums.cs AssemblyInfo.cs --link-with=$(BINDIR)libRedLaserSDK.a,libRedLaserSDK.a
clean:
-rm -rf $(BINDIR)*.dll
包含 makefile 的目录还应包含文件
redlaser.cs
、 enums.cs
和 AssemblyInfo.cs
(即与 Chris 的相同)。 我认为这停止工作的原因是 MonoDevelop 或 MonoTouch 中的错误以及它在包含引号时扩展“附加 mtouch 参数”的方式。克里斯的原始论点如下所示:
-cxx -gcc_flags="-framework SystemConfiguration -framework CFNetwork -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework OpenGLES -framework Security -L${ProjectDir}/Lib -lRedLaserSDK -ObjC"
MonoDevelop 没有正确解析它,而是在每个选项周围插入引号,以空格分隔。查看构建输出(在“编译为 native 代码”下)表明这已扩展为:
"/Users/tyson/Downloads/chrisbranson-RedLaserSample-1a5545f-1/RedLaserSample/Lib/RedLaser.dll" -debug -nolink -sdk "5.1" -targetver "5.1" --armv7 "-cxx" "-gcc_flags=\"-framework" "SystemConfiguration" "-framework" "CFNetwork" "-framework" "CoreVideo" "-framework" "CoreMedia" "-framework" "AVFoundation" "-framework" "OpenGLES" "-framework" "Security" "-L/Users/tyson/Downloads/chrisbranson-RedLaserSample-1a5545f-1/RedLaserSample/Lib" "-lRedLaserSDK" "-ObjC\""
解决方案包括在整个 'gcc_flags' 选项周围添加显式引号,手动转义内部引号。例如:
"-cxx" "-gcc_flags=\"-framework SystemConfiguration -framework CFNetwork -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework OpenGLES -framework Security -L${ProjectDir}/Lib -lRedLaserSDK -ObjC\""
这正确扩展为:
"/Users/tyson/Downloads/chrisbranson-RedLaserSample-1a5545f-1/RedLaserSample/Lib/RedLaser.dll" -debug -nolink -sdk "5.1" -targetver "5.1" --armv7 "-cxx" "-gcc_flags=\"-framework SystemConfiguration -framework CFNetwork -framework CoreVideo -framework CoreMedia -framework AVFoundation -framework OpenGLES -framework Security -L/Users/tyson/Downloads/chrisbranson-RedLaserSample-1a5545f-1/RedLaserSample/Lib -lRedLaserSDK -ObjC\""
好的,现在我已经编译了它,我试图在我的手机上运行它。该应用程序加载良好,并通过
RedLaserSDK.CheckReadyStatus()
函数成功调用 RedLaser SDK。但是,一旦我点击扫描按钮(加载 BarcodePickerController
),它就会崩溃,并在 RedLaser SDK 深处出现 native 异常:terminate called throwing an exception
Native stacktrace:
0 RedLaserSample 0x0159d62d mono_handle_native_sigsegv + 244
1 RedLaserSample 0x015b6251 sigabrt_signal_handler + 112
2 libsystem_c.dylib 0x319b67ed _sigtramp + 48
3 libsystem_c.dylib 0x319ac20f pthread_kill + 54
4 libsystem_c.dylib 0x319a529f abort + 94
5 libc++abi.dylib 0x34fb1f6b abort_message + 46
6 libc++abi.dylib 0x34faf34d _ZL17default_terminatev + 24
7 libobjc.A.dylib 0x358e536f _objc_terminate + 170
8 libc++abi.dylib 0x34faf3c5 _ZL19safe_handler_callerPFvvE + 76
9 libc++abi.dylib 0x34faf451 _ZdlPv + 0
10 libc++abi.dylib 0x34fb079f __cxa_throw + 122
11 RedLaserSample 0x000404a9 _ZN5zxing6qrcode19FinderPatternFinder18selectBestPatternsEv + 172
12 RedLaserSample 0x000415e9 _ZN5zxing6qrcode19FinderPatternFinder4findERKNS_11DecodeHintsE + 512
13 RedLaserSample 0x0003a7f7 _ZN5zxing6qrcode8Detector6detectERKNS_11DecodeHintsE + 366
14 RedLaserSample 0x00046b97 _ZN5zxing6qrcode12QRCodeReader6decodeENS_3RefINS_12BinaryBitmapEEENS_11DecodeHintsE + 130
15 RedLaserSample 0x0004ec35 _ZN5zxing6Reader6decodeENS_3RefINS_12BinaryBitmapEEE + 240
16 RedLaserSample 0x00058455 -[FormatReader decode:] + 116
17 RedLaserSample 0x00013835 -[ZXingDecoder findCodesInBitmap:bytesPerRow:width:height:] + 656
18 RedLaserSample 0x0005f6af -[BarcodePhotoEngine zxingFindBarcodesInPixmap:] + 222
19 RedLaserSample 0x00055f25 __38-[BarcodeEngine findBarcodesInPixMap:]_block_invoke_059 + 76
20 libdispatch.dylib 0x34635c59 _dispatch_call_block_and_release + 12
21 libdispatch.dylib 0x34637d0f _dispatch_queue_drain + 274
22 libdispatch.dylib 0x34637b75 _dispatch_queue_invoke$VARIANT$mp + 40
23 libdispatch.dylib 0x346387e7 _dispatch_worker_thread2 + 210
24 libsystem_c.dylib 0x31967dfb _pthread_wqthread + 294
25 libsystem_c.dylib 0x31967cd0 start_wqthread + 8
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
运行非常相似的 RedLaser Xcode 示例项目(即没有 MonoTouch 参与,所有的objective-c)工作正常。
此外,如果有任何意义,禁用所有条形码扫描类型允许
BarcodePickerController
加载并显示相机 View 。显然,它永远不会检测到条形码。 最佳答案
你提到的崩溃现在是 fixed in the bindings 。
它与 QR 使用 C++ 异常和不正确的链接参数有关。
关于c# - 显示 BarcodePickerController 时,通过 MonoTouch 使用 RedLaser SDK 会崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10041124/