私は最近いくつかの SDL チュートリアルに飛び込みましたが、特に SDL ライブラリで DevC++ を使用してこれをコンパイルするのに苦労しています: http://lazyfoo.net/SDL_tutorials/lesson05/index.php
この特定のエラーが発生しています: `filename' が宣言されていません (最初にこの関数を使用します)。それは filename.c_str() を指しています)。コードの領域、およびコンパイルログにリストされている他のいくつかの領域。「apply_surface」が認識されていないことも調査したいと思います。次のヘッダーを含めました。
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include "SDL/SDL.h"
#include "quickcg.h"
#include "SDL/SDL_mixer.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
using namespace QuickCG;
リンカー オプションには、同じ問題で見つけた他のスレッドに基づく提案が含まれています。
-lmingw32
-mwindows
-lSDLmain
-lSDL
-lSDL_mixer
-lSDL_image
-lSDL_ttf
-lstdc++
コードスニペット:
int main(int /*argc*/, char */*argv*/[])
{
{
SDL_Surface* title = NULL;
SDL_Surface* hud = NULL;
SDL_Surface* screen = NULL;
SDL_Surface* loadedImage = NULL;
SDL_Surface* optimizedImage = NULL;
loadedImage = IMG_Load( filename.c_str() );
if (loadedImage != NULL)
{
optimizedImage = SDL_DisplayFormat( loadedImage );
SDL_FreeSurface( loadedImage );
if( optimizedImage != NULL)
などなど
コンパイルログ:
Compiler: Default compiler
Building Makefile: "D:\Coding\Raycaster\Makefile.win"
Executing make...
make.exe -f "D:\Coding\Raycaster\Makefile.win" all
g++.exe -c raycaster.cpp -o raycaster.o -I"D:/Coding/Dev-Cpp/lib/gcc/mingw32/3.4.2
/include" -I"D:/Coding/Dev-Cpp/include/c++/3.4.2/backward" -I"D:/Coding/Dev-Cpp
/include/c++/3.4.2/mingw32" -I"D:/Coding/Dev-Cpp/include/c++/3.4.2" -I"D:/Coding
/Dev-Cpp/include" -fexpensive-optimizations -O3 -mwindows
raycaster.cpp: In function `int SDL_main(int, char**)':
raycaster.cpp:117: error: `filename' undeclared (first use this function)
raycaster.cpp:117: error: (Each undeclared identifier is reported only once for
each function it appears in.)
raycaster.cpp:130: error: invalid conversion from `SDL_Surface*' to `int'
raycaster.cpp:133: error: `apply_surface' undeclared (first use this function)
raycaster.cpp:134: error: `hud' undeclared (first use this function)
make.exe: *** [raycaster.o] Error 1
Execution terminated
提案やアドバイスをいただければ幸いです。私は、C++ シーン全体の初心者でもありますが、これは何よりも学習実験です。基本的な raycaster を構築したいのですが、hud を表示するのに苦労しています。