Jump to content

  • Log In with Google      Sign In   
  • Create Account

James Miller

Member Since 14 Mar 2009
Offline Last Active May 20 2015 10:15 AM

Topics I've Started

SDL undeclared filename and apply_surface not working

31 March 2014 - 10:56 PM

I've recently dived into some SDL tutorials, but am having difficulty compiling this one in particular using DevC++ with the SDL library: http://lazyfoo.net/SDL_tutorials/lesson05/index.php

I am getting this particular error: `filename' undeclared (first use this function) and it points to the filename.c_str() ); area of the code, as well as a few others listed in the compile log. I'd like to also investigate the "apply_surface" not being recognized as well. I have included the following headers:

#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;

Linker options include suggestions based on other threads I've found with the same issue, it appears I'm not alone but I haven't quite found the solution that applies to my code yet:










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)</pre>

etc etc


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

Any suggestions or advice would be greatly appreciated. I'm yet another newbie to the whole C++ scene, but this is more of a learning experiment than anything else.


How long would it take to...

25 January 2013 - 02:51 PM

I know there's been threads about this strewn all over the net, with the question "How long does it take to learn C++", with the answer pretty much being "You never stop learning", however, I have a few questions I'll put out here as specifically as I can, as I'm curious.

1: How long would it take the average person learn C++ to the point where they can confidently and reasonably use all C++ commands/functions etc (even if they're not quite at the John Carmack skill level). I'm just talking, to the point where they could create anything they're asked, even if it's primitive.


2: Continuing on from Q1, how long would it take our average Joe to go from making their first Hello World, to a primitive, but functional 3d engine, something on par with say, the original QUAKE or Half-Life 1 engine in terms of functionality, graphics etc (nothing next gen, just simple but functional).