0

I was trying out the muslcc images on dockerhub, but cannot run a compiled Hello World program.

The image I am using is: muslcc/i686:x86_64-linux-musl (found here). I load the image with:

docker run -it --rm -v /path/to/local:/var muslcc/i686:x86_64-linux-musl

so that I can code on my local machine, and compile and test on the musl image.


The program I am compiling is a basic hello world:

#include<stdio.h>

int main(void){
    puts("Hello world.");
    return 0;
}

This file is saved as helloworld.c

I run gcc -Wall helloworld.c and get a.out in the same directory. Doing ls -l gives me:

total 1068
-rwxr-xr-x    1 root     root          7584 Jul 25 05:41 a.out
-rw-r--r--    1 root     root            76 Jul 25 05:27 helloworld.c

When I try to run a.out with: ./a.out, I get:

/bin/sh: ./a.out: not found

I have also tried to specific an output file, in case this is some problem with a default output, but no luck. I have also tried with an absolute path, a la /var/a.out but also, no luck.

-- Edits:

  1. I have checked and the ./ symbol is in $PATH
asuprem
  • 554
  • 1
  • 5
  • 17

1 Answers1

0

Ok, I fixed it by adding the -static flag to gcc:

gcc -static input.c -o output.out
asuprem
  • 554
  • 1
  • 5
  • 17