error: ‘align’ is not a member of ‘std’
We tried to run the code, but when we run the command "python install.py --tool --ot --sh2pc", this error occurs: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/utils/prg.h: In member function ‘void emp::PRG::random_data_unaligned(void*, int)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/utils/prg.h:76:6: error: ‘align’ is not a member of ‘std’ if(std::align(sizeof(block), sizeof(block), aligned_data, size)) { ^ In file included from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:4:0, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/file_io_channel.h:5, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/emp-tool.h:2, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/test/prg.cpp:1: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/utils/prg.h: In member function ‘void emp::PRG::random_data_unaligned(void*, int)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/utils/prg.h:76:6: error: ‘align’ is not a member of ‘std’ if(std::align(sizeof(block), sizeof(block), aligned_data, size)) { ^ In file included from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:4:0, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/file_io_channel.h:5, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/emp-tool.h:2, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/test/hash.cpp:1: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/utils/prg.h: In member function ‘void emp::PRG::random_data_unaligned(void*, int)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/utils/prg.h:76:6: error: ‘align’ is not a member of ‘std’ if(std::align(sizeof(block), sizeof(block), aligned_data, size)) { ^ In file included from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:4:0, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/file_io_channel.h:5, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/emp-tool.h:2, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/test/netio.cpp:1: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/utils/prg.h: In member function ‘void emp::PRG::random_data_unaligned(void*, int)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/utils/prg.h:76:6: error: ‘align’ is not a member of ‘std’ if(std::align(sizeof(block), sizeof(block), aligned_data, size)) { ^ In file included from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/file_io_channel.h:5:0, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/emp-tool.h:2, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/test/prp.cpp:1: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h: In member function ‘void emp::IOChannel<T>::send_bool(bool*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:56:26: error: ‘align’ is not a member of ‘std’ const void * aligned = std::align(alignof(uint64_t), sizeof(uint64_t), ptr, space); ^ /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h: In member function ‘void emp::IOChannel<T>::recv_bool(bool*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:69:20: error: ‘align’ is not a member of ‘std’ void * aligned = std::align(alignof(uint64_t), sizeof(uint64_t), ptr, space); ^ In file included from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/file_io_channel.h:5:0, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/emp-tool.h:2, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/test/hash.cpp:1: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h: In member function ‘void emp::IOChannel<T>::send_bool(bool*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:56:26: error: ‘align’ is not a member of ‘std’ const void * aligned = std::align(alignof(uint64_t), sizeof(uint64_t), ptr, space); ^ /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h: In member function ‘void emp::IOChannel<T>::recv_bool(bool*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:69:20: error: ‘align’ is not a member of ‘std’ void * aligned = std::align(alignof(uint64_t), sizeof(uint64_t), ptr, space); ^ In file included from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/file_io_channel.h:5:0, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/emp-tool.h:2, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/test/prg.cpp:1: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h: In member function ‘void emp::IOChannel<T>::send_bool(bool*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:56:26: error: ‘align’ is not a member of ‘std’ const void * aligned = std::align(alignof(uint64_t), sizeof(uint64_t), ptr, space); ^ /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h: In member function ‘void emp::IOChannel<T>::recv_bool(bool*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:69:20: error: ‘align’ is not a member of ‘std’ void * aligned = std::align(alignof(uint64_t), sizeof(uint64_t), ptr, space); ^ In file included from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/file_io_channel.h:5:0, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/emp-tool.h:2, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/test/netio.cpp:1: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h: In member function ‘void emp::IOChannel<T>::send_bool(bool*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:56:26: error: ‘align’ is not a member of ‘std’ const void * aligned = std::align(alignof(uint64_t), sizeof(uint64_t), ptr, space); ^ /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h: In member function ‘void emp::IOChannel<T>::recv_bool(bool*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/io/io_channel.h:69:20: error: ‘align’ is not a member of ‘std’ void * aligned = std::align(alignof(uint64_t), sizeof(uint64_t), ptr, space); ^ In file included from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/emp-tool.h:15:0, from /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/test/prp.cpp:1: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/circuits/sha3_256.h: In function ‘int emp::sha3_256(uint8_t*, const T*, size_t)’: /home/users/dase212lxy/tmp/emp-sh2pc-master/emp-tool/emp-tool/circuits/sha3_256.h:32:37: error: there are no arguments to ‘EVP_sha3_256’ that depend on a template parameter, so a declaration of ‘EVP_sha3_256’ must be available [-fpermissive] const EVP_MD * algo = EVP_sha3_256();
The errors you're encountering seem to stem from two issues:
-
std::alignNot Found:- The
std::alignfunction is available starting from C++17. If your compiler or build system is not set to use C++17, this error will occur.
- The
-
EVP_sha3_256Undefined:- This function is part of OpenSSL 1.1.1 or newer. If your system has an older version of OpenSSL or is missing it, this error will occur.
Resolution Steps:
1. Fixing std::align Error
-
Ensure your compiler supports C++17. Run the following command to check the version of
g++orclang:g++ --versionFor GCC, version 7 or newer is recommended.
-
Update your compiler flags to include
-std=c++17. Modify theCMakeLists.txtfile in theemp-sh2pcproject. Find the line that sets the compiler flags and ensure it includes:set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON)
2. Fixing EVP_sha3_256 Error
-
Verify your OpenSSL version using the command:
openssl versionIf it's older than 1.1.1, you need to update OpenSSL. On Ubuntu, you can do this with:
sudo apt update sudo apt install libssl-devOn other systems, ensure the latest OpenSSL development libraries are installed.
-
If OpenSSL is installed correctly, make sure your build system links against it. For CMake, include:
find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) target_link_libraries(<the_target_name> ${OPENSSL_LIBRARIES})
3. Clean and Rebuild
-
After making the changes, clean your build directory:
cmake .. make -j 4
4. Re-run the Install Command
Once the build completes successfully, try re-running the install command:
python install.py --tool --ot --sh2pc