Simply run C/C++ GUI code using emscripten

1,494 views
Skip to first unread message

Mohammad Hammad

unread,
Nov 9, 2016, 10:46:22 AM11/9/16
to emscripten-discuss
Hi . I simply want to run C/C++ code and GUI using GTK+ with emscripten 

I have done some workaround which is defined below

I am able to compile C/C++ code with GTK+ using MinGW compiler . I used below command for this
C:\gtkmm\bin>g++ helloworld.cpp -o hello.exe `pkg-config --cflags --libs gtk+-2.0` 

And I am simply able to run simple C++ script without GUI using emscripten
C:\Program Files\Emscripten\emscripten\1.35.0> em++ helloworld.cpp -o helloworld.html 


I am a newbie to emscripten and i have done some research on it but unfortunately i am unable to sort it out . 


For some reason if this is impossible or currently not achievable due to compatibility issues , then what are the alternatives to run C++ code with GUI on browser 

Or what GUI libraries for C++ should be recpmmendable for this

Thanx in advance

Floh

unread,
Nov 10, 2016, 8:19:34 PM11/10/16
to emscripten-discuss
Did you google for "GTK on emscripten"? There's almost certainly porting work required, but may be someone else already did it.

There have been working ports of Qt running in emscripten (e.g. https://blog.qt.io/blog/2015/09/25/qt-for-native-client-and-emscripten/), but Qt and GTK are huge frameworks which will most likely result in a fairly unpleasent experience when running in the browser.

If you just need a small and fast UI running on top of a WebGL context, I recommend Dear Imgui (http://www.github.com/ocornut/imgui), or Nuklear (https://github.com/vurtun/nuklear), there's also TurboBadger (https://github.com/fruxo/turbobadger), but this is maintaining a big C++ object tree and isn't as lightweight as the other two.

For demos of those UI toolkits running in emscripten, see here: http://floooh.github.io/oryol-samples, you still need to provide some rendering and input wrapper code to make these simple UI frameworks run in the browser though.

Cheers,
-Floh.
Reply all
Reply to author
Forward
0 new messages