1. Do we always need
pp::Instance class HandleMessage(), PostMessage())
pp::Module class
pp::Var class
to be implemented in our code to make communication possible between browser and pNaCl library.
2. Can we have any document stored in hard disk of the system and it can be accessible from chrome browser through pNaCl library? How ?
3. Does communication between chrome browser and pNaCl library only a possibility or is it possible between chrome extension and pNaCl and also between chrome app and pNaCl?
4. Does chrome browser has capability of storage while processing or communicating with pNaCl library and how?
Thanks in advance for the guidance.
With best regards,
Anoop.
./pnacl-clang++ hello.pexe hello_tutorial.cc -Inacl_sdk/pepper_47/include/ -L/home/anoop/testProgram -lLIB.a
hello_tutorial.cc:65:5: warning: 'auto' type specifier is a
C++11 extension [-Wc++11-extensions]
auto message =
var_message.AsString();
^
1 warning generated.
pnacl-ld: Cannot find '-lLIB.a'
3. Is there a way that chrome saves a document into a file system and pnacl can read the document from that file system? What type of file system is it? What are the API’s? Is there any example?
I appreciate your help in advance.
Thanks & regards,
Anoop.
./pnacl-clang++ hello.pexe hello_tutorial.cc -Inacl_sdk/pepper_47/include/ -L/home/anoop/testProgram -lLIB.a
hello_tutorial.cc:65:5: warning: 'auto' type specifier is a
C++11 extension [-Wc++11-extensions]
auto message =
var_message.AsString();
^
1 warning generated.
pnacl-ld: Cannot find '-lLIB.a'
3. Is there a way that chrome extension saves a document into a file system and pnacl can read the document from that file system? What type of file system is it? What are the API’s? Is there any example?
I appreciate your help in advance.
Thanks & regards,
Anoop.
Hi Sam,
Thanks for great response. I understood how can i create multiple .pexe and use them in browser through embed tag.
A question regarding building .pexe. I built static library using pnacl toolchain separately "LIB.a", and then I want to get .pexe out of it by compiling hello_tutorial.cc file and including "LIB.a", i tried this command, but it threw error:
./pnacl-clang++ hello.pexe hello_tutorial.cc -Inacl_sdk/pepper_47/include/ -L/home/anoop/testProgram -lLIB.a
hello_tutorial.cc:65:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto message = var_message.AsString();
^
1 warning generated.
pnacl-ld: Cannot find '-lLIB.a'
I have copied "LIB.a" at specified place. What could be wrong here?
2. Could you please point me a Sample code to how to use ppapi lib directly or ppapi_simple in view of getting a document from javascript into .pexe and send it to a specific API present in static library which was built with .pexe as above?
3. Is there a way that chrome saves a document into a file system and pnacl can read the document from that file system? What type of file system is it? What are the API’s? Is there any example?
I appreciate your help in advance.
Thanks & regards,
Anoop.
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="t
Hi Sam,
Thanks for great response. I understood how can i create multiple .pexe and use them in browser through embed tag.
A question regarding building .pexe. I built static library using pnacl toolchain separately "LIB.a", and then I want to get .pexe out of it by compiling hello_tutorial.cc file and including "LIB.a", i tried this command, but it threw error:
./pnacl-clang++ hello.pexe hello_tutorial.cc -Inacl_sdk/pepper_47/include/ -L/home/anoop/testProgram -lLIB.a
hello_tutorial.cc:65:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto message = var_message.AsString();
^
1 warning generated.
pnacl-ld: Cannot find '-lLIB.a'
I have copied "LIB.a" at specified place. What could be wrong here?
I appreciate your help in advance.
Thanks & regards,
Anoop.
Hi Sam,
Thanks for the valuable guidance.1. Is there a way that chrome extension saves a document into a file system and pnacl can read the document from that file system? What type of file system is it? What are the API’s to support it? Is there any example? Please also point a link where I can read about it.
2. Could you please point me a Sample code to how to use ppapi lib directly or ppapi_simple in view of getting a document from javascript(chrome extension or browser) into .pexe and send it to a specific function present in static library which was built with .pexe ?
Hi Ben,
Thanks a lot for the info. I was able to learn through file_io examples as you pointed it.
I have one query, I have a static library (e.g., libwork.a ) which i built using pnacl toolchain. I included this library while building my CPP code to create pexe using pnacl toolchain.
./pnacl-clang++ hello.pexe hello_tutorial.cc -Inacl_sdk/pepper_47/include/ -L/home/anoop/testProgram -lwork
pnacl-finalize -o hello.pexe hello.bc
Could you please tell me how can i test that library (libwork.a) is included in pexe? Like in linux we have commands ldd which tells what all libraries included with executable?
Is there any such command? Let me know if there is any other way of testing it.
...$ llvm-nm graphics_3d_unstripped.bc | c++filt
Hi Ben,
Thanks a lot for the info and corrections.
I want to let you know that all build and operations i am doing on linux(ubuntu) machine.
Actually, I followed these commands to create pexe.
first i ran below command to get hello.o
./pnacl-clang++ -c hello_tutorial.cc -o hello.o -I/home/anoop/nacl_sdk/pepper_47/include/ -L/home/anoop/nacl_sdk/pepper_47/lib/pnacl/Release/ -lwor
then i created .pexe out of it using command
./pnacl-clang++ hello.pexe -o hello.o
and finalized it hello.pexe using this command to generate again hello.pexe only
./pnacl-finalize hello.pexe hello.pexe
I checked this pexe in chrome browser and it works fine.
Do i need to create .bc first mandatorily and not object file? What is the difference b/w two commands ..one uses –c and one –o and create object file.
I created hello.bc file also to follow your instruction
./pnacl-clang++ -c hello_tutorial.cc -o hello.bc -I/home/anoop/nacl_sdk/pepper_47/include/ -L/home/anoop/nacl_sdk/pepper_47/lib/pnacl/Release/ -lwork
# compile hello_tutorial.cc into the object file hello_tutorial.opnacl-clang++ -c hello_tutorial.cc -o hello_tutorial.o -I/home/anoop/nacl_sdk/pepper_47/include/# link hello_tutorial.o into a LLVM bitcode filepnacl-clang++ -o hello.bc hello_tutorial.o -L/home/anoop/nacl_sdk/pepper_47/lib/pnacl/Release -lwork# finalize the LLVM bitcode file into a PNaCl pexepnacl-finalize -o hello.pexe hello.bc
# compile and link in one steppnacl-clang++ -o hello.bc hello_tutorial.c -I/home/anoop/nacl_sdk/pepper_47/include/ -L/home/anoop/nacl_sdk/pepper_47/lib/pnacl/Release -lwork# finalize the LLVM bitcode file into a PNaCl pexepnacl-finalize -o hello.pexe hello.bc
but when i ran pnacl-finalize command like below I got the error
./pnacl-finalize -o hello.pexe hello.bc
LLVM ERROR: Struct types are not supported in PNaCl bitcode
Why is this error? How to fix this?
In your example you have run llvm-nm command on unstripped.bc file so i ran command like below and got the error
llvm-nm hello.bc
llvm-nm: hello.bc: Invalid value.
When i do llvm-nm for hello.pexe it says
llvm-nm: hello.pexe: unrecognizable file type
Some times it says invalid record. What could be the issue?
While building one c file using pnacl-clang i got this error
fatal error: 'net/if.h' file not found
This seems to be that net/if.h is not supported. But this program compiles using gcc on linux but pnacl-clang build on linux shows the above said error. How to fix it?
Hi Ben,
Thanks for elaborated info. It solved almost all issues which i was facing. I am able to link the library successfully and create .pexe.
One more small help i need,
I want my chrome browser to read a file from any supported file system (file which is saved by chrome extension) through pexe and send it as a parameter to my library(lwork) function(e.g., performThis()), something like shown below
hello.cpp
status = performThis("D:/abc.txt", "XX.XX.XX.XX"); //I need to know what to replace at file ("D:/abc.txt") place.
Here i am reading from D drive directlt just to show what i need to do and understand it is not possible perhaps from chrome browser using pnacl library.
How could i achieve this in my cpp file and build it to create pexe?
I will build using the commandpnacl-clang++ -o hello.bc hello.cpp -I/home/anoop/nacl_sdk/pepper_47/include/ -L/home/anoop/nacl_sdk/pepper_47/lib/pnacl/Release -lwork
I think the file_io as you said earlier should be able to do this but I am not sure how? Your guidance will be highly appreciated.
class HelloTutorialInstance : public pp::Instance {
public:
explicit HelloTutorialInstance(PP_Instance instance)
: pp::Instance(instance) {
// initialize nacl file system
nacl_io_init_ppapi(instance, pp::Module::Get()->get_browser_interface());
// mounting html5fs filesystem
int result = mount("", /* source. Use relative URL */
"/fileSystemMount", /* target */
"html5fs", /* filesystemtype */
0, /* mountflags */
""); /* data */
virtual void HandleMessage(const pp::Var& var_message) {
std::string message = var_message.AsString();
int status = 0;
char mount_path[100] = "/fileSystemMount/";
char *messageptr = new char[message.length() + 1];
strcpy(messageptr, message.c_str());
std::strcat(mount_path, messageptr);
status = performAction(mount_path, "XX.XX.XX.XX"); //this function is in the library -lwork
PostMessage(status);
delete [] messageptr;
...
...
Hi Sam and Ben,