Code Monkey home page Code Monkey logo

Comments (5)

W2Wizard avatar W2Wizard commented on June 27, 2024

Well that's a whole new error i've never seen before.
I however simply get:

- docker build -t mlx42-test .
- docker run -it mlx42-test
Failed to initialize GLFW

Which makes sense as there is no display to launch with docker, even with MLX_HEADLESS it won't work as a "Window" context is needed.

from mlx42.

GroteGnoom avatar GroteGnoom commented on June 27, 2024

Yes, there was a lot of work to overcome 'Failed to initialize GLFW' for me too :D I used xquartz and

echo 'first start docker desktop yourself, else this will not work'
export DISPLAY=127.0.0.1:0
xhost + 127.0.0.1
export BUILDKIT_PROGRESS=plain
docker build --build-arg CACHEBUST=$(date +%s) -t mlx42-app .
docker run --rm -it -e DISPLAY=host.docker.internal:0 \
     -e LIBGL_ALWAYS_SOFTWARE=1 \
     -e LIBGL_ALWAYS_INDIRECT=1 \
     -v /tmp/.X11-unix:/tmp/.X11-unix mlx42-app
  • not everything is relevant, but maybe this works

from mlx42.

W2Wizard avatar W2Wizard commented on June 27, 2024

Ok so this took a bit of digging but I found a docker file that handles exactly all of this stuff.

I suggest forking: https://github.com/BoundfoxStudios/docker-opengl

FROM boundfoxstudios/opengl:latest

# Install necessary dependencies
RUN apk update && apk add --no-cache gcc g++ make openssl-dev cmake git bash glfw-dev mesa-dev git

# Clone the repo
RUN git clone https://github.com/codam-coding-college/MLX42.git /MLX42

# Copy your minilibx.c file
COPY minilibx.c /tmp

# Set the working directory
WORKDIR /tmp

# Build the project
RUN cd /MLX42 && \
    cmake -B build && \
    cmake --build build -j4

# Set the default command to compile and run your program
CMD gcc /tmp/minilibx.c -g /MLX42/build/libmlx42.a -I/MLX42/include -ldl -lglfw -pthread -lm && ./a.out

I modified the .c file to just print the address:

# include "MLX42/MLX42.h"
# include <stdio.h>
# include <stdlib.h>

# define WIDTH 512
# define HEIGHT 512

int    main(void)
{
    mlx_t    *mlx;

    mlx_set_setting(MLX_HEADLESS, true);
    if (!(mlx = mlx_init(WIDTH, HEIGHT, "MLX42", true)))
    {
        puts(mlx_strerror(mlx_errno));
        return(EXIT_FAILURE);
    }
    printf("mlx_init: %p\n", mlx);
}

And instead of an error now you get:

Starting Xvfb
Waiting for Xvfb (PID: 7) to be ready...
Xvfb is running.
mlx_init: 0xffff915dd1b0
Waiting for Xvfb (PID: 7) to shut down...

from mlx42.

W2Wizard avatar W2Wizard commented on June 27, 2024

I tested it with the program in the README.md, seems to work perfectly fine!

If this works for you too i'll add it to the readme or create a Docker example so in the future others can look into how to make it work with Docker and avoid doing all this annoying Xvfb non-sense.

from mlx42.

W2Wizard avatar W2Wizard commented on June 27, 2024

I assume for now, yes, if not, please re-open.

from mlx42.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.