Ubuntu环境下安装MAGE时缺失mg_exceptions.hpp文件的问题
问题
在AWS的Ubuntu环境运行Memgraph 2.0.12,尝试添加MAGE算法时执行编译命令出现错误,提示缺失mg_exceptions.hpp文件,具体编译日志如下:
ubuntu@ip-10-0-10-157:~/repos$ git clone https://github.com/memgraph/mage.git Cloning into 'mage'... remote: Enumerating objects: 7314, done. remote: Counting objects: 100% (2354/2354), done. remote: Compressing objects: 100% (1193/1193), done. remote: Total 7314 (delta 1456), reused 1772 (delta 1157), pack-reused 4960 Receiving objects: 100% (7314/7314), 21.99 MiB | 11.22 MiB/s, done. Resolving deltas: 100% (3706/3706), done. ubuntu@ip-10-0-10-157:~/repos$ cd mage ubuntu@ip-10-0-10-157:~/repos/mage$ python3 setup build -p /usr/lib/memgraph/query_modules 2023-11-06 16:15:10,414 [INFO]: [Terminal] Starting building and copying source code... 2023-11-06 16:15:10,414 [INFO]: [Terminal] (1/7) Building C++ modules started. 2023-11-06 16:15:10,414 [DEBUG]: [Terminal] Running command `['cmake', '..', '-DCMAKE_BUILD_TYPE=Release']`. 2023-11-06 16:15:16,061 [DEBUG]: [Terminal] Running command `['make', '-j2']`. Cloning into 'gtest-proj'... Cloning into 'uuid-proj'... HEAD is now at 5c538cc Merge pull request #57 from rickyviking/windows_defines HEAD is now at e2239ee6 Googletest export Cloning into 'mgclient-proj'... HEAD is now at 1999893 Add column names to the Cpp client (#55) In file included from /home/ubuntu/repos/mage/cpp/mg_utility/mg_utils.hpp:12, from /home/ubuntu/repos/mage/cpp/betweenness_centrality_module/betweenness_centrality_module.cpp:3: /home/ubuntu/repos/mage/cpp/mg_utility/mg_graph.hpp:15:10: fatal error: mg_exceptions.hpp: No such file or directory 15 | #include "mg_exceptions.hpp" | ^~~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [betweenness_centrality_module/CMakeFiles/betweenness_centrality.dir/build.make:76: betweenness_centrality_module/CMakeFiles/betweenness_centrality.dir/betweenness_centrality_module.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:1652: betweenness_centrality_module/CMakeFiles/betweenness_centrality.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:146: all] Error 2 2023-11-06 16:16:04,262 [ERROR]: [Terminal] Running command ['make', '-j2'] failed. 2023-11-06 16:16:04,262 [ERROR]: [Terminal] (1/8) Building C++ modules failed. 2023-11-06 16:16:04,262 [ERROR]: [Terminal] An error occurred while building. Check the output message for more information. ubuntu@ip-10-0-10-157:~/repos/mage$
解答
什么是mg_exceptions.hpp
mg_exceptions.hpp是Memgraph C++查询模块开发的核心头文件,定义了Memgraph运行时抛出的各类异常类型(比如图操作异常、数据类型不兼容异常等),是MAGE模块依赖的基础接口文件之一。
缺失原因及解决办法
问题源于当前克隆的MAGE版本与Memgraph 2.0.12不兼容——新版MAGE引入了mg_exceptions.hpp这类较新的接口,但Memgraph 2.0.12并未提供该文件。
解决步骤:
- 切换MAGE到与Memgraph 2.0.12匹配的版本:
cd mage git checkout 1.7.0 - 重新执行编译命令:
python3 setup build -p /usr/lib/memgraph/query_modules
说明:Memgraph与MAGE版本严格对应,Memgraph 2.0.x系列需搭配MAGE 1.7.x版本,避免因接口差异导致编译失败。
内容的提问来源于stack exchange,提问作者CharlesTheMan
相关产品推荐
相关产品推荐

