2

我正在为我的 64 位 Windows 7 系统设置简单直接媒体层库。基本库适用于 MinGW 和 Free Pascal,但目前我想包含 SDL_gfx 库。我发现的在线教程说,我必须为 Windows 系统构建自己的 DLL。链接到教程。第 4a 章是关于 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) 也可以正常工作。

我已经在 Internet 上查找了预编译的 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
4

1 回答 1

2

You should modify Makefile according to the following steps:

1. Change:

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. Change:

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

To:

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

3. Add: rm -f $(include_dir)/SDL/SDL_gfxBlitFunc.h

Between

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

And

rm -f $(include_dir)/SDL/SDL_gfxPrimitives.h
于 2013-04-05T09:55:40.720 回答