Running CMake on Amazon Linux
Asked Answered
A

5

5

I am trying to build OpenJpeg on an AWS Amazon Linux EC2 instance. I installed cmake and gcc and had no issues during installation. When I try to cmake openjpeg I get the following error:

-- Check if the system is big endian
-- Searching 16 bit integer
CMake Error at /usr/share/cmake/Modules/TestBigEndian.cmake:44 (message):
  no suitable type found
Call Stack (most recent call first):
  CMakeLists.txt:164 (TEST_BIG_ENDIAN)


-- Configuring incomplete, errors occurred!

Checking the error logs it seems CMake is unable to determine the size of integers, shorts and longs. The full error log can be found in this gist

How can I work this out and make CMake work?

Amendment answered 27/11, 2017 at 10:20 Comment(0)
B
23

Amazon has a guide: Preparing to Compile Software, which proposes the following command to install a C compiler.

sudo yum groupinstall "Development Tools"

Next, you can download and build Cmake yourself: Install Cmake 3.

wget https://cmake.org/files/v3.18/cmake-3.18.0.tar.gz
tar -xvzf cmake-3.18.0.tar.gz
cd cmake-3.18.0
./bootstrap
make
sudo make install

Note: the last make actually needs sudo.

Burbank answered 5/3, 2019 at 13:2 Comment(3)
./bootstrap failed for me after a few minutes. Could not find OpenSSL. Install an OpenSSL development package or configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL. this helped me resolve: discourse.cmake.org/t/how-to-compile-dcmake-use-openssl-off/…Winfrid
@JordanKohn I've solved it via the second answer including yum install sudo wget openssl-devel -y first, though I needed to use sudo for it.Cherie
yum install cmake3Draft
E
14

This works in the most recent Amazon Linux image (Nov 2021):

# Install sudo, wget and openssl, which is required for building CMake
yum install sudo wget openssl-devel -y

# Install development tools
sudo yum groupinstall "Development Tools" -y

# Download, build and install cmake
wget https://cmake.org/files/v3.18/cmake-3.18.0.tar.gz
tar -xvzf cmake-3.18.0.tar.gz
cd cmake-3.18.0
./bootstrap
make
sudo make install
Energumen answered 2/11, 2021 at 1:17 Comment(0)
P
1

You could try to set up a Docker container to replicate correct environment. This way, you could form a container on your local machine, make sure it all builds on the container environment, and later use this environment on the EC2.

There is a project on Github that provides a Docker image which can be used to compile for Lambda and test stuff locally. Have a look: https://github.com/lambci/docker-lambda

Presidentship answered 27/11, 2017 at 20:47 Comment(3)
Thabks but I need to build directly on the instance as I will move the package binaries to AWS lambdaAmendment
@ZaidAmir that's not a problem – have a look at this: github.com/lambci/docker-lambdaPresidentship
I honestly do not see how a container can solve this particular problem. The EC2 instance should replicate the lambda environment on its own. No need to add another layer of complexity to this.Amendment
A
1

Though this does not actually answer why the error was happening but I was able to build OpenJpeg by building CMake from source. So I just removed Cmake which was installed via yum and I believe was 2.8.12. Downloaded the latest CMake3 sources (v 3.10) built Cmake and openjpeg and all my other packages with no issues.

Amendment answered 3/12, 2017 at 6:46 Comment(0)
M
0

For Amazon Linux 2023 you can install cMake with dnf: dnf install cmake.

Here's an example of building a Docker image with Amazon Linux 2023 and cMake, for use as an AWS Lambda Function:

FROM public.ecr.aws/lambda/python:3.12
ENV PYTHONDONTWRITEBYTECODE=1

# Install cMake
RUN dnf install -y cmake

# Copy requirements.txt
COPY requirements.txt ${LAMBDA_TASK_ROOT}

# Install the specified packages
RUN pip install --no-cache-dir -r requirements.txt 

# Copy function code
COPY main.py ${LAMBDA_TASK_ROOT}

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "main.lambda_handler" ]
Mahler answered 2/2 at 1:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.