使用MinGW不构建SDL_gfx 2.0.24 DLL

时间:2013-03-22 12:49:16

标签: dll windows-7 64-bit mingw sdl

我正在为我的64位Windows 7系统设置简单直接媒体层库。基本库适用于MinGW和Free Pascal,但目前我想要包含SDL_gfx库。我发现在线教程说,我必须为Windows系统构建自己的DLL。 Link to the Tutorial. Chapter 4a is about GFX

我按照步骤操作并相应地更改了makefile。但是当我在gfx文件夹中运行“mingw32-make”时,它会中止错误消息“未定义引用'GFX_ALPHA_ADJUST_ARRAY'”。之后,此消息再次重复,但指向源代码的不同部分。然后“ld.exe”中止消息“在'.data'部分中的错误重定位地址0x0”。 “collect2.exe”也失败了,因为“ld”返回1作为结束状态。然后makefile抱怨说,“目标'SDL_gfx.dll'的配方失败了。”

我拥有一台Linux笔记本电脑,所以我认为尝试编译所有内容可能会有所帮助,但我不知道它有多复杂。所以基本上我要求建议做什么。在调试方面,我重新安装了整个SDL库并进行了测试,如果它正常工作的话。我安装的另一个DLL(SDL_image.dll)工作正常。

我已经在互联网上查看过预编译的DLL,但它们要么过时,要么是32位系统。但如果没有其他工作,这也可能是一个解决方案。我将发布makefile和源代码的部分,其中缺少变量。

生成文件

    CC = gcc
    AR=ar rc
    RANLIB=ranlib

    prefix=C:/
    bin_dir=$(prefix)/bin
    include_dir=$(prefix)/include
    lib_dir=$(prefix)/lib

    CFLAGS = -O3 -march=athlon-xp -mmmx -msse -m3dnow -DBUILD_DLL -IC:/MinGW/include/SDL
    LIBS = -LC:/MinGW/lib -lSDL

    OBJS = SDL_framerate.o SDL_gfxPrimitives.o SDL_imageFilter.o SDL_rotozoom.o

    STATIC_LIB=libSDL_gfx.a
    IMPORT_LIB=libSDL_gfx.dll.a
    SHARED_LIB=SDL_gfx.dll

    all: $(STATIC_LIB) $(SHARED_LIB)

    $(STATIC_LIB): $(OBJS)
    $(AR) $@ $^
    $(RANLIB) $@

    $(SHARED_LIB): $(OBJS)
gcc -s -shared -o $@ $^ -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(IMPORT_LIB) $(LIBS)

    test: $(SHARED_LIB) $(STATIC_LIB) Test/TestFramerate.exe Test/TestFonts.exe
    Test/TestGfxPrimitives.exe Test/TestImageFilter.exe Test/TestRotozoom.exe

    Test/TestFramerate.exe: Test/TestFramerate.c
gcc -c $^ -o Test/TestFramerate.o -O3 -march=athlon-xp -mmmx -msse -m3dnow -DWIN32 -Ic:/dev/local/include/SDL
gcc -o $@ Test/TestFramerate.o $(CFLAGS) -L../ -Lc:/dev/local/lib -lmingw32 -lSDLmain $(SHARED_LIB) -lSDL

    Test/TestFonts.exe: Test/TestFonts.c
gcc -c $^ -o Test/TestFonts.o -O3 -march=athlon-xp -mmmx -msse -m3dnow -DWIN32 -Ic:/dev/local/include/SDL
gcc -o $@ Test/TestFonts.o $(CFLAGS) -L../ -Lc:/dev/local/lib -lmingw32 -lSDLmain $(SHARED_LIB) -lSDL

    Test/TestGfxPrimitives.exe: Test/TestGfxPrimitives.c
gcc -c $^ -o Test/TestGfxPrimitives.o -O3 -march=athlon-xp -mmmx -msse -m3dnow -DWIN32 -Ic:/dev/local/include/SDL
gcc -o $@ Test/TestGfxPrimitives.o $(CFLAGS) -L../ -Lc:/dev/local/lib -lmingw32 -lSDLmain $(SHARED_LIB) -lSDL

    Test/TestImageFilter.exe: Test/TestImageFilter.c
gcc -c $^ -o Test/TestImageFilter.o -O3 -march=athlon-xp -mmmx -msse -m3dnow -DWIN32 -Ic:/dev/local/include/SDL
gcc -o $@ Test/TestImageFilter.o $(CFLAGS) -L../ -Lc:/dev/local/lib -lmingw32 -lSDLmain $(SHARED_LIB) -lSDL

    Test/TestRotozoom.exe: Test/TestRotozoom.c
gcc -c $^ -o Test/TestRotozoom.o -O3 -march=athlon-xp -mmmx -msse -m3dnow -DWIN32 -Ic:/dev/local/include/SDL
gcc -o $@ Test/TestRotozoom.o $(CFLAGS) -L../ -Lc:/dev/local/lib -lmingw32 -lSDLmain $(SHARED_LIB) -lSDL

    install: $(STATIC_LIB) $(SHARED_LIB)
cp $(STATIC_LIB) $(SHARED_LIB) $(IMPORT_LIB) $(lib_dir)
cp SDL_framerate.h SDL_gfxPrimitives.h SDL_imageFilter.h SDL_rotozoom.h $(include_dir)/SDL

    uninstall:
rm -f $(lib_dir)/$(STATIC_LIB)
rm -f $(lib_dir)/$(SHARED_LIB)
rm -f $(lib_dir)/$(IMPORT_LIB)
rm -f $(include_dir)/SDL/SDL_framerate.h
rm -f $(include_dir)/SDL/SDL_gfxPrimitives.h
rm -f $(include_dir)/SDL/SDL_imageFilter.h
rm -f $(include_dir)/SDL/SDL_rotozoom.h

    clean:
rm -f *.o *.a *.dll
rm -f Test/*.o Test/*.exe

来自'SDL_gfxPrimitives.c'的部分;第435-445行和第773-785行

    /*435-445*/
    #ifdef ALPHA_PIXEL_ADDITIVE_BLEND
                    A = (dA | GFX_ALPHA_ADJUST_ARRAY[alpha & 255]) << Ashift; // make destination less transparent...
    #else
                    A = ((dA + ((((color & Amask) >> Ashift) - dA) * alpha >> 8)) << Ashift) & Amask;
    #endif
                    *pixel |= A;
                }
            }
        }
        break;
    #endif

    /*773-785*/
    #ifdef ALPHA_PIXEL_ADDITIVE_BLEND
                        A = (dA | GFX_ALPHA_ADJUST_ARRAY[sA & 255]) << Ashift; // make destination less transparent...
    #else
                        A = ((dA + ((sA - dA) * alpha >> 8)) << Ashift) & Amask;
    #endif
                        *pixel |= A;
                    }
                }
            }
        }
    }
    break;
    #endif

1 个答案:

答案 0 :(得分:2)

您应该按照以下步骤修改Makefile:

1。 变化:

OBJS = SDL_framerate.o SDL_gfxPrimitives.o SDL_imageFilter.o SDL_rotozoom.o

To:

OBJS = SDL_framerate.o SDL_gfxBlitFunc.o SDL_gfxPrimitives.o SDL_imageFilter.o SDL_rotozoom.o

2。 变化:

cp SDL_framerate.h SDL_gfxPrimitives.h SDL_imageFilter.h SDL_rotozoom.h $(include_dir)/SDL

要:

cp SDL_framerate.h SDL_gfxBlitFunc.h SDL_gfxPrimitives.h SDL_imageFilter.h SDL_rotozoom.h $(include_dir)/SDL

3。 添加:rm -f $(include_dir)/SDL/SDL_gfxBlitFunc.h

之间

rm -f $(include_dir)/SDL/SDL_framerate.h

rm -f $(include_dir)/SDL/SDL_gfxPrimitives.h