NO

Author Topic: SDL issues  (Read 11451 times)

goodwillhart

  • Guest
SDL issues
« on: August 08, 2007, 06:35:50 AM »
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.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: SDL issues
« Reply #1 on: August 08, 2007, 06:19:06 PM »
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: [Select]
polib sdl.dll /OUT:sdl.libNow 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
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

goodwillhart

  • Guest
Re: SDL issues
« Reply #2 on: August 09, 2007, 09:08:06 PM »
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.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: SDL issues
« Reply #3 on: August 10, 2007, 02:11:31 PM »
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: [Select]
pocc /Ze /MT /I..\include testoverlay2.c SDL_win32_main.c
polink testoverlay2.obj SDL_win32_main.obj sdl.lib
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.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

goodwillhart

  • Guest
Re: SDL issues
« Reply #4 on: August 10, 2007, 10:29:31 PM »
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.



goodwillhart

  • Guest
Re: SDL issues
« Reply #5 on: August 10, 2007, 10:35:40 PM »
The same problem occurs if I try to build one of the test example programs from the SDL distribution.

Bill Hart.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: SDL issues
« Reply #6 on: August 10, 2007, 11:42:45 PM »
I followed your instructions making same moves.
I cut and paste your code in local files.
The project works here!
It seems there is a problem on your computer. I post the zipped project with the executabe, does it runs on your system? (try it before trying to recompile!!!).
If you still have problem please post the errors you have ***literally***, I mean the exact error text you get.
ps: I fixed the rc file.
« Last Edit: August 10, 2007, 11:56:47 PM by frankie »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

goodwillhart

  • Guest
Re: SDL issues
« Reply #7 on: August 11, 2007, 01:48:12 AM »
No indeed it doesn't work on my PC. I get exactly the same error message:

SDL.exe - Entry Point Not Found

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

This is a wierd problem indeed. I am going to try removing all copies of SDL.dll from my machine. There must be a copy of an old version of the file somewhere that is interfering with the new version.

Bill Hart.


goodwillhart

  • Guest
Re: SDL issues
« Reply #8 on: August 11, 2007, 01:59:26 AM »
Ah, it works now. There must have been 20 different copies of sdl.dll, SDL.dll and SDL.dLL on my machine. Everything from a Space Quest sequel game, to Ur Quan masters to demoscene demos, old copies of my website, PellesC, etc, etc, etc.

There was also an SDL.DLL in my windows/system directory which was presumably the one causing the problem. I have no idea what program installed it or even if it has anything to do with SDL. When I removed it, everything started working.

Thanks very much for all your help. Once you sent me the zip file, that helped me narrow the problem down very quickly, though it should have occurred to me earlier. I just assumed there were no other SDL.dll files on my machine, since the only one I recall putting on was in the old PellesC installation. I didn't realise how ubiquitous SDL had become.

Bill Hart.