D and SDL - undefined functions

I have a very simple program D (pk.d):

import std.stdio;
import SDL;

int main(string[] args) {
    writefln("Hello world");
    if (SDL_Init( SDL_INIT_VIDEO ) < 0) {
        writefln("Unable to init SDL");
        return 1;
    }

    return 0;
}

I have a very simple make script (here I am here, but the Windows D compiler comes with a bash interpreter):

DMD=dmd
DFLAGS=-I./lib/SDL 

$(DMD) pk $(DFLAGS)
pk

But when I create it, I get Error 42: Symbol Undefined _SDL_Init

He managed to import the SDL in order, and he finds SDL_INIT_VIDEO just fine. I went ahead and checked in SDL.d and found that there is a definition for SDL_Init: int SDL_Init(Uint32 flags);. I can’t figure it out. This is the first non-STL library I imported with D, so hopefully my error is obvious, can anyone see it?

+3
source share
3 answers

SDL. , . , - pragma(lib, "SDL.lib") .

+5

D SDL.

import std.stdio;
import sdl;

int main(string[] args)
{
    SDL_Surface * screen;

    SDL_Init(SDL_INIT_EVERYTHING);
    screen = SDL_SetVideoMode(800, 600, 24, SDL_SWSURFACE);

    SDL_FillRect(screen, &screen.clip_rect, SDL_MapRGB(screen.format, 
                                                       0xFF, 0x00, 0x00));
    SDL_Flip(screen);

    SDL_Delay(6000);
    return 0;
}

. , SDL VC6

OMF. coff2omf, Borland ++ Compiler, . DigitalMars , . .

coff2omf.exe SDL.lib SDL2.lib

:

dmd -c test.d sdl.d

test.obj sdl.obj SDL2.lib

.

0

, D SDL, . sdl.d, .

0
source

Source: https://habr.com/ru/post/1794636/


All Articles