[英]How do you debug a Node.js addon built with CMake.js?
I want to be able to step though my C++ code for a Node.js addon that I am making.我希望能够遍历我正在制作的 Node.js 插件的 C++ 代码。 I understand that CMake.js has the
--debug
option, but there is no documentation about it.我知道 CMake.js 有
--debug
选项,但没有关于它的文档。
I am using the node-addon-api module, in CLion.我在 CLion 中使用 node-addon-api 模块。
After months of blind debugging though the use of Errors to print variables, I have finally figured out how to attach the CLion debugger to a Node.js addon.经过几个月的盲目调试,虽然使用 Errors 打印变量,但我终于想出了如何将 CLion 调试器附加到 Node.js 插件。
which node
or where.exe node
on Windows)which node
或 Windows 上的where.exe node
)I recently stumbled on the same problem and had success creating a custom toolchain in CLion 2020.3 with CMake.js on a Linux system.我最近偶然发现了同样的问题,并在 Linux 系统上使用 CMake.js 在 CLion 2020.3 中成功创建了自定义工具链。
Reproducible steps:可重现的步骤:
npm install -g cmake-js
.npm install -g cmake-js
。 Make sure to install the package globally, so that your toolchain becomes available across multiple projects.mkdir my-project && cd my-project && npm init
.mkdir my-project && cd my-project && npm init
。npm install bindings && npm install node-addon-api
(For the C++ wrapper).npm install bindings && npm install node-addon-api
(对于 C++ 包装器)。CMakeLists.txt
in the root directory and paste this .CMakeLists.txt
并粘贴这个. Make sure to replace file(GLOB SOURCE_FILES hello.cpp)
with your addon-specific cpp and header files.file(GLOB SOURCE_FILES hello.cpp)
替换为特定于插件的 cpp 和头文件。my-project
in CLion.my-project
。cmake-js
binary that you downloaded in the npm directory where you keep your global packages.cmake-js
二进制文件。compile -D
and set the working directory to the root directory of my-project
.compile -D
并将工作目录设置为my-project
的根目录。cmake-js
binary.cmake-js
二进制文件的目录。 Set the arguments to clean
and set the working directory to your project's root directory.clean
并将工作目录设置为项目的根目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.