Jump to content
  • Advertisement
Sign in to follow this  
GenuineXP

Building Libraries (for SDL)

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I'm a beginner working with SDL. I recently added a few threads to get some help with loading images into my sprite class. Well, I have a new question. :-P I'm trying to create an isometric game, but I don't want to use sprites for the tiles. Instead, I want to draw the tiles using polygons. I've found several libraries for SDL that seem to make drawing polygons a snap... but I have no idea how to use them! I'm using Code::Blocks and the GNU GCC Compiler, so I can't use any of the DSP files that come with the packages to build the libraries. How can I go about doing this? All I need are the library files and the headers, but I have no idea how to make them! Any help is very appreciated. Thanks in advance. :-)

Share this post


Link to post
Share on other sites
Advertisement
I'm looking at two libraries, actually.

One is called SDL_gfx. http://www.ferzkopp.net/~aschiffler/Software/SDL_gfx-2.0/

The other is called SDL_draw. http://sdl-draw.sourceforge.net/

SDL_gfx seems more favorable. It has support for alpha blending at high speed with hardware acceleration and anti-aliasing certain primitives like lines and circles.

Does that help...?

Thanks for the quick reply, by the way. :-)

Share this post


Link to post
Share on other sites
Step by step

* File->New Project
* Dynamic Link Library, "Do not create any files"
* Right click on "DLL Sample" on the left bottom pane, select add files and select all the .h/.c files for SDL_Gfx (i just copied them all to a new folder where I made this project at)
* Hit Ctrl+F11 and Yes to build everything

Your library should now be made. Of course you will get a lot of messages:

Project : DLL Sample
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\Drew Benton\Desktop\SDL_gfx--------------------------------------------------------------------------------
Switching to target: default
Compiling: SDL_gfxPrimitives.c
Compiling: SDL_imageFilter.c
Compiling: SDL_rotozoom.c
Compiling: SDL_framerate.c
Linking dynamic library: sample.dll
Creating library file: libsample.a
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1fc): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x252): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x2be): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x34c): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x5e6): undefined reference to `SDL_MapRGB'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0xb09): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0xb6b): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0xbbf): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0xc37): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0xe8a): undefined reference to `SDL_MapRGB'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x13ce): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1430): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1494): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1650): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x17f9): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x192b): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1b4c): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1b5a): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1c8c): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1ee3): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1ef1): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x1ff3): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x2a3d): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x2a4b): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x2c13): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x2f1e): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x2f80): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x32fa): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x357c): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x37cc): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x3ab9): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x3b1b): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x3e42): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x4184): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x49ea): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x4a5e): undefined reference to `SDL_MapRGBA'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x58d5): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x5c3b): undefined reference to `SDL_LockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x6373): undefined reference to `SDL_UnlockSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x7ea3): undefined reference to `SDL_FreeSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x805c): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x80cb): undefined reference to `SDL_SetAlpha'
.objs\SDL_gfxPrimitives.o:SDL_gfxPrimitives.c:(.text+0x81a5): undefined reference to `SDL_UpperBlit'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x1b7e): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x1ba3): undefined reference to `SDL_UpperBlit'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x1d54): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x1d9b): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x1da9): undefined reference to `SDL_LockSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x1e5f): undefined reference to `SDL_SetAlpha'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x1f5b): undefined reference to `SDL_SetColorKey'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x1f66): undefined reference to `SDL_UnlockSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x2002): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x2049): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x2057): undefined reference to `SDL_LockSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x20a5): undefined reference to `SDL_SetAlpha'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x2151): undefined reference to `SDL_SetColorKey'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x215c): undefined reference to `SDL_UnlockSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x2170): undefined reference to `SDL_FreeSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x22b2): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x22d7): undefined reference to `SDL_UpperBlit'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x23c0): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x2407): undefined reference to `SDL_CreateRGBSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x2415): undefined reference to `SDL_LockSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x245d): undefined reference to `SDL_SetAlpha'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x2503): undefined reference to `SDL_SetColorKey'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x250e): undefined reference to `SDL_UnlockSurface'
.objs\SDL_rotozoom.o:SDL_rotozoom.c:(.text+0x251f): undefined reference to `SDL_FreeSurface'
.objs\SDL_framerate.o:SDL_framerate.c:(.text+0x29): undefined reference to `SDL_GetTicks'
.objs\SDL_framerate.o:SDL_framerate.c:(.text+0xb3): undefined reference to `SDL_GetTicks'
.objs\SDL_framerate.o:SDL_framerate.c:(.text+0x114): undefined reference to `SDL_Delay'
.objs\SDL_framerate.o:SDL_framerate.c:(.text+0x127): undefined reference to `SDL_GetTicks'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
0 errors, 0 warnings




Because the input libraries were not specified. If you click on Project->Build Options->Linker options tab, you will need to add in the .a file for the "libSDL.dll.a" file (SDL 1.2.9) and you will now get

Project : DLL Sample
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Documents and Settings\Drew Benton\Desktop\SDL_gfx--------------------------------------------------------------------------------
Switching to target: default
Compiling: SDL_gfxPrimitives.c
Compiling: SDL_imageFilter.c
Compiling: SDL_rotozoom.c
Compiling: SDL_framerate.c
Linking dynamic library: sample.dll
Creating library file: libsample.a
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings




That's it! No project file needed, good luck. Let us know if you run into troubles. Just make sure you have added in the directories to the compiler for the SDL library.

Share this post


Link to post
Share on other sites
Thanks! That seems to have worked perfectly! I had to change a few lines in the code from "#include<SDL.h>" to "#include<SDL/SDL.h>", but that's about it. :-) Now I have a DLL and an A file!

Thanks for the help. Maybe I can handle compiling other libraries now. :-P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!