Running CMake on Amazon Linux

Viewed 8100

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?

4 Answers

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.

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

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

Related