C language > Expert questions

SDL issues

(1/2) > >>

goodwillhart:
Hi Pelles and others,

Some time ago I wrote a tutorial on how to set up SDL with Pelles C (with some help from Pelles that I recall). Since then a couple of users have had a go at making the install simpler and updating it.

However the latest version of the instructions don't seem to work with the latest SDL and latest Pelles C. I've fixed as many problems with the instructions, here, as I can:

http://www.friedspace.com/cprogramming/sdlsetup.php

But once I go to actually build a program that uses SDL, whilst it compiles, it won't execute. It simply gives the error message:

"The procedure entry point SDL_strlcpy could not be located in the dynamic link library SDL.dll."

Does anyone know what the cause of this might be, and how it might be rectified?

Bill Hart.

frankie:
Get the precompiled DLL from the SDL site and put it in a directory on your disk. Open command line interpreter, go in the directory where is sdl.dll and type in this command:

--- Code: ---polib sdl.dll /OUT:sdl.lib
--- End code ---
Now you have the import library sdl.lib.
Now get the source pakage from sdl site, you need only the include directory with all contents and the file "SDL_win32_main.c" and "version.rc" from directory "\src\main\win32". Compile the last two in a library if you like or just add them to your project.
Enjoy  ;D

goodwillhart:
Hi,

Thanks for taking a look at this. I tried building the sdl.lib using the polib command you specified and copied the new sdl.lib file into the Lib directory in Pelles C replacing the version I had in there.

It still complains that it can't find the entry point in the dll. I got a copy of the .dll file from Sam Lantinga who manages the SDL project and checked with him that the procedure is definitely contained in the dll. I did the whole procedure again with the dll file he sent, but no change. I get the same error message.

I also tried to compile the sdlmain.lib according to your instructions, but when I try to add the version.rc file to the project is complains that the "target file cannot be determined from the source files extension". If I don't add the .rc file to the project, it does compile the sdlmain library however.

I've tried searching my PellesC installation for other files called sdl.lib and sdl.dll and deleting them, just in case. This didn't change anything.

Bill Hart.

frankie:
It works here, and works also using the sdl.lib file from win32 precompiled development download (without to have to build sdl.lib on yourself).
Try to go to the test samples directory in the source distribution and compile each sample with the command lines:
--- Code: ---pocc /Ze /MT /I..\include testoverlay2.c SDL_win32_main.c
polink testoverlay2.obj SDL_win32_main.obj sdl.lib
--- End code ---
Of course you have to set environment for pellesc before.
If you are using an ide project to build your source maybe there is a problem in configuration. Post your project.
About the error including the rc file in the static lib this is normal because PellesC isn't able to store a resource in a static lib, so simply add it at your project.

goodwillhart:
OK, I tried it all again. Here is what I did:

1) Rename my old Pelles C installation to PellesCbak
2) Reinstall PellesC 4.5 from the files here:
http://www.smorgasbordet.com/pellesc/
3) Make a new console project, called SDL
4) Download and unzip the files SDL-devel-1.2.12-VC6.zip and SDL-1.2.12-win32.zip from this website:
http://www.libsdl.org/download-1.2.php
5) Copy the files SDL_win32_main.c and version.rc into the new SDL project directory.
6) Copy all the files in the include directory of the SDL files to the PellesC\Include directory.
7) Copy the SDL.dll file to the PellesC\Bin directory
8) Copy the SDL.lib file to the PellesC\Lib directory
9) Add an SDL program to the project (sdlexample.c below)
10) Add SDL_win32_main.c to the project
11) Select the compiler options "Enable Microsoft extensions" and "__cdecl" as the calling convention.
12) Add sdl.lib to the list of object and lib files under linker options.

At this point the project compiles, but gives the same error message about the dll file.

If I add version.rc to the project it doesn't compile because it looks for a nonexistent afxres.h included from the version.rc file. If I comment this out, it compiles, but does not run (with the same error message).

Here is the program I am compiling (sdlexample.c):

/**********************************************************************/

#include <stdio.h>
#include "SDL.h"

#define WIDTH 640
#define HEIGHT 480
#define BPP 4
#define DEPTH 32

void setpixel(SDL_Surface *screen, int x, int y, Uint8 r, Uint8 g, Uint8 b)
{
    Uint32 *pixmem32;
    Uint32 colour; 
 
    colour = SDL_MapRGB( screen->format, r, g, b );
 
    pixmem32 = (Uint32*) screen->pixels  + y + x;
    *pixmem32 = colour;
}


void DrawScreen(SDL_Surface* screen, int h)
{
    int x, y, ytimesw;
 
    if(SDL_MUSTLOCK(screen))
    {
        if(SDL_LockSurface(screen) < 0) return;
    }

    for(y = 0; y < screen->h; y++ )
    {
        ytimesw = y*screen->pitch/BPP;
        for( x = 0; x < screen->w; x++ )
        {
            setpixel(screen, x, ytimesw, (x*x)/256+3*y+h, (y*y)/256+x+h, h);
        }
    }

    if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
 
    SDL_Flip(screen);
}


int main(int argc, char* argv[])
{
    SDL_Surface *screen;
    SDL_Event event;
 
    int keypress = 0;
    int h=0;
 
    if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
   
    if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_FULLSCREEN|SDL_HWSURFACE)))
    {
        SDL_Quit();
        return 1;
    }
 
    while(!keypress)
    {
         DrawScreen(screen,h++);
         while(SDL_PollEvent(&event))
         {     
              switch (event.type)
              {
                  case SDL_QUIT:
                 keypress = 1;
                 break;
                  case SDL_KEYDOWN:
                       keypress = 1;
                       break;
              }
         }
    }

    SDL_Quit();
 
    return 0;
}

/************************************************************************/

Here is the project file which Pelles C creates:

/************************************************************************/

#
# PROJECT FILE generated by "Pelles C for Windows, version 4.50".
# WARNING! DO NOT EDIT THIS FILE.
#

POC_PROJECT_VERSION = 4.00#
POC_PROJECT_TYPE = 3#
POC_PROJECT_ARGUMENTS = #
POC_PROJECT_WORKPATH = #
POC_PROJECT_EXECUTOR = #
CC = pocc.exe#
AS = poasm.exe#
RC = porc.exe#
LINK = polink.exe#
CCFLAGS =  -Tx86-coff -Ot -W1 -Gd -Ze #
ASFLAGS = -AIA32 -Gd#
RCFLAGS = -r#
LINKFLAGS =  -subsystem:console -machine:ix86  kernel32.lib advapi32.lib delayimp.lib sdl.lib#

.SILENT:

#
# Build SDL.exe.
#
SDL.exe: \
   output\SDL_win32_main.obj \
   output\sdlexample.obj
   $(LINK) $(LINKFLAGS) -out:"$@" $**

#
# Build SDL_win32_main.obj.
#
output\SDL_win32_main.obj: \
   SDL_win32_main.c \
   ..\..\Include\SDL.h \
   ..\..\Include\SDL_main.h \
   ..\..\Include\SDL_stdinc.h \
   ..\..\Include\SDL_config.h \
   ..\..\Include\SDL_platform.h \
   ..\..\Include\SDL_config_minimal.h \
   ..\..\Include\begin_code.h \
   ..\..\Include\close_code.h \
   ..\..\Include\SDL_audio.h \
   ..\..\Include\SDL_error.h \
   ..\..\Include\SDL_endian.h \
   ..\..\Include\SDL_mutex.h \
   ..\..\Include\SDL_thread.h \
   ..\..\Include\SDL_rwops.h \
   ..\..\Include\SDL_cdrom.h \
   ..\..\Include\SDL_cpuinfo.h \
   ..\..\Include\SDL_events.h \
   ..\..\Include\SDL_active.h \
   ..\..\Include\SDL_keyboard.h \
   ..\..\Include\SDL_keysym.h \
   ..\..\Include\SDL_mouse.h \
   ..\..\Include\SDL_video.h \
   ..\..\Include\SDL_joystick.h \
   ..\..\Include\SDL_quit.h \
   ..\..\Include\SDL_loadso.h \
   ..\..\Include\SDL_timer.h \
   ..\..\Include\SDL_version.h
   $(CC) $(CCFLAGS) "$!" -Fo"$@"

#
# Build sdlexample.obj.
#
output\sdlexample.obj: \
   sdlexample.c \
   ..\..\Include\SDL.h \
   ..\..\Include\SDL_main.h \
   ..\..\Include\SDL_stdinc.h \
   ..\..\Include\SDL_config.h \
   ..\..\Include\SDL_platform.h \
   ..\..\Include\SDL_config_minimal.h \
   ..\..\Include\begin_code.h \
   ..\..\Include\close_code.h \
   ..\..\Include\SDL_audio.h \
   ..\..\Include\SDL_error.h \
   ..\..\Include\SDL_endian.h \
   ..\..\Include\SDL_mutex.h \
   ..\..\Include\SDL_thread.h \
   ..\..\Include\SDL_rwops.h \
   ..\..\Include\SDL_cdrom.h \
   ..\..\Include\SDL_cpuinfo.h \
   ..\..\Include\SDL_events.h \
   ..\..\Include\SDL_active.h \
   ..\..\Include\SDL_keyboard.h \
   ..\..\Include\SDL_keysym.h \
   ..\..\Include\SDL_mouse.h \
   ..\..\Include\SDL_video.h \
   ..\..\Include\SDL_joystick.h \
   ..\..\Include\SDL_quit.h \
   ..\..\Include\SDL_loadso.h \
   ..\..\Include\SDL_timer.h \
   ..\..\Include\SDL_version.h
   $(CC) $(CCFLAGS) "$!" -Fo"$@"

.EXCLUDEDFILES:

/************************************************************************/

It makes no difference if I select multithreaded dll (the -MT option you use).

Thanks again for taking the time to help me with this problem.

Bill Hart.


Navigation

[0] Message Index

[#] Next page

Go to full version