1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7608],{39114:(e,n,i)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/custom-query-modules/cpp",function(){return i(82634)}])},82634:(e,n,i)=>{"use strict";i.r(n),i.d(n,{default:()=>l,useTOC:()=>s});var t=i(23798),r=i(28293),a=i(67106),o=i(19935);function s(e){return[{value:"How C++ API works in Memgraph",id:"how-c-api-works-in-memgraph",depth:2}]}let l=(0,r.e)(function(e){let{toc:n=s(e)}=e,i={a:"a",h1:"h1",h2:"h2",li:"li",p:"p",ul:"ul",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.h1,{children:"How to create a query module in C++"}),"\n",(0,t.jsx)(i.p,{children:"As C++ requires compiling, you cannot use its source code directly; it must first be compiled into a shared library. This shared library can then be loaded by Memgraph and utilized as a query module."}),"\n",(0,t.jsx)(i.p,{children:"To achieve this, an environment equipped for compiling C++, including necessary libraries, headers, and a compiler, needs to be established on the system or within a development container."}),"\n",(0,t.jsx)(i.p,{children:"Given these requirements, you have two primary options for developing a C++ query module:"}),"\n",(0,t.jsxs)(i.ul,{children:["\n",(0,t.jsx)(i.li,{children:(0,t.jsx)(i.a,{href:"/custom-query-modules/cpp/cpp-example#quickstart-gude-for-developing-a-query-module-in-c",children:"Developing in your own environment"})}),"\n",(0,t.jsx)(i.li,{children:(0,t.jsx)(i.a,{href:"/custom-query-modules/cpp/cpp-example#developing-a-query-module-with-mage",children:"Utilizing the MAGE environment"})}),"\n"]}),"\n",(0,t.jsx)(i.p,{children:"When developing in your own environment, you will manage only your dependencies.\nThis setup is compatible with any Memgraph installation or container and doesnât\nnecessitate MAGE. Here, you will manually install the required dependencies and\ncompile the shared library."}),"\n",(0,t.jsx)(i.p,{children:"Alternatively, the MAGE environment contains all dependencies and files\nnecessary for the Mage library to function properly. In this setup, you will\nfollow the Mage structure to integrate your own query modules and compile them\nalongside Mage."}),"\n",(0,t.jsx)(i.h2,{id:n[0].id,children:n[0].value}),"\n",(0,t.jsxs)(i.p,{children:["The C++ API acts as a wrapper around the ",(0,t.jsx)(i.a,{href:"/custom-query-modules/c/c-api",children:"C API"}),".\nThe ",(0,t.jsx)(i.a,{href:"/custom-query-modules/cpp/cpp-api",children:"C++ API"}
1)," provides a full range of\nsupported functions with automatic memory management. C++ API modules, just like\nC API modules, need\nto be compiled into a shared library so that they can be loaded when Memgraph starts."]}),"\n",(0,t.jsx)(i.p,{children:"This means the C++ shared library is directly tied to the Memgraph instance that loaded it and shares the same resources, which leads to quite efficient performance.\nAs a result, unhandled exceptions in the C++ code can crash the Memgraph instance, making it important to handle all exceptions."})]})},"/custom-query-modules/cpp",{filePath:"pages/custom-query-modules/cpp.mdx",timestamp:1789474418e3,pageMap:a.O,frontMatter:{title:"How to create a query module in C++",description:"Enhance your graph data analysis by integrating the C++ programming language with Memgraph. Explore C++ and other languages further in our documentation."},title:"How to create a query module in C++"},"undefined"==typeof RemoteContent?s:RemoteContent.useTOC)}},e=>{e.O(0,[8293,7106,636,6593,8792],()=>e(e.s=39114)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.