2017-05-08 6 views
0

EmscriptenでSDL2 Imageを使用するNimプロジェクトをコンパイルしようとしましたが、いくつかののタイプが衝突します。エラー。私はこの小さなコードスニペットでこの問題を再現することができます:私は、このコードスニペットをコンパイルすると、私はエラーをEmscriptenでNimとSDL2 Imageをコンパイルするときに競合するタイプ

index.nim

import sdl2, sdl2.image 

const imgFlags: cint = IMG_INIT_PNG 
if image.init(imgFlags) != imgFlags: 
    raise Exception.newException(
    "SDL2 Image initialization failed, SDL error: " & $getError()) 

nim.cfg

@if emscripten: 
    define = SDL_Static 
    gc = none 
    cc = clang 
    clang.exe = "emcc" 
    clang.linkerexe = "emcc" 
    clang.options.linker = "" 
    cpu = "i386" 
    out = "index.html" 
    warning[GcMem] = off 
    passC = "-Wno-warn-absolute-paths -I/path/to/SDL2/headers" 
    passL = "-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='[\"png\"]'" 
@end 

を取得します:競合するタイプ

$ nim c -d:emscripten index.nim 
Hint: used config file '/path/to/Nim/config/nim.cfg' [Conf] 
Hint: used config file '/path/to/my-project/nim.cfg' [Conf] 
Hint: system [Processing] 
Hint: index [Processing] 
Hint: sdl2 [Processing] 
Hint: macros [Processing] 
Hint: unsigned [Processing] 
Hint: strutils [Processing] 
Hint: parseutils [Processing] 
Hint: math [Processing] 
Hint: algorithm [Processing] 
SDL2 will be statically linked. Please make sure you pass the correct linker flags (library search paths, linked libraries). 
Hint: image [Processing] 
CC: index 
Error: execution of an external compiler program 'emcc -c -w -Wno-warn-absolute-paths -Iinclude -I/path/to/Nim/lib -o /path/to/my-project/nimcache/index.o /path/to/my-project/nimcache/index.c' failed with exit code: 1 

/path/to/my-project/nimcache/index.c:65:21: error: conflicting types for 'SDL_GetError' 
N_NIMCALL(NCSTRING, SDL_GetError)(void); 
        ^
/path/to/SDL2/SDL_error.h:42:37: note: previous declaration is here 
extern DECLSPEC const char *SDLCALL SDL_GetError(void); 
            ^

何かを間違って設定しましたか?どうすれば修正できますか?

編集:私はnim.cfgからdefine = SDL_Staticを削除する場合が、私はこのエラーを得ることはありませんが、私はそれを行う場合、私はSDLへの静的リンクはできません。


ニムコンパイラバージョン0.16.1(2017年5月7日)[Linuxの場合:AMD64](develのブランチの最新バージョン)

EMCC(Emscriptenのgcc /打ち鳴らすような交換)1.37.9(コミットb5bee629cb54864e7e231ae55a7d0ae9bdc25c6c)

+2

sdl2.image.nimのように見えます。モジュールにはバグがあります。この問題は、通常のネイティブターゲットにコンパイルするときに再現される可能性があります。そうであれば、問題をnim-lang/sdl2プロジェクトに報告してください。 – uran

+0

'nim c index.nim'(no -d:emscripten')を実行するとエラーなしでコンパイルされます。 – maiermic

答えて

1

thisプルリクエストで修正されたbugです。パッケージsdl2のバージョン1.2でリリースされるはずです。ニムコンパイラに--dynlibOverride:SDL2を渡す静的にリンクするには

nimble install sdl2#head 

:それまでは、リポジトリから最新の(開発)バージョンをインストールすることができます。

関連する問題