내가 최근에 일부 SDL 튜토리얼에 다이빙 한 작동하지 apply_surface하지만, 이것을 SDL 라이브러리 ++ DevC를 사용하여 특히 하나의 컴파일 어려움을 겪고 :이 특정 오류를 얻고있다 http://lazyfoo.net/SDL_tutorials/lesson05/index.phpSDL 선언되지 않은 파일 이름과
를` 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)
등 등
COMPILE LOG :
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++ 장면 전체에 대한 또 다른 멍청한 초보자이지만, 이것은 다른 무엇보다도 학습 실험에 더 가깝다. 나는 기본적인 레이캐스터를 만드는 것을 좋아하고, 허드를 보여 주려고 붙어있다.
나는 올바르게 이해하고있다 - 당신은 (어떤 알려지지 않은 이유로) "레슨"을 수정하고, 많은 실수를 저지르고, 왜 그것이 컴파일되지 않는지 궁금해 한단 말인가? 어쨌든 소스를 다운로드하고 (당신이 언급 한 기사의 맨 아래에있는 링크) 그것을 깨지 않는 것은 어떨까요? – keltar
어쨌든 소스 코드 버전이 실행되지 않습니다. 그러나 어느쪽으로 든, 나는 그 문제를 해결할 수 있었다. 나는 내가 너무 멀리 앞으로 뛰어 왔고 조금 더 뒤로 갈 예정이다라고 생각한다. 지금까지 사람들은 거대한 1008 페이지 책을 제안하는 사람과 함께 C++을 배우기위한 일관성없는 시작점을 전달하게했습니다. 그리고 포럼 회원은 "raycaster 코딩"으로 시작한다고 조언합니다. title-screen 영역이지만, 2 일의 경험으로이 종류의 코딩 수준이 나에게 너무 심오 해 보인다. 답변 해 주셔서 감사합니다. – Mantis