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?

Zaid Amir
  • 4,727
  • 6
  • 52
  • 101

4 Answers4

22

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.

diginoise
  • 7,352
  • 2
  • 31
  • 39
bvdb
  • 22,839
  • 10
  • 110
  • 123
  • 1
    ./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: https://discourse.cmake.org/t/how-to-compile-dcmake-use-openssl-off/1271 – Jordan Kohn Nov 17 '21 at 23:16
11

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
Leandro Barone
  • 129
  • 1
  • 4
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.

Zaid Amir
  • 4,727
  • 6
  • 52
  • 101
0

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

ivanmoskalev
  • 2,004
  • 1
  • 16
  • 25
  • Thabks but I need to build directly on the instance as I will move the package binaries to AWS lambda – Zaid Amir Nov 27 '17 at 21:15
  • @ZaidAmir that's not a problem – have a look at this: https://github.com/lambci/docker-lambda – ivanmoskalev Nov 27 '17 at 21:42
  • 1
    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. – Zaid Amir Dec 03 '17 at 06:45