How can you embed a C++ game into a webpage? - c++

Without recoding in flash or making it into a java applet! Keeping it as a C++ app, is there a way to embed it into a web page so site visitors can play the game?
We can assume it's a small game, the size of your average flash game or even thinner.
The game in question was written with the Allegro library in under 1000 lines of code.
Is it possible?

Quick answer: no you can't.
C++ applications cannot be embedded inside a web page, they need to be downloaded and the user has to run them on the client machine.
Details: it's somehow possible but it's absolutely not portable across browsers. For example Internet Explorer has ActiveX components (they can be a C++ application, it'll be downloaded, installed and will run inside the web-page). Other browsers have different mechanism to achieve this (Chrome has its Native Client, for example) but you can't write something really portable and you'll have many limitations whatever you'll use.

It is possible
http://doom.pdox.net/
http://code.google.com/p/nativeclient/
In fact, this is old news...
http://www.engadget.com/2010/05/13/googles-native-client-sdk-developer-preview-provides-helpful-re/

Try the emscripten project, it is a C++ compiler based on LLVM Clang and compiles C++ files into JS files which can then be run in the browser.
#include <iostream>
int main()
{
using namespace std;
cout << "Hello World" << endl;
return 0;
}
Assuming that you saved this in helloWorld.cpp use this after installing Emscripten.
$ emcc helloWorld.cpp -o helloWorld.html
You will be done, open helloWorld.html now in your browser and see for yourself. The good thing about Emscripten is that it supports a wide range of desktop libraries, including SDL etc.,
http://kripken.github.io/emscripten-site/

It's possible only as plugin for Google Chrome browser as native extension.

Related

Is there any way to create an executable file using c++ and an online IDE

So here's the situation. I have been using ms access vba for automation at my job. I have access to ms access and notepad++ only with the nppexec plugin. However, g++ is not installed as far as I can tell.
I am looking to use ui automation event handlers but those do not work in vba. Since I have notepad++ i can write out c++ and make that work but in the end, i would like to produce a one click .exe file that runs the add event handlers objects.
The issue is that i cannot compile or run without g++. However I can if I use an online ide. I just need one that will let me download the resulting exe file.
Is there any such tool? Either that or a way to get g++ onto a computer without installing. (Permissions issues)
Thank you.

Run application without GUI on iOS?

I have a C++ library that I want to include into my iOS application. It has unit tests. If I put it simply, it's something like:
#include <cstdio>
int main()
{
printf("Test result\n");
}
Is it possible to run such an application that uses only stdin/stdout on an arm64 based iOS device to make sure that all compiles and works correctly?
I can do it on a real android device with adb push/adb shell, so I wonder, is it possible to do the same on iOS based devices?
It's not completely clear what are you trying to archive. But let me guess:
There is a third-party library you don't have control over.
There're tests in this library. The tests are a separate console app.
And you're looking for a way to run this app in some kind of shell on iOS that can run an arbitrary executables. And you can't because of all the security.
But if you have the source code of unit tests, then with some small changes you can compile them as a library, not as an executable. And call them from a "shell" you can write yourself - a small host app the sole purpose of which is to call these tests (and probably send their results via any kind of connection that suits you).
More on this you can read here
Yes, this host app will have a GUI, but I don't really understand why do you against it... if you really are.
Also these may be helpfull:
debug bridge for iPhone / shell command prompt
ADB equivalent for iOS device

embedding .exe applications on a QT form

I wanted to know if its possible to embed other .exe applications on a QT form.
Say i have an app called foo.exe. Now I want to lauch foo.exe through my application. I know I could do that using QProcess::startDetached() however I would like that program to run within my form.Is that possible ?
Believe what you want is a kind of "EMBED", there seems to be something done, but I can direct you to a few ways:
Cygwin
In X Window System we have o "X-Embed"
For Windows exists Cygwin/X (apparently to run "multi-threaded" in "google chrome" uses cygwin).
QT X11 Systems: http://qt-project.org/doc/qt-4.8/qvfb.html
Nice example: http://arstechnica.com/information-technology/2009/03/experimental-process-per-tab-browser-created-with-qt-xembed/ (outdated)
ActiveX
You can create Activex Controls, see example: http://qt-project.org/doc/qt-4.8/activeqt-server.html
In two suggestions that you spent the programs you want to add to your main program should be created by you, in other words, programs that are not compiled with "Cygwin" or is not an "ActiveX" (QT you can add controls ActiveX, such as Internet Explorer or MSExcel).
Believe both examples programs work as "servers" and its main program as a "client", in other words, other processes need not necessarily one graphical interface, I believe the main software is who works the GUI part.
For this reason the programs should be "embedded" created with the purpose of "embedding"
Alternative solution (DotNet and user32.dll)
See article:
http://www.codeproject.com/Articles/9123/Hosting-EXE-Applications-in-a-WinForm-project

Apply VST audio effect/plugin to audio-file

This is my first question after leeching over here for some time.. So spare me.
I need to apply the iZotope Vinyl VST effect to some audio files via CLI or C++ (so language doesn't really matter), it has to work on a Mac or on a Unix based system. I've researched all over the webs and can't find any working solution.
I've tried using MissWatson, a command line utility, this works but my result audio files are silent...
./MissWatson -plugin=Vinyl -input-file="/Users/Sjaq/Desktop/test.wav" -output-file="/Users/Sjaq/Downloads/MissWatson-v1.0-mac/res.wav" -parameter=1:0.6,2:0.6,11:0.4
Then I tried using the Steinberg VST SDK by creating a host application, starting from the vstvalidator provided by the SDK. But when I try to load the VST I get this error:
2010-12-01 16:57:40.774 vstvalidator[4654:903] Error loading /Library/Audio/Plug-Ins/VST/Vinyl.vst/Contents/MacOS/Vinyl: dlopen(/Library/Audio/Plug-Ins/VST/Vinyl.vst/Contents/MacOS/Vinyl, 262): no suitable image found. Did find:
/Library/Audio/Plug-Ins/VST/Vinyl.vst/Contents/MacOS/Vinyl: no matching architecture in universal wrapper
And I don't know what to do. I'm pretty new to C++ and and made a few apps without any issues, but this time I've hit a dead end.
I've read about pyvst but it seems to need a DLL for the VST so that didn't work either.
I'm the author of MissWatson, and as you probably noticed on the webpage, I unfortunately was required to close-source the code, so I can't really ask you for more diagnostic information, since I wouldn't be able to patch MissWatson if it's a bug there. However, I would recommend running MissWatson with the -verbose switch and perhaps logging that output to file if that floods your terminal. You might find something in that output which helps you to diagnose the problem.
Anyways, as for the error in your VST host, I have a feeling that you are compiling your app as a 64-bit executable and trying to load a 32-bit plugin. Since hardly any VST/AU plugins (and also sequencers, for that matter) have made the leap to 64-bit, you'd be better off just compiling your app as a 32-bit x86 binary.
By default, the "debug" configuration in Xcode only builds your app for the native architecture of your machine to save time during compilation. I would advise that you disable this feature in your project's build settings and always build with the architectures you plan to ship with. This will prevent weird cross-architecture types of errors like the one you saw above.
Edit: I have since started a new command-line VST host to replace MissWatson which is called MrsWatson. You should try using this tool instead.
Perhaps you can port the source code of this open source vst host to match your platforms?
http://www.hermannseib.com/english/vsthost.htm
Scroll down to the bottom of the page.
Hope it helps.

Oracle C++ linux and more weird stuff

So here is the story. I have this device that uses Linux and more open source tools(btw its an ARM). And I was given the task of creating some magic cashier application with it.
I have done it and now my boss have made a new request. He wants me to make that stuff(the device) connect to a remote database(preferably Oracle). So thats what I started doing with the light version of oracle instant client. Everything is fine and cool until I ran my first hello world:
#include <occi.h>
using namespace oracle::occi;
int main(){
Environment *env = Environment::createEnvironment();
Connection *conn = env->createConnection("HR", "password");
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return 0;
}
Linking against occi, clntsh, thread;
And setting the library search path, along other stuff to: "${workspace_loc:/OracleTest/instantclient_10_2}" that is the directory that holds my .so files;
Here is the compilation command:
ucfront-g++ -Wl,-elf2flt="r" -static -o OracleTest ./main.o -locci -lclntsh -lthread -L/usr/local/arm-elf/lib -L"C:\workspace\OracleTest\instantclient_10_2" -L/usr/local/fit-libs/lib
And here is the error:
/usr/local/arm-elf/bin/ld.real: cannot find -locci collect2: ld returned 1 exit status
And there are a few things that I would like to mention:
1- I'm running windows and compiling this for linux, the instant client version that I've downloaded is for linux x86(No Idea if that will work or if it could be the source of the problem).
2- I'm using a modified version of eclipse to develop, specific for that device.
3- I have no idea if I should move those Oracle libs to the device after the compilation, so if anyone could give me orientation on that, I would be very thankful.
TLDR: I wan't to compile the above code but it fails to link, help, please!
EDIT:
To the two first answers, no I haven't found any specific ARM libraries, I don't think there are any.
Here is the link if anyone can find anything that resemble an ARM distribution I would be thankful.
There are two RISC distribution but I don't know if they are compatible with ARM :
Instant Client for HP-UX PA-RISC (64-bit)
Instant Client for HP-UX PA-RISC (32-bit)
If you do not have ARM versions of the Oracle library, you're totally out of luck there and would need to get one (perhaps there is a free driver?) or implement the wire protocol manually.
Erm... is there an instant-client (or any Oracle client) for Linux+ARM at all? I don't see one on the downloads page.
If not, you will have to use ODBC, or another database that has an open-source client you can compile.
How about using java with a jdbc-driver ? Oracle-thin-driver is pure-java so it should work on arm. If you cannot write a pure java-app and need to use other libraries on your arm-device, you can use JNI-calls from java to use native-arm libraries.
Well i'm pretty sure that you'd need the windows version of the Oracle Client if you're running on a windows machine.
You need to move the -L arguments before the -l arguments.
You'll need ARM libraries to run on the device, not x86 libraries, no idea if Oracle provides those.
You probably don't want to have the device directly accessing the database. It would be better to stick a middle-tier server in the stack, and have the devices talk to that (over XML-RPC or other RPC protocol).
Your best chances are either to use Java and the JDBC driver, as suggested by tjin, or completely forget the idea of directly connecting to the database; create a web service on the server and use that instead.