Electron build doesn't work properly
See original GitHub issueHi,
not sure if I’m doing something wrong on my end but when I try to build my Electron C++ addon with CMake.js I end up with some weird issues. The biggest one is that the app instatnly crashes when I call args[0]->IsString()
during function argument validation. There doesn’t seem to be a problem with the other validation methods like IsNumber()
or IsStringObject()
. After I toggled on the --enable-logging
flag in Electron I was able to figure out that this is the error Electron crashes on:
[13508:1016/202149.533:ERROR:crashpad_client_win.cc(799)] not connected
.
Another weird behavior is that when I’m logging something with std::cout
it only actually gets printed when compiling in Debug mode. Neither of these issues appeared when I tried building with node-gyp
.
My CMakeLists.txt
file is just the very basic configuration:
cmake_minimum_required (VERSION 3.5)
set(CMAKE_CXX_STANDARD 17)
project(test)
include_directories(${CMAKE_JS_INC})
add_library(${PROJECT_NAME} SHARED main.cpp ${CMAKE_JS_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
target_link_libraries (${PROJECT_NAME} ${CMAKE_JS_LIB})
and this is my setup in package.json
:
"cmake-js": {
"runtime": "electron",
"runtimeVersion": "10.1.3",
"arch": "x64"
}
Am I missing something or is this some sort of internal CMake.js issues? Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:19
Top GitHub Comments
For Electron 9+
V8_31BIT_SMIS_ON_64BIT_ARCH
should be defined.For Electron 9+ for
arm64
and forx64
V8_COMPRESS_POINTERS
should also be defined.For Electron 11+
V8_REVERSE_JSARGS
should also be defined.Since Electron 9 it uses the patch to enable pointer compression in v8 and its node.js: https://github.com/electron/electron/pull/21468/files
Now all native node modules should be built with the
V8_COMPRESS_POINTERS
macro defined only on 64-bit platforms and theV8_31BIT_SMIS_ON_64BIT_ARCH
macro defined on all platforms (which seems counterintuitive, but in the patch this is defined by default)Those macros don’t affect node-addon-abi, that is why it works fine.
cc @unbornchikken @mastergberry