Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use c++ as back-end for Electron.js?

I have a task to make simple c++ app which stores information into binary files, then need to make simple manipulations with this info, like edit,delete,read. I wanted to create desktop app using Electron for designing UI and to use c++ for manipulation with information.

Is it possible and how can i include c++ into electron, is there any tutorials? Thanks in advance.

like image 662
Viktor Avatar asked Apr 13 '17 07:04

Viktor


People also ask

Does Electron need a backend?

Electron will act as a wrapper for the existing web app without requiring any changes to the backend. Setting up Electron is easy for this type of app! There are no changes needed at the web app codebase level.

What backend does Electron use?

Electron uses HTML, JavaScript, and CSS for its front end and Node. js for its backend. This design enables developers to quickly write and easily maintain cross-platform applications between their desktop and web applications.

Can you use C# with Electron?

And as it is C# core, it is cross-platform as well. Cross-platform desktop app powered by Electron using React for UI and extended functionality by C# goodness. And now not only you can use your frontend skills, but backend as well.

Can you use C++ with Electron?

It is written in C++ and is used in Google Chrome. V8 can run standalone, or can be embedded into any C++ application. Electron builds V8 as part of Chromium and then points Node to that V8 when building it.


1 Answers

Electron is using nodejs, so you can still package cpp code as a node module and then use it as dependency in your electron app.

See the Hello World example here which basically does this:

module.exports.hello = () => 'world';

This is the example from their tutorial:

// hello.cc
#include <node.h>

namespace demo {

using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;

void Method(const FunctionCallbackInfo<Value>& args) {
  Isolate* isolate = args.GetIsolate();
  args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
}

void init(Local<Object> exports) {
  NODE_SET_METHOD(exports, "hello", Method);
}

NODE_MODULE(addon, init)

}  // namespace demo
like image 130
Beginner Avatar answered Sep 17 '22 15:09

Beginner