On Windows, how to run Google's Native Client run outside of Chrome? - google-nativeclient

This question is specifically about Windows (64-bit).
A similar question was asked here, but the answers appear to be specific to Linux (and perhaps OS X).
The non-Windows answer is to use sel_ldr but no such file is present in a Chrome install on Windows. nacl64.exe seem like it is the file that files the same function. This page mentions the "NaCl Process" and that even though Chrome is 32-bit process on x64 Windows, sel_ldr needs to be 64-bit and thus a separate process. I also see nacl64.exe running when my plug-in is loaded, and not running when when I just start Chrome without a NaCl plug-in loaded.
The NaCl plug-in for Visual Studio requires being run on 64-bit windows, thus the comments about 64-bit above.
On this page I found an example that was reported as successful on Linux:
~/nacl_sdk/pepper_19/tools/sel_ldr_x86_64 -B ~/nacl_sdk/pepper_19/tools/irt_x86_64.nexe hello_x86_64.nexe
and here I found this example also for Linux:
/home/ubuntu/nacl_sdk/pepper_19/tools/sel_ldr_x86_32 -a -S -B /home/ubuntu/nacl_sdk/pepper_19/tools/irt_core_x86_32.nexe <plug-in path>
so I tried some commands modeled on that but all have resulted in nacl64.exe crashing:
<user directory>\AppData\Local\Google\Chrome\Application\23.0.1271.91>nacl64.exe -B nacl_irt_x86_64.nexe <NaCL SDK root>\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\NaCl64\newlib\Debug\hello_nacl_cpp_64.nexe
d:\><user directory>\AppData\Local\Google\Chrome\Application\23.0.1271.64\nacl64.exe -B <user directory>\AppData\Local\Google\Chrome\Application\23.0.1271.64\nacl_irt_x86_64.nexe <NaCL SDK root>\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\NaCl64\newlib\Debug\hello_nacl_cpp_64.nexe
d:\><user directory>\AppData\Local\Google\Chrome\Application\23.0.1271.64\nacl64.exe -a -S -B <user directory>\AppData\Local\Google\Chrome\Application\23.0.1271.64\nacl_irt_x86_64.nexe <NaCL SDK root>\vs_addin\examples\hello_nacl_cpp\hello_nacl_cpp\NaCl64\newlib\Debug\hello_nacl_cpp_64.nexe
and I've verified that hello_nacl_cpp_64.nexe works when run in Chrome via a web page.
So then the question is, on Windows, how does one successfully run Google's Native Client run outside of Chrome?

You can find sel_ldr.exe and non-browser IRT in NaCl SDK in pepper_<version>/tools folder.
Note that NaCl application can't be run successfully both in browser and sel_ldr. Browser application shouldn't have main, command line application must have it. Also command line application can not use Pepper APIs since sel_ldr doesn't implement them.

Related

ConEmu to Linux via ssh, ***without*** cygwin

I am using ConEmu 150504 under Windows 10 Enterprise, release 21H2, and I am having some problems when connecting to a linux host via ssh.
There is no cygwin installation at all. Every Windows utility, including ssh, is a non-cygwin version. I mention this here because other similar questions that I have found involve the use of cygwin's ssh, but I want to make it clear that I am not using the cygwin version of ssh nor any other cygwin software.
From within my ConEmu window, I can successfully connect to my linux host, as follows ...
ssh myuserid#the.host.name.com
Once connected to my linux host, I want to use various curses-based and other console-based utilties, including emacs -nw. I have export TERM=xterm properly set in my linux shell, but I am only getting partial console capability.
By "partial", I mean that ANSI color codes are not being honored, and certain control characters are not being honored.
Is there some way to set up ConEmu so that it is totally, completely, 100-percent emulating full xterm capabilities and full ANSI character-code management?
Thank you in advance for any thoughts and suggestions.
PS: setting export TERM=xterm-color and export TERM=xterm-256color in linux don't help at all when I'm using ConEmu.

How i can get Ubuntu terminal's list from Qt

In my app i want to open ssh in terminal-emulator for user. Now i'am using QProcess like this:
QProcess _localhostConnection;
_localhostConnection.start(QString("gnome-terminal"), QStringList("--command=ssh 127.0.0.1"));
But the problem is there can be no gnome-terminal on another computer. Another computer has Ubuntu. How can i get installed terminal's list in Qt on Ubuntu?
Try calling x-terminal-emulator instead. Almost all Debian-based systems use the update-alternatives package (in conjunction with virtual packages like x-terminal-emulator) to bookkeep programs with similar functions, such as Internet browsers, editors, command shells, et cetra. Calling x-terminal-emulator will launch the default terminal emulator set by the user.
Read more about update-alternatives here: https://manpages.ubuntu.com/manpages/xenial/en/man1/update-alternatives.1.html
However, hardcoding --command=ssh 127.0.0.1 isn't very wise if you are aiming to support all terminal emulators. XTerm, for example, won't accept that parameter syntax.

Execute this command line in Windows

I'm trying to connect my firebase auth to an expo project.
I'm following the main docs of each library. I'm stucking on this step.
I'm not able in windows to exeute this command line openssl rand -base64 32 | openssl sha1 -c.
I've tried with the specific https://code.google.com/archive/p/openssl-for-windows/downloads but I don't know how to reproduce the same line.
Any help would be great, thanks in advance.
You need to install openssl. It is usually available on Linux (which I think that article might have been written for). There are some Windows binaries available at here. Alternatively, you could setup a WSL session, and run the command from there.
that is a linux command. Therefore a linux terminal is needed.
there are at least 2 ways to get this done
using virtual machine with ubuntu or some other operating system that uses a linux terminal aka shell (which I doubt you know about)
OR
installing a linux emulator (windows 8+ since it's from the windows store)
assuming you would prefer option 2, go to the windows store, search "Kali" and you will find an app called Kali. install it and if an error shows up, here's a nice video here that talks about solving that error and you would have a kali terminal on your windows computer (your command would work there)

Can I execute a Linux binary from a Windows application?

I want to execute a Linux binary from a QT application running on W10.
In QT we have QProcess to launch additional processes. However, since my binary is for Linux, I've thought of two possible approaches:
Running the binary in a container (i.e.: Docker, Kubernetes, Singularity...).
Executing the binary through WSL (Ubuntu) bash.
In any case, the QT application should initiate the process (the container or the bash) and, in turn, this process should launch my binary.
I've been searching on the web and I could not find something related, what makes me think that it will be difficult. For this reason, I am posting the question in order to know the viability of the proposed approaches.
EDITED
It looks like the WSL is easier, the problem is that the user has to have install ed it. Apart from requiring the sudo password when installing new software via apt-get.
The binary that I have to execute only exists for Linux, and let's say that cross-compiling is dismissed because of its complexity. Furthermore, this application needs CGAL, BOOST, MPI, among other pieces of software.
If you want to go with WSL, you can just run wsl myLinuxProgram --options.
Using WSL is the easiest way I believe as the current directory (PWD), is the current one i.e. the same as the PWD of your Qt app.
You can read Microsoft documenation for more info: https://learn.microsoft.com/en-us/windows/wsl/interop
If your linux binary depends on a lots of things, I really suggest you use docker for windows. Then, you have chance to pre-build an own docker image which put all dependency software also the linux binary you need to run in it.
Of course, to let your customer to use it, you should put it to dockerhub, register an account for yourself.
Then, the solution is simple: let the QT application to call docker run to setup a container base on your own image, execute it, and also let the linux binary to write the log or others to the bind mount volume among linux container & windows. After it run, the QT application fetch the linux binary output from this shared folder.
Finally, I give a minimal workable example for your reference:
Suppose the shared folder between windows & linux container is: C:\\abc\\log_share, it will mapped to linux container as /tmp folder. Of course you need to allow volume share by right click the docker icon in windows tray area & choose settings, like described here
Simplify the windows application as bat file, and simplfy the docker image as ubuntu, you should use your own prebuilt docker image with all dependency in it:
win_app.bat:
ECHO OFF
::New a shared folder with linux container
RD /s/q C:\\abc\\log_share > NUL 2>&1
MKDIR C:\\abc\\log_share
::From windows call docker to execute linux command like 'echo'
echo "Start to run linux binary in docker container..."
docker run -it -v C:\\abc\\log_share:/tmp ubuntu:16.04 bash -c "echo 'helloworld' > /tmp/linux_log_here.txt"
::In windows, get the log from shared bind mount from linux
echo "Linux binary run finish, print the log generated by the container..."
type C:\\abc\\log_share\linux_log_here.txt
Simplify the linux binary just as echo command in linux, the output things should be all write to shared directory:
echo 'helloworld' > /tmp/linux_log_here.txt
Now, execute the bat file with command win_app.bat:
C:\abc>win_app.bat
C:\abc>ECHO OFF
"Start to run linux binary in docker container..."
"Linux binary run finish, print the log generated by the container..."
helloworld
You can see the windows application already could fetch things(here is helloworld) which generated by linux binary from docker container.

Why does configure.sh think win32 is Unix?

I'm trying to build an application from source in windows that requires some Unix tools. I think it's the apparently standard ./configure; make; make install (there's no INSTALL file). First I tried MinGW but got confused that there was no bash, autoconf, m4, or automake exes in \bin. I'm sure I missed something obvious but I installed Cygwin anyways just to move forward. For some reason when I run
sh configure.sh
I get:
platform unix
compiler cc
configuration directory ./builds/unix
configuration rules ./builds/unix/unix.mk
My OS has identity problems. Obviously the makefile is all wrong since I'm not on unix but win32. Why would the configure script think this? I assume it has something to do with Cygwin but if I remove that I can't build it at all. Please help; I'm very confused.
Also is it possible to build using MinGW? What's the command for bash and is mingw32-make the same as make? I noticed they're different sizes.
Everything is fine. When you are inside CygWin, you are basically emulating an UNIX. sh runs inside CygWin, and thus identifies the OS correctly as Unix.
Have a look at GCW - The Gnu C compiler for Windows
Also, you might be interested in this help page, that goes into some detail about the minimal system (MSYS), such as how to install, configure et. c.
That should help you get bash, configure and the rest to work for MinGW as well.
From the Cygwin home page
Cygwin is a Linux-like environment for Windows. It consists of two parts:
A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
A collection of tools which provide Linux look and feel.
Since configure is using the Cygwin environment, it is interacting against the emulation layer and so it is just like it's working on a Unix environment.
Have you tried building the application and seeing if it works?

Resources