トップページ > 記事閲覧
コンパイルできません
名前:名無し 日時: 2019/09/14 14:11

minGWでコンパイルしようとすると、 In file included from DxDataType.h:17, from DxCompileConfig.h:391, from DxLib.h:12, from dx.c:2: DxDataTypeWin.h:1255:1: error: unknown type name 'namespace'; did you mean '_istspace'? namespace DxLib ^~~~~~~~~ _istspace DxDataTypeWin.h:1256:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token { ^ In file included from DxCompileConfig.h:391, from DxLib.h:12, from dx.c:2: DxDataType.h:36:1: error: unknown type name 'namespace'; did you mean '_istspace'? namespace DxLib ^~~~~~~~~ _istspace DxDataType.h:37:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token { ^ In file included from dx.c:2: DxLib.h:1107:1: error: unknown type name 'namespace'; did you mean '_istspace'? namespace DxLib ^~~~~~~~~ _istspace DxLib.h:1108:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token { ^ In file included from DxLib.h:1802, from dx.c:2: DxFunctionWin.h:16:1: error: unknown type name 'namespace'; did you mean '_istspace'? namespace DxLib ^~~~~~~~~ _istspace DxFunctionWin.h:17:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token { ^ In file included from dx.c:2: DxLib.h:1822:1: error: unknown type name 'namespace'; did you mean '_istspace'? namespace DxLib ^~~~~~~~~ _istspace DxLib.h:1823:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token { ^ In file included from dx.c:2: DxLib.h:5265:1: error: unknown type name 'using'; did you mean 'u_int'? using namespace DxLib ; ^~~~~ u_int DxLib.h:5265:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'DxLib' using namespace DxLib ; ^~~~~ dx.c: In function 'WinMain': dx.c:4:20: error: parameter name omitted int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){ ^~~~~~~~~ dx.c:4:30: error: parameter name omitted int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){ ^~~~~~~~~ dx.c:4:40: error: parameter name omitted int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){ ^~~~~ dx.c:4:46: error: parameter name omitted int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){ ^~~ dx.c:5:9: warning: implicit declaration of function 'DxLib_Init'; did you mean 'LZInit'? [-Wimplicit-function-declaration] DxLib_Init(); // DX・1;35m^~~~~~~~~~ LZInit dx.c:8:9: warning: implicit declaration of function 'WaitKey' [-Wimplicit-function-declaration] WaitKey(); // ・1;35m^~~~~~~ dx.c:9:9: warning: implicit declaration of function 'DxLib_End' [-Wimplicit-function-declaration] DxLib_End(); // DX・1;35m^~~~~~~~~ と、表示されて、コンパイルできません。 コードは #define DX_GCC_COMPILE #include "DxLib.h" int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){ DxLib_Init(); // DXライブラリ初期化処理 WaitKey(); // キー入力待ち DxLib_End(); // DXライブラリ終了処理 return 0; } です。 どのようにすればコンパイルできるでしょうか?
メンテ

Page: 1 |

Re: コンパイルできません ( No.1 )
名前:管理人 日時:2019/09/14 22:05

DXライブラリを使用するプログラムは C++ のファイルである必要がありますので、 dx.c のファイル名を dx.cpp に変更すれば正常にコンパイルできます よろしければお試しください m(_ _)m
メンテ
Re: コンパイルできません ( No.2 )
名前:名無し 日時:2019/09/15 00:23

ご指摘通りdx.cppでコンパイルしたら c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\゙[ス\AppData\Local\Temp\cc30Toaz.o:dx.cpp:(.text+0x7): undefined reference to `DxLib::DxLib_Init()' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\゙[ス\AppData\Local\Temp\cc30Toaz.o:dx.cpp:(.text+0xc): undefined reference to `DxLib::WaitKey()' c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\゙[ス\AppData\Local\Temp\cc30Toaz.o:dx.cpp:(.text+0x11): undefined reference to `DxLib::DxLib_End()' collect2.exe: error: ld returned 1 exit status と表示されてコンパイルできませんでした。
メンテ
Re: コンパイルできません ( No.3 )
名前:管理人 日時:2019/09/15 12:46

関数のリンクが失敗しているようです MinGWの使い方ページの『リンク時に必要なオプション』に記載されている <リンク時に必要なオプション> https://dxlib.xsrv.jp/use/dxuse_gcc.html#R4 -lDxLib -lDxUseCLib -lDxDrawFunc -ljpeg -lpng -lzlib -ltiff -ltheora_static -lvorbis_static -lvorbisfile_static -logg_static -lbulletdynamics -lbulletcollision -lbulletmath -lopusfile -lopus -lsilk_common -lcelt はコンパイルのコマンドに記述されていますでしょうか? あと、もし記述されていてもエラーが発生するとのことでしたら、お手数で申し訳ありませんが コマンドからエラー出力までを全部こちらの掲示板にコピー&貼り付けしてください m(_ _)m
メンテ
Re: コンパイルできません ( No.4 )
名前:名無し 日時:2019/09/15 16:00

何度も申し訳ありません。 上記のオプションを記述しましても、 C:\Users\あああ\Desktop\いいい\DXライブラリ>set PATH=C:\MinGW\bin;C:\MinGW\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Windows Live\Shared;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Skype\Phone\;C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\あああ\AppData\Local\Microsoft\WindowsApps; C:\Users\あああ\Desktop\いいいDXライブラリ>g++ dx.cpp -lDxLib -lDxUseCLib -lDxDrawFunc -ljpeg -lpng -lzlib -ltiff -ltheora_static -lvorbis_static -lvorbisfile_static -logg_static -lbulletdynamics -lbulletcollision -lbulletmath -lopusfile -lopus -lsilk_common -lcelt c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lDxLib c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lDxUseCLib c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lDxDrawFunc c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -ljpeg c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lpng c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lzlib c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -ltiff c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -ltheora_static c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lvorbis_static c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lvorbisfile_static c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -logg_static c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lbulletdynamics c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lbulletcollision c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lbulletmath c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lopusfile c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lopus c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lsilk_common c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lcelt collect2.exe: error: ld returned 1 exit status と、表示されてコンパイルできませんでした。
メンテ
Re: コンパイルできません ( No.5 )
名前:管理人 日時:2019/09/16 03:27

貼り付けありがとうございます エラーが発生する原因が分かりました オプションにリンクするライブラリファイルがあるパスを指定する -L オプション -L(libDxLib.aなどがあるフォルダのパス) が無いのが原因です ただ、ログを拝見する限りではお使いのバージョンは MinGW の 8.2.0 のようですが、 DXライブラリGCC版には 8.2.0 用のライブラリファイルはありません 8.2.0 用のライブラリファイルを追加しようと思いますので、 よろしければお使いの mingw をダウンロードされたウェブサイトを教えていただけないでしょうか? m(_ _)m
メンテ
Re: コンパイルできません ( No.6 )
名前:名無し 日時:2019/09/16 09:03

こちらです。 mingw.org/download/installer
メンテ
Re: コンパイルできません ( No.7 )
名前:管理人 日時:2019/09/17 05:58

お待たせしました MinGW 8.2.0 用のライブラリファイルを追加した暫定最新版をアップしましたので、 よろしければダウンロードしてください m(_ _)m https://dxlib.xsrv.jp/temp/DxLibGCC_MinGWTest.zip // Windows版 MinGW 用 手元では以下のようなコマンドでコンパイルできました( 長いので行を分けていますが、実際は1行です ) g++.exe dx.cpp -o "dx.exe" -I"D:\DxLibGCC_MinGWTest\8_2_0" -L"D:\DxLibGCC_MinGWTest\8_2_0" -mwindows -lgcc -lDxLib -lDxUseCLib -lDxDrawFunc -ljpeg -lpng -lzlib -ltiff -ltheora_static -lvorbis_static -lvorbisfile_static -logg_static -lbulletdynamics -lbulletcollision -lbulletmath -lopusfile -lopus -lsilk_common -lcelt -I"D:\DxLibGCC_MinGWTest\8_2_0" と -L"D:\DxLibGCC_MinGWTest\8_2_0" に書かれている フォルダパス D:\DxLibGCC_MinGWTest\8_2_0 は、DxLibGCC_MinGWTest.zip の中にあるフォルダですので、 こちらは名無しさんがzipファイルを解凍した先の実際のフォルダのパスに書き換えてください あと、コンパイルが成功して出来上がった dx.exe の実行には MinGW 8.2.0 の bin フォルダの中にある libgcc_s_dw2-1.dll と libstdc++-6.dll が必要ですので、dx.exe があるフォルダに libgcc_s_dw2-1.dll と libstdc++-6.dll をコピーした状態で dx.exe を実行してください
メンテ
Re: コンパイルできません ( No.8 )
名前:名無し 日時:2019/09/17 19:17

ご指摘通り実行しましたら、コンパイルに成功しました。 DXライブラリのコンパイル方法を教えて下さいましたこと、 そしてDXライブラリを作成し、無償で提供下さった事に、心より 厚く御礼申し上げます。
メンテ

Page: 1 |

題名
名前
コメント
パスワード (記事メンテ時に使用)

   クッキー保存