- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为 Chrome 构建一个 Native Client 插件,其中将包含 TesseractOCR 库。我已经使用适用于 linux x86-64 的 glibc NaCL 工具链编译了 leptonica 和 tesseract(以及适当的依赖项)。所有动态链接库都包含在 nmf 中。
当我实际尝试在 chrome 中加载插件时,我在 javascript 控制台上收到以下错误:
updateStatus() hello_tutorial.html:56
pageDidLoad if true hello_tutorial.html:39
NativeClient: NaCl module load failed: Nexe crashed during startup hello_tutorial.html:1
我不确定我是否编译不正确,或者我正在尝试做一些 NaCL/Chrome 无法处理的事情。非常感谢任何建议和帮助!
我确实得到了 LOADING... 来显示等等。
我已经在 Chrome 标志中禁用了 nacl_gdb 调试器(如 this post 和 this post 所建议)。我可以编译和运行 NaCL 教程中的示例。
这是加载插件的 HTML 文件:
<!DOCTYPE html>
<html>
<!--
Copyright (c) 2012 The Native Client Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<title>hello_tutorial</title>
<script type="text/javascript">
HelloTutorialModule = null; // Global application object.
statusText = 'NO-STATUS';
// Indicate load success.
function moduleDidLoad() {
HelloTutorialModule = document.getElementById('hello_tutorial');
updateStatus('SUCCESS');
console.log("moduleDidLoad()");
}
// The 'message' event handler. This handler is fired when the NaCl module
// posts a message to the browser by calling PPB_Messaging.PostMessage()
// (in C) or pp::Instance.PostMessage() (in C++). This implementation
// simply displays the content of the message in an alert panel.
function handleMessage(message_event) {
alert(message_event.data);
}
// If the page loads before the Native Client module loads, then set the
// status message indicating that the module is still loading. Otherwise,
// do not change the status message.
function pageDidLoad() {
if (HelloTutorialModule == null) {
updateStatus('LOADING...');
console.log("pageDidLoad if true");
} else {
// It's possible that the Native Client module onload event fired
// before the page's onload event. In this case, the status message
// will reflect 'SUCCESS', but won't be displayed. This call will
// display the current message.
updateStatus();
console.log("pageDidLoad if false");
}
}
// Set the global status message. If the element with id 'statusField'
// exists, then set its HTML to the status message as well.
// opt_message The message test. If this is null or undefined, then
// attempt to set the element with id 'statusField' to the value of
// |statusText|.
function updateStatus(opt_message) {
console.log("updateStatus()");
if (opt_message)
statusText = opt_message;
var statusField = document.getElementById('status_field');
if (statusField) {
if(statusField.innerHTML.indexOf("..." >= 0)){
statusField.innerHTML = statusText.replace(".", "");
}
else{
if(statusField.innerHTML.indexOf(".." >= 0)){
statusField.innerHTML = statusText + ".";
}
else{
if(statusField.innerHTML.indexOf("." >= 0)){
statusField.innerHTML = statusText + ".";
}
}
}
statusField.innerHTML = statusText;
}
}
</script>
</head>
<body onload="pageDidLoad()">
<h1>Native Client Module HelloTutorial</h1>
<p>
<!-- Load the published .nexe. This includes the 'nacl' attribute which
shows how to load multi-architecture modules. Each entry in the "nexes"
object in the .nmf manifest file is a key-value pair: the key is the
instruction set architecture ('x86-32', 'x86-64', etc.); the value is a URL
for the desired NaCl module.
To load the debug versions of your .nexes, set the 'nacl' attribute to the
_dbg.nmf version of the manifest file.
Note: Since this NaCl module does not use any real-estate in the browser,
it's width and height are set to 0.
Note: The <EMBED> element is wrapped inside a <DIV>, which has both a 'load'
and a 'message' event listener attached. This wrapping method is used
instead of attaching the event listeners directly to the <EMBED> element to
ensure that the listeners are active before the NaCl module 'load' event
fires. This also allows you to use PPB_Messaging.PostMessage() (in C) or
pp::Instance.PostMessage() (in C++) from within the initialization code in
your NaCl module.
-->
<div id="listener">
<script type="text/javascript">
var listener = document.getElementById('listener');
listener.addEventListener('load', moduleDidLoad, true);
listener.addEventListener('message', handleMessage, true);
</script>
<embed name="nacl_module"
id="hello_tutorial"
width=0 height=0
src="hello_tutorial.nmf"
type="application/x-nacl" />
</div>
</p>
<h2>Status</h2>
<div id="status_field">NO-STATUS</div>
</body>
</html>
这是我要为插件编译的 C++ 文件:
#include <cstdio>
#include <string>
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/var.h"
#include <baseapi.h>
#include <allheaders.h>
/// The Instance class. One of these exists for each instance of your NaCl
/// module on the web page. The browser will ask the Module object to create
/// a new Instance for each occurence of the <embed> tag that has these
/// attributes:
/// type="application/x-nacl"
/// src="hello_tutorial.nmf"
/// To communicate with the browser, you must override HandleMessage() for
/// receiving messages from the browser, and use PostMessage() to send messages
/// back to the browser. Note that this interface is asynchronous.
class HelloTutorialInstance : public pp::Instance {
public:
/// The constructor creates the plugin-side instance.
/// @param[in] instance the handle to the browser-side plugin instance.
explicit HelloTutorialInstance(PP_Instance instance) : pp::Instance(instance)
{}
virtual ~HelloTutorialInstance() {}
/// Handler for messages coming in from the browser via postMessage(). The
/// @a var_message can contain anything: a JSON string; a string that encodes
/// method names and arguments; etc. For example, you could use
/// JSON.stringify in the browser to create a message that contains a method
/// name and some parameters, something like this:
/// var json_message = JSON.stringify({ "myMethod" : "3.14159" });
/// nacl_module.postMessage(json_message);
/// On receipt of this message in @a var_message, you could parse the JSON to
/// retrieve the method name, match it to a function call, and then call it
/// with the parameter.
/// @param[in] var_message The message posted by the browser.
virtual void HandleMessage(const pp::Var& var_message) {
// TODO(sdk_user): 1. Make this function handle the incoming message.
}
};
/// The Module class. The browser calls the CreateInstance() method to create
/// an instance of your NaCl module on the web page. The browser creates a new
/// instance for each <embed> tag with type="application/x-nacl".
class HelloTutorialModule : public pp::Module {
public:
HelloTutorialModule() : pp::Module() {}
virtual ~HelloTutorialModule() {}
/// Create and return a HelloTutorialInstance object.
/// @param[in] instance The browser-side instance.
/// @return the plugin-side instance.
virtual pp::Instance* CreateInstance(PP_Instance instance) {
return new HelloTutorialInstance(instance);
}
};
namespace pp {
/// Factory function called by the browser when the module is first loaded.
/// The browser keeps a singleton of this module. It calls the
/// CreateInstance() method on the object you return to make instances. There
/// is one instance per <embed> tag on the page. This is the main binding
/// point for your NaCl module with the browser.
Module* CreateModule() {
return new HelloTutorialModule();
}
} // namespace pp
它的编译命令:
/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++ hello_tutorial.cc -o hello_tutorial_x86_64.nexe -I/var/www/native_client/projects/leptonica_src/src -I/var/www/native_client/projects/tesseract_build/include/tesseract -I/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/include/glib-2.0 -I/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/include/webp -I/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/include/libpng12 -I/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/include -I/var/www/native_client/projects/leptonica_src/src -I/var/www/native_client/nacl_sdk/pepper_26/include -L/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/lib -L/var/www/native_client/projects/leptonica_src/src/.libs -L/var/www/native_client/projects/tesseract_build/lib -lppapi_cpp -lppapi -pthread -lglib-2.0 -lstdc++ -ldl -lz -lwebp -lpng -ltesseract -llept -lnosys -lm
我用来编译 leptonica 的命令:
> ./configure --host=nacl SOURCES="-I/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/include" AR="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/bin/ar" CC="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++" CFLAGS=" -g -O2 -fPIC -I/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/include/webp -I/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/include" CPP="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++ -E" CXX="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++" CXXCPP="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++ -E" CXXFLAGS="-g -O2 -fPIC " LD="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-ld -L /var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/lib -lplatform -ldl" NM="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-nm -B" OBJDUMP="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-objdump" RANLIB="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-ranlib" ac_ct_CXX="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++"
> MAKE
编译Tesseract
> ./configure --host=nacl --prefix=/var/www/native_client/projects/tesseract_build SOURCES="-I/var/www/native_client/projects/leptonica_src_compiled_x86-64/src" AR="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/bin/ar" CC="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++" CFLAGS=" -g -O2 -fPIC -I/var/www/native_client/projects/leptonica_src_compiled_x86-64/src" CPP="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++ -E" CXX="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++" CXXCPP="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++ -E" CXXFLAGS="-g -O2 -fPIC -I/var/www/native_client/projects/leptonica_src_compiled_x86-64/src" LD="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-ld -L/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/lib -L/var/www/native_client/projects/leptonica_src_compiled_x86-64/src/.libs -lplatform -ldl" LIBLEPT_HEADERSDIR="/var/www/native_client/projects/leptonica_src_compiled_x86-64/src" LIBS="-L/var/www/native_client/projects/leptonica_src/src/.libs -L/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/usr/lib -llept -lpng -lwebp -lz" NM="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-nm -B" OBJDUMP="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-objdump" RANLIB="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-ranlib" ac_ct_CXX="/var/www/native_client/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/bin/x86_64-nacl-g++"
> MAKE
最佳答案
尝试调试可能是最简单的方法。参见 https://developers.google.com/native-client/devguide/devcycle/debugging#gdb
上面的链接提供了很多细节,但这里是基础知识:
--enable-nacl-debug
运行 chrome,然后导航到您的页面。 NEXE 不会加载,而是等待调试器连接。$NACL_SDK_ROOT/toolchain/linux_x86_newlib/bin/x86_64-nacl-gdb
nacl-manifest hello_tutorial.nmf
然后 target remote :4014
(上面的链接提到运行 nacl-irt ...
同样,如果崩溃不在您的代码中,它也会提供额外的信息,但通常是不必要的)c
继续bt
以打印堆栈回溯。关于c++ - 使用 tesseract 库的 Native Client 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16906600/
#include using namespace std; class C{ private: int value; public: C(){ value = 0;
这个问题已经有答案了: What is the difference between char a[] = ?string?; and char *p = ?string?;? (8 个回答) 已关闭
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 此帖子已于 8 个月
除了调试之外,是否有任何针对 c、c++ 或 c# 的测试工具,其工作原理类似于将独立函数复制粘贴到某个文本框,然后在其他文本框中输入参数? 最佳答案 也许您会考虑单元测试。我推荐你谷歌测试和谷歌模拟
我想在第二台显示器中移动一个窗口 (HWND)。问题是我尝试了很多方法,例如将分辨率加倍或输入负值,但它永远无法将窗口放在我的第二台显示器上。 关于如何在 C/C++/c# 中执行此操作的任何线索 最
我正在寻找 C/C++/C## 中不同类型 DES 的现有实现。我的运行平台是Windows XP/Vista/7。 我正在尝试编写一个 C# 程序,它将使用 DES 算法进行加密和解密。我需要一些实
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
有没有办法强制将另一个 窗口置于顶部? 不是应用程序的窗口,而是另一个已经在系统上运行的窗口。 (Windows, C/C++/C#) 最佳答案 SetWindowPos(that_window_ha
假设您可以在 C/C++ 或 Csharp 之间做出选择,并且您打算在 Windows 和 Linux 服务器上运行同一服务器的多个实例,那么构建套接字服务器应用程序的最明智选择是什么? 最佳答案 如
你们能告诉我它们之间的区别吗? 顺便问一下,有什么叫C++库或C库的吗? 最佳答案 C++ 标准库 和 C 标准库 是 C++ 和 C 标准定义的库,提供给 C++ 和 C 程序使用。那是那些词的共同
下面的测试代码,我将输出信息放在注释中。我使用的是 gcc 4.8.5 和 Centos 7.2。 #include #include class C { public:
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我的客户将使用名为 annoucement 的结构/类与客户通信。我想我会用 C++ 编写服务器。会有很多不同的类继承annoucement。我的问题是通过网络将这些类发送给客户端 我想也许我应该使用
我在 C# 中有以下函数: public Matrix ConcatDescriptors(IList> descriptors) { int cols = descriptors[0].Co
我有一个项目要编写一个函数来对某些数据执行某些操作。我可以用 C/C++ 编写代码,但我不想与雇主共享该函数的代码。相反,我只想让他有权在他自己的代码中调用该函数。是否可以?我想到了这两种方法 - 在
我使用的是编写糟糕的第 3 方 (C/C++) Api。我从托管代码(C++/CLI)中使用它。有时会出现“访问冲突错误”。这使整个应用程序崩溃。我知道我无法处理这些错误[如果指针访问非法内存位置等,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我有一些 C 代码,将使用 P/Invoke 从 C# 调用。我正在尝试为这个 C 函数定义一个 C# 等效项。 SomeData* DoSomething(); struct SomeData {
这个问题已经有答案了: Why are these constructs using pre and post-increment undefined behavior? (14 个回答) 已关闭 6
我是一名优秀的程序员,十分优秀!