terrapane / aescrypt_linux

AES Crypt Graphical User Interface (GUI) version of that allows one to encrypt and decrypt files from the Linux desktop
https://www.aescrypt.com
Other
3 stars 0 forks source link

Build Error: Remove constexpr from Function in engine_common.h #1

Closed dil-atiwari closed 1 month ago

dil-atiwari commented 2 months ago

When attempting to build the project using the Docker image --platform=linux/amd64 phusion/passenger-ruby30, I encountered an error.

cmake --build build --parallel

The error originates from line 67 of the file located at /home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/engine_common.h.

To resolve the issue, you need to remove the constexpr keyword from the following function declaration. Since I don't have the access and this is a dependency which is not getting directly installed so could you fix it from your end

Before

constexpr std::string CreateComponent(const std::string &component, const std::string &instance);

After

std::string CreateComponent(const std::string &component, const std::string &instance);

Error log due when running this command in the docker container


FROM --platform=linux/amd64 phusion/passenger-ruby30

# Install necessary packages
RUN apt-get update && \
    apt-get install -y \
    git \
    cmake \
    build-essential

RUN git clone https://github.com/terrapane/aescrypt_cli.git /aescrypt_cli && \
    cd /aescrypt_cli && \
    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
    cmake --build build --parallel
 80%] Building CXX object _deps/aescrypt_engine-build/src/CMakeFiles/aescrypt_engine.dir/decryptor.cpp.o
[ 80%] Building CXX object _deps/aescrypt_engine-build/src/CMakeFiles/aescrypt_engine.dir/encryptor.cpp.o
In file included from /home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/decryptor.cpp:31:
/home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/engine_common.h: In function ‘constexpr std::string {anonymous}::CreateComponent(const string&, const string&)’:
/home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/engine_common.h:67:23: error: invalid return type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} of ‘constexpr’ function ‘constexpr std::string {anonymous}::CreateComponent(const string&, const string&)’
   67 | constexpr std::string CreateComponent(const std::string &component,
      |                       ^~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/streambuf:41,
                 from /usr/include/c++/11/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/11/iterator:66,
                 from /usr/include/c++/11/bits/ranges_algobase.h:36,
                 from /usr/include/c++/11/bits/ranges_algo.h:35,
                 from /usr/include/c++/11/algorithm:64,
                 from /home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/decryptor.cpp:22:
/usr/include/c++/11/bits/basic_string.h:85:11: note: ‘std::__cxx11::basic_string<char>’ is not literal because:
   85 |     class basic_string
      |           ^~~~~~~~~~~~
/usr/include/c++/11/bits/basic_string.h:85:11: note:   ‘std::__cxx11::basic_string<char>’ does not have ‘constexpr’ destructor
In file included from /home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/encryptor.cpp:32:
/home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/engine_common.h: In function ‘constexpr std::string {anonymous}::CreateComponent(const string&, const string&)’:
/home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/engine_common.h:67:23: error: invalid return type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} of ‘constexpr’ function ‘constexpr std::string {anonymous}::CreateComponent(const string&, const string&)’
   67 | constexpr std::string CreateComponent(const std::string &component,
      |                       ^~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/streambuf:41,
                 from /usr/include/c++/11/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/11/iterator:66,
                 from /usr/include/c++/11/bits/ranges_algobase.h:36,
                 from /usr/include/c++/11/bits/ranges_algo.h:35,
                 from /usr/include/c++/11/algorithm:64,
                 from /home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/encryptor.cpp:22:
/usr/include/c++/11/bits/basic_string.h:85:11: note: ‘std::__cxx11::basic_string<char>’ is not literal because:
   85 |     class basic_string
      |           ^~~~~~~~~~~~
/usr/include/c++/11/bits/basic_string.h:85:11: note:   ‘std::__cxx11::basic_string<char>’ does not have ‘constexpr’ destructor
gmake[2]: *** [_deps/aescrypt_engine-build/src/CMakeFiles/aescrypt_engine.dir/build.make:76: _deps/aescrypt_engine-build/src/CMakeFiles/aescrypt_engine.dir/decryptor.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: *** [_deps/aescrypt_engine-build/src/CMakeFiles/aescrypt_engine.dir/build.make:90: _deps/aescrypt_engine-build/src/CMakeFiles/aescrypt_engine.dir/encryptor.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1733: _deps/aescrypt_engine-build/src/CMakeFiles/aescrypt_engine.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

Line 67: nano /home/app/be/tmp/aescrypt_linux/build/_deps/aescrypt_engine-src/src/engine_common.h

Remove this constexpr from this line

std::string CreateComponent(const std::string &component,
                                      const std::string &instance)
paulej commented 2 months ago

This is valid C++20 code. I think the issue might be that the compiler you are using does not yet support this syntax. This form has been supported since at least clang 14, gcc 12.2, and MSVC 2022.

dil-atiwari commented 2 months ago

Hi @paulej I am still getting the above error even after using the new version. Here is my dockerfile

# Use the specified base image and platform
FROM --platform=linux/amd64 phusion/passenger-ruby30 AS base

RUN apt-get update && \
    apt-get remove -y default-libmysqlclient-dev libmysqlclient21 && \
    apt-get install -y -o Dpkg::Options::="--force-confold" \
    wget \
    xfonts-base \
    xfonts-75dpi \
    fonts-arkpandora \
    nano \
    tzdata \
    make \
    cmake \
    g++ \
    swig \
    nginx-extras \
    fontconfig \
    libxext6 \
    libxrender1 \
    imagemagick \
    default-libmysqlclient-dev \
    libssl-dev \
    apt-transport-https \
    shared-mime-info && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN git clone https://github.com/terrapane/aescrypt_cli.git

RUN cd aescrypt_cli && \
    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
    cmake --build build --parallel
paulej commented 2 months ago

That container has g++ 11.4. That's too old.

dil-atiwari commented 2 months ago

Hi @paulej I have updated my compiler to g++(12.3.0) but now all the commands are running without any error but the aescrypt package is still not yet installed.

aescrypt --version
bash: aescrypt: command not found
g++ --version
g++ (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# Use the specified base image and platform
FROM --platform=linux/amd64 phusion/passenger-ruby30 AS base

RUN apt-get update && \
    apt-get remove -y default-libmysqlclient-dev libmysqlclient21 && \
    apt-get install -y -o Dpkg::Options::="--force-confold" \
    wget \
    xfonts-base \
    xfonts-75dpi \
    fonts-arkpandora \
    nano \
    tzdata \
    make \
    cmake \
    g++ \
    swig \
    nginx-extras \
    fontconfig \
    libxext6 \
    libxrender1 \
    imagemagick \
    default-libmysqlclient-dev \
    libssl-dev \
    apt-transport-https \
    shared-mime-info && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN add-apt-repository ppa:ubuntu-toolchain-r/test && \
    apt-get update && \
    apt-get install -y gcc-12 g++-12 && \
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 && \
    update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10

RUN git clone https://github.com/terrapane/aescrypt_cli.git && \
    cd aescrypt_cli && \
    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
    cmake --build build --parallel
paulej commented 2 months ago

If you want to install it inside the container, run cmake --install build. If you want to create package files (e.g., .deb or .rpm), you can change directories to the build directory and run cpack. That would require the right package files to be installed.

Anyway, at this point, the aescrypt executable should be in build/src/aescrypt. If that's all you're seeking, you could just copy it. But the --install will actually install it into the container.

paulej commented 2 months ago

@dil-atiwari Changes were made to the code to remove the constexpr issue you encountered. While valid, it was the one and only one thing blocking builds on some older compilers. Thus, it was changed.