Coder Social home page Coder Social logo

Comments (6)

fccm avatar fccm commented on June 25, 2024

(You can set the English language with LANG=en)

Have you check what is the path for the headers?

from ocamlsdl2.

fccm avatar fccm commented on June 25, 2024

In the command line that produced the error the path for headers is /usr/include/SDL2.
Did you check if the headers for SDL2 are there?
This is usually the standard path for a C lib, but it can also be /usr/local/include for libs installed from sources.
Do you know what is the path where the headers for SDL2 have been installed on your system?

Header files in the C programming language are files with *.h file extension.
A C lib always provide header files like this. This is the equivalence of *.mli files of ocaml. In OCaml we call it signature files or interface files, but in C we call it header files.

In both C with gcc and OCaml this path is provided by -I as you can see in the log file you provided.

from ocamlsdl2.

jarmuszz avatar jarmuszz commented on June 25, 2024

SDL headers are present in /usr/include/SDL2. Moreover,

#include <SDL2/SDL.h>
int
main(int argc, char *argv[])
{
        SDL_Init(SDL_INIT_VIDEO);
        SDL_Window *win = SDL_CreateWindow("foobar",
                        SDL_WINDOWPOS_UNDEFINED,
                        SDL_WINDOWPOS_UNDEFINED,
                        200, 200,
                        SDL_WINDOW_SHOWN);

        SDL_Delay(500);
        SDL_Quit();
}

compiles and runs fine with
x86_64-w64-mingw32-gcc main.c -I /usr/include/ -L /usr/lib -lmingw32 -lSDL2main -lSDL2 -mwindows

Interestingly, the x86_64-w64-mingw32-gcc binary doesn't seem to include nor link the "standard" directories such as /usr/lib and /usr/include.

I also noticed that the command that errors out uses the i686 gcc instead of the x86_64.

I tried to "extract" a c compiler command from the ocamlc line that fails to get a more in-depth error message but I was not able to reach anything worth mentioning.

Also, I think it's worth to mention that this is a windows's error message, not a cygwin/posix one.

from ocamlsdl2.

fccm avatar fccm commented on June 25, 2024

In the logs you provided, the command line was:
ocamlc -cc "c:/cygwin/bin/i686-w64-mingw32-gcc.exe -g -Wall -Werror" -ccopt "-static -I/usr/include/SDL2 -Dmain=SDL_main -g -O " sdlinit_stub.c
If your test in pure C does work, you can just put the same arguments.
You can replace gcc-32bits by gcc-64bit if you want.
You can see that the -cc command provides the gcc command.
You can probably remove -Wall and -Werror (kitykate already told me I should remove it from a release)
You can also remove -static if this is not a static version that you want, or if the SDL2 that you installed don't include the static version.
If you want to see what is the command line run by ocamlopt and ocamlc the argument is -verbose.
In the ocamlc call the argument -ccopt are the arguements that will be provided to the C compiler.

If this one works:
x86_64-w64-mingw32-gcc main.c -I /usr/include/ -L /usr/lib -lmingw32 -lSDL2main -lSDL2 -mwindows

You could try:
ocamlc -verbose -cc "x86_64-w64-mingw32-gcc" -ccopt "-I /usr/include/SDL2 -I /usr/include -L /usr/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -Dmain=SDL_main -g -O " sdlinit_stub.c

(If you want to share a mini-game on the internet (for example on Itch.io), there are still people using old 32bit computers. If you compile for 64bit they will not be able to run your game. If you compile for 32bit, people with 64bit computers will be able to run your game fine.)

from ocamlsdl2.

fccm avatar fccm commented on June 25, 2024

Hi again, I just see on your page that you know some assembly, you may be interested to have a look at the assembly created by ocamlopt with -S:

echo 'print_endline "Hello"' > h.ml
ocamlopt -S -o h.opt h.ml
cat h.s

from ocamlsdl2.

jarmuszz avatar jarmuszz commented on June 25, 2024

I feel kinda dumb now. I forgot that the Makefile.config file has to be created by hand, not generated by the main Makefile and so I was placing all of my fixes in Makefile.config.win32 wondering why won't they work... 🥲

The only change that has to be made to build successfully on windows is removing the -Werror (as you said above).

BTW thanks for all of this info, it surely will help me later :)

from ocamlsdl2.

Related Issues (16)

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.