memgraph / mage

MAGE - Memgraph Advanced Graph Extensions :crystal_ball:
Apache License 2.0
238 stars 23 forks source link

[BUG] Compilation problem when installing python3.9 environment by anaconda #484

Open csqjxiao opened 1 week ago

csqjxiao commented 1 week ago

I am a university researcher, and would like to develop several new graph mining algorithms based on mage. So I have to install mage from source code. The following compilation error is encoutered however.

In file included from /home/qingjunxiao.linux/mage/cpp/biconnected_components_module/biconnected_components_module.cpp:1:
/home/qingjunxiao.linux/mage/cpp/memgraph/include/mg_exceptions.hpp:79:44: error: expected ‘)’ before ‘identifier’
   79 |   explicit InvalidIDException(std::uint64_t identifier) : message_{StringSerialize("Invalid ID =", identifier)} {}
      |                              ~             ^~~~~~~~~~~
      |                                            )
/home/qingjunxiao.linux/mage/cpp/memgraph/include/mg_exceptions.hpp:79:113: error: expected unqualified-id before ‘{’ token
   79 |   explicit InvalidIDException(std::uint64_t identifier) : message_{StringSerialize("Invalid ID =", identifier)} {}
      |                                                                                                                 ^
In file included from /home/qingjunxiao.linux/mage/cpp/bipartite_matching_module/bipartite_matching_module.cpp:1:
/home/qingjunxiao.linux/mage/cpp/memgraph/include/mg_exceptions.hpp:79:44: error: expected ‘)’ before ‘identifier’
   79 |   explicit InvalidIDException(std::uint64_t identifier) : message_{StringSerialize("Invalid ID =", identifier)} {}
      |                              ~             ^~~~~~~~~~~
      |                                            )
/home/qingjunxiao.linux/mage/cpp/memgraph/include/mg_exceptions.hpp:79:113: error: expected unqualified-id before ‘{’ token
   79 |   explicit InvalidIDException(std::uint64_t identifier) : message_{StringSerialize("Invalid ID =", identifier)} {}
      |                                                                                                                 ^
make[2]: *** [biconnected_components_module/CMakeFiles/biconnected_components.dir/build.make:76: biconnected_components_module/CMakeFiles/biconnected_components.dir/biconnected_components_module.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1772: biconnected_components_module/CMakeFiles/biconnected_components.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[2]: *** [bipartite_matching_module/CMakeFiles/bipartite_matching.dir/build.make:76: bipartite_matching_module/CMakeFiles/bipartite_matching.dir/bipartite_matching_module.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:1824: bipartite_matching_module/CMakeFiles/bipartite_matching.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
2024-06-25 07:42:53,611 [ERROR]: [Terminal] Running command ['make', '-j4'] failed.
2024-06-25 07:42:53,611 [ERROR]: [Terminal] (1/8) Building C++ modules failed.
2024-06-25 07:42:53,611 [ERROR]: [Terminal] An error occurred while building. Check the output message for more information.

My platform is Ubuntu 24.04 (i.e., MacOS installed with lima and ubuntu-lts). The CPU chip on my computer is Apple M1 Pro with ARM instruction set.

Firstly, I cloned the v1.17-memgraph-2.17 branch of mage project.

git clone --recurse-submodules -b v1.17-memgraph-2.17 https://github.com/memgraph/mage

Then, I installed the project's dependencies by the following commands. Note that libpython3.9 is not availble on Ubuntu 24.04. So I have to install a python3.9 virtual environment by anaconda.

sudo apt install python3 python3-dev python3-setuptools python3-pip libcurl4 libssl-dev openssl build-essential make cmake curl g++ clang unixodbc
# this a must
sudo apt install unixodbc-dev

wget https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-aarch64.sh
bash Anaconda3-2024.02-1-Linux-aarch64.sh
source ~/.bashrc
conda update conda
conda update anaconda
conda create --name python39 python=3.9
conda activate python39

curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& export PATH="/root/.cargo/bin:${PATH}"

cd ~/mage
pip3 install -r ./python/requirements.txt 
pip3 install -r ./python/tests/requirements.txt 
pip3 install torch-sparse torch-cluster torch-spline-conv torch-geometric torch-scatter -f https://data.pyg.org/whl/torch-1.12.0+cu102.html

I have also installed the toolchain.

$ source /opt/toolchain-vXYZ/activate
(toolchain-v5) (python39) $ which gcc
/opt/toolchain-v5/bin/gcc
(toolchain-v5) (python39) $ which g++
/opt/toolchain-v5/bin/g++
(toolchain-v5) (python39) $ which clang
/opt/toolchain-v5/bin/clang
(toolchain-v5) (python39) $ which clang++
/opt/toolchain-v5/bin/clang++

Everything was fine until this step.

Thirdly, I complied the probject by:

python3 setup build -p /usr/lib/memgraph/query_modules

The C++ compiliation error appeared as mentioned at the beginning.

[ 23%] Building CXX object biconnected_components_module/CMakeFiles/biconnected_components.dir/biconnected_components_module.cpp.o
In file included from /home/qingjunxiao.linux/mage/cpp/biconnected_components_module/biconnected_components_module.cpp:1:
/home/qingjunxiao.linux/mage/cpp/memgraph/include/mg_exceptions.hpp:79:44: error: expected ‘)’ before ‘identifier’
   79 |   explicit InvalidIDException(std::uint64_t identifier) : message_{StringSerialize("Invalid ID =", identifier)} {}
      |                              ~             ^~~~~~~~~~~
      |                                            )
/home/qingjunxiao.linux/mage/cpp/memgraph/include/mg_exceptions.hpp:79:113: error: expected unqualified-id before ‘{’ token
   79 |   explicit InvalidIDException(std::uint64_t identifier) : message_{StringSerialize("Invalid ID =", identifier)} {}
      |                                                                                                                 ^
make[2]: *** [biconnected_components_module/CMakeFiles/biconnected_components.dir/build.make:76: biconnected_components_module/CMakeFiles/biconnected_components.dir/biconnected_components_module.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1772: biconnected_components_module/CMakeFiles/biconnected_components.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
csqjxiao commented 1 week ago

I fixed this cpp compilation problem by adding the following header include at the beginning of ~/mage/cpp/memgraph/include/mg_exceptions.hpp. The type std::uint64_t is defined in cstdint.h.

#include <cstdint>

Regretfully, after fixing this problem, more compilation errors appeared.

[ 63%] Building CXX object uuid_module/CMakeFiles/uuid_generator.dir/uuid_module.cpp.o
In file included from /usr/include/c++/13/bits/chrono_io.h:39,
                 from /usr/include/c++/13/chrono:3370,
                 from /home/qingjunxiao.linux/mage/cpp/build/uuid/include/uuid.h:15,
                 from /home/qingjunxiao.linux/mage/cpp/uuid_module/uuid_module.cpp:1:
/usr/include/c++/13/format:2404:7: error: ‘span’ does not name a type
 2404 |       span<_CharT> _M_span;
      |       ^~~~
/usr/include/c++/13/format:2405:16: error: expected nested-name-specifier before ‘span’
 2405 |       typename span<_CharT>::iterator _M_next;
      |                ^~~~
/usr/include/c++/13/format:2405:16: error: expected ‘;’ at end of member declaration
 2405 |       typename span<_CharT>::iterator _M_next;
      |                ^~~~
      |                    ;
/usr/include/c++/13/format:2405:20: error: expected unqualified-id before ‘<’ token
 2405 |       typename span<_CharT>::iterator _M_next;
      |                    ^
/usr/include/c++/13/format:2416:17: error: expected ‘)’ before ‘<’ token
 2416 |       _Sink(span<_CharT> __span) noexcept
      |            ~    ^
      |                 )
/usr/include/c++/13/format:2422:7: error: ‘span’ does not name a type
 2422 |       span<_CharT>
      |       ^~~~
/usr/include/c++/13/format:2428:17: error: ‘span’ does not name a type
 2428 |       constexpr span<_CharT>
      |                 ^~~~
/usr/include/c++/13/format:2440:16: error: ‘span’ is not a type
 2440 |       _M_reset(span<_CharT> __s, size_t __pos = 0) noexcept
      |                ^~~~
/usr/include/c++/13/format:2440:20: error: expected ‘,’ or ‘...’ before ‘<’ token
 2440 |       _M_reset(span<_CharT> __s, size_t __pos = 0) noexcept
      |                    ^
/usr/include/c++/13/format: In member function ‘constexpr void std::__format::_Sink<_CharT>::_M_rewind()’:
/usr/include/c++/13/format:2436:9: error: ‘_M_next’ was not declared in this scope; did you mean ‘next’?
 2436 |       { _M_next = _M_span.begin(); }
      |         ^~~~~~~
      |         next
/usr/include/c++/13/format:2436:19: error: ‘_M_span’ was not declared in this scope; did you mean ‘span’?
 2436 |       { _M_next = _M_span.begin(); }
      |                   ^~~~~~~
      |                   span
/usr/include/c++/13/format: In member function ‘void std::__format::_Sink<_CharT>::_M_reset(int)’:
/usr/include/c++/13/format:2442:9: error: ‘_M_span’ was not declared in this scope; did you mean ‘span’?
 2442 |         _M_span = __s;
      |         ^~~~~~~
      |         span
/usr/include/c++/13/format:2442:19: error: ‘__s’ was not declared in this scope
 2442 |         _M_span = __s;
      |                   ^~~
/usr/include/c++/13/format:2443:9: error: ‘_M_next’ was not declared in this scope; did you mean ‘next’?
 2443 |         _M_next = __s.begin() + __pos;
      |         ^~~~~~~
      |         next
/usr/include/c++/13/format:2443:33: error: ‘__pos’ was not declared in this scope; did you mean ‘__pow’?
 2443 |         _M_next = __s.begin() + __pos;
      |                                 ^~~~~
      |                                 __pow
/usr/include/c++/13/format: In member function ‘constexpr void std::__format::_Sink<_CharT>::_M_write(_CharT)’:
/usr/include/c++/13/format:2450:10: error: ‘_M_next’ was not declared in this scope; did you mean ‘next’?
 2450 |         *_M_next++ = __c;
      |          ^~~~~~~
      |          next
/usr/include/c++/13/format:2451:23: error: ‘_M_span’ was not declared in this scope; did you mean ‘span’?
 2451 |         if (_M_next - _M_span.begin() == std::ssize(_M_span)) [[unlikely]]
      |                       ^~~~~~~
      |                       span
/usr/include/c++/13/format: In member function ‘constexpr void std::__format::_Sink<_CharT>::_M_write(std::basic_string_view<_CharT>)’:
/usr/include/c++/13/format:2458:14: error: expected ‘;’ before ‘__to’
 2458 |         span __to = _M_unused();
      |              ^~~~
/usr/include/c++/13/format:2459:16: error: ‘__to’ was not declared in this scope
 2459 |         while (__to.size() <= __s.size())
      |                ^~~~
/usr/include/c++/13/format:2462:13: error: ‘_M_next’ was not declared in this scope; did you mean ‘next’?
 2462 |             _M_next += __to.size();
      |             ^~~~~~~
      |             next
/usr/include/c++/13/format:2465:20: error: there are no arguments to ‘_M_unused’ that depend on a template parameter, so a declaration of ‘_M_unused’ must be available [-fpermissive]
 2465 |             __to = _M_unused();
      |                    ^~~~~~~~~
/usr/include/c++/13/format:2465:20: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/usr/include/c++/13/format:2469:22: error: ‘__to’ was not declared in this scope
 2469 |             __s.copy(__to.data(), __s.size());
      |                      ^~~~
/usr/include/c++/13/format:2470:13: error: ‘_M_next’ was not declared in this scope; did you mean ‘next’?
 2470 |             _M_next += __s.size();
      |             ^~~~~~~
      |             next
/usr/include/c++/13/format: In member function ‘void std::__format::_Iter_sink<_CharT, _OutIter>::_M_overflow()’:
/usr/include/c++/13/format:2572:13: error: ‘span’ was not declared in this scope; did you mean ‘gsl::span’?
 2572 |             span<_CharT> __first;
      |             ^~~~
      |             gsl::span
In file included from /usr/include/c++/13/format:44:
/home/qingjunxiao.linux/mage/cpp/build/uuid/include/gsl/span:78:7: note: ‘gsl::span’ declared here
   78 | class span;
      |       ^~~~
/usr/include/c++/13/format:2572:24: error: expected primary-expression before ‘>’ token
 2572 |             span<_CharT> __first;
      |                        ^
/usr/include/c++/13/format:2572:26: error: ‘__first’ was not declared in this scope
 2572 |             span<_CharT> __first;
      |                          ^~~~~~~
/usr/include/c++/13/format: At global scope:
/usr/include/c++/13/format:2646:14: error: ‘span’ does not name a type
 2646 |       static span<_CharT>
      |              ^~~~
/usr/include/c++/13/format: In instantiation of ‘_Seq std::__format::_Seq_sink<_Seq>::get() && [with _Seq = std::__cxx11::basic_string<char>]’:
/usr/include/c++/13/format:3788:32:   required from here
/usr/include/c++/13/format:2538:19: error: ‘class std::__format::_Seq_sink<std::__cxx11::basic_string<char> >’ has no member named ‘_M_used’; did you mean ‘_M_seq’?
 2538 |         if (this->_M_used().size() != 0)
      |             ~~~~~~^~~~~~~
      |             _M_seq
/usr/include/c++/13/format: In instantiation of ‘_Seq std::__format::_Seq_sink<_Seq>::get() && [with _Seq = std::__cxx11::basic_string<wchar_t>]’:
/usr/include/c++/13/format:3797:32:   required from here
/usr/include/c++/13/format:2538:19: error: ‘class std::__format::_Seq_sink<std::__cxx11::basic_string<wchar_t> >’ has no member named ‘_M_used’; did you mean ‘_M_seq’?
 2538 |         if (this->_M_used().size() != 0)
      |             ~~~~~~^~~~~~~
      |             _M_seq
/usr/include/c++/13/format: In instantiation of ‘constexpr std::__format::_Buf_sink<_CharT>::_Buf_sink() [with _CharT = char]’:
/usr/include/c++/13/format:2527:7:   required from ‘std::__format::_Seq_sink<_Seq>::_Seq_sink() [with _Seq = std::__cxx11::basic_string<char>]’
/usr/include/c++/13/format:3786:31:   required from here
/usr/include/c++/13/format:2494:23: error: cannot convert ‘char [256]’ to ‘const std::__format::_Sink<char>&’
 2494 |       : _Sink<_CharT>(_M_buf)
      |                       ^~~~~~
      |                       |
      |                       char [256]
/usr/include/c++/13/format:2475:13: note:   initializing argument 1 of ‘std::__format::_Sink<_CharT>::_Sink(const std::__format::_Sink<_CharT>&) [with _CharT = char]’
 2475 |       _Sink(const _Sink&) = delete;
      |             ^~~~~~~~~~~~
/usr/include/c++/13/format: In instantiation of ‘constexpr std::__format::_Buf_sink<_CharT>::_Buf_sink() [with _CharT = wchar_t]’:
/usr/include/c++/13/format:2527:7:   required from ‘std::__format::_Seq_sink<_Seq>::_Seq_sink() [with _Seq = std::__cxx11::basic_string<wchar_t>]’
/usr/include/c++/13/format:3795:34:   required from here
/usr/include/c++/13/format:2494:23: error: cannot convert ‘wchar_t [64]’ to ‘const std::__format::_Sink<wchar_t>&’
 2494 |       : _Sink<_CharT>(_M_buf)
      |                       ^~~~~~
      |                       |
      |                       wchar_t [64]
/usr/include/c++/13/format:2475:13: note:   initializing argument 1 of ‘std::__format::_Sink<_CharT>::_Sink(const std::__format::_Sink<_CharT>&) [with _CharT = wchar_t]’
 2475 |       _Sink(const _Sink&) = delete;
      |             ^~~~~~~~~~~~
/usr/include/c++/13/format: In instantiation of ‘void std::__format::_Iter_sink<_CharT, _OutIter>::_M_overflow() [with _CharT = wchar_t; _OutIter = std::__format::_Sink_iter<wchar_t>]’:
/usr/include/c++/13/format:2564:7:   required from here
/usr/include/c++/13/format:2566:26: error: ‘class std::__format::_Iter_sink<wchar_t, std::__format::_Sink_iter<wchar_t> >’ has no member named ‘_M_used’
 2566 |         auto __s = this->_M_used();
      |                    ~~~~~~^~~~~~~
/usr/include/c++/13/format: In instantiation of ‘void std::__format::_Iter_sink<_CharT, _OutIter>::_M_overflow() [with _CharT = char; _OutIter = std::__format::_Sink_iter<char>]’:
/usr/include/c++/13/format:2564:7:   required from here
/usr/include/c++/13/format:2566:26: error: ‘class std::__format::_Iter_sink<char, std::__format::_Sink_iter<char> >’ has no member named ‘_M_used’
/usr/include/c++/13/format: In instantiation of ‘constexpr void std::__format::_Sink<_CharT>::_M_write(std::basic_string_view<_CharT>) [with _CharT = wchar_t]’:
/usr/include/c++/13/format:2379:19:   required from ‘constexpr std::__format::_Sink_iter<_CharT>& std::__format::_Sink_iter<_CharT>::operator=(std::basic_string_view<_CharT>) [with _CharT = wchar_t]’
/usr/include/c++/13/format:599:12:   required from ‘_Out std::__format::__write(_Out, std::basic_string_view<_CharT>) [with _Out = _Sink_iter<wchar_t>; _CharT = wchar_t]’
/usr/include/c++/13/format:3639:36:   required from ‘constexpr void std::__format::_Formatting_scanner<_Out, _CharT>::_M_on_chars(iterator) [with _Out = std::__format::_Sink_iter<wchar_t>; _CharT = wchar_t; iterator = const wchar_t*]’
/usr/include/c++/13/format:3636:7:   required from here
/usr/include/c++/13/format:2465:29: error: ‘_M_unused’ was not declared in this scope
 2465 |             __to = _M_unused();
      |                    ~~~~~~~~~^~
/usr/include/c++/13/format: In instantiation of ‘constexpr void std::__format::_Sink<_CharT>::_M_write(std::basic_string_view<_CharT>) [with _CharT = char]’:
/usr/include/c++/13/format:2379:19:   required from ‘constexpr std::__format::_Sink_iter<_CharT>& std::__format::_Sink_iter<_CharT>::operator=(std::basic_string_view<_CharT>) [with _CharT = char]’
/usr/include/c++/13/format:599:12:   required from ‘_Out std::__format::__write(_Out, std::basic_string_view<_CharT>) [with _Out = _Sink_iter<char>; _CharT = char]’
/usr/include/c++/13/format:3639:36:   required from ‘constexpr void std::__format::_Formatting_scanner<_Out, _CharT>::_M_on_chars(iterator) [with _Out = std::__format::_Sink_iter<char>; _CharT = char; iterator = const char*]’
/usr/include/c++/13/format:3636:7:   required from here
/usr/include/c++/13/format:2465:29: error: ‘_M_unused’ was not declared in this scope
make[2]: *** [uuid_module/CMakeFiles/uuid_generator.dir/build.make:76: uuid_module/CMakeFiles/uuid_generator.dir/uuid_module.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2243: uuid_module/CMakeFiles/uuid_generator.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
katarinasupe commented 3 days ago

Hi @csqjxiao, thank you for reporting this! Did you try installing MAGE outside of Conda? To unblock you, is it okay for you to run Memgraph MAGE Docker image?