c++ - Able to include cpp.... but not header? Whats going on? -


I think I'm misunderstanding a big concept in c ++ (can not buy any books). I can not find anything else on this, sorry that the hidden things in a vague part of the Internet have been changed. I was trying to work with SDL, when I found a new interesting way of creating an application cover for SDL. But when it is divided into separate CPP and header files ... the stuff happens.

C ++:

  // // AppSdl.cpp // sdlgaim // // Created on 28/4/14 by Home // Copyright ( C) 2014 Hyperm All Rights Reserved. // # "AppSdl.h" app_sdl :: app_sdl (): _running (wrong) {} apisl :: ~ apisl () {include (deleted); } Int app_sedl :: Init (int width, intensity height, const char * title) {// Start SDL library if (SDL_INIT (SDL_IIDIDADADLLINIITMER) & lt; 0} {FPrintf (CDRR, "SDL_ent () failed:% s \ N ", SDL_gatorerror ()); Return APP_FAILED; } Win = SDL_CreateWindow (Title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN); Renderer = SDL_CreateRenderer (win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); // Success. APP_OK; } Zero app_sdl :: deleted () {if (win) {SDL_DestroyWindow (win); SDL_DestroyRenderer (Renderer); SDL_Quit (); }} Int app_sdl :: runs (int width, intensity height, cons four * title) {// start application int state = init (width, height, title); If (state! = APP_OK) return status; // SDL Event Enter in the loop SDL_Event ev; _running = true; While (SDL_WaitEvent (and amp)) {onEvent (and amp;); to present(); If (_running == wrong) {break; }     }      // Success. APP_OK; } Zero APIISL :: Onewind (SDL_Event * Eve) {Switch (AV-> Type) {Case SDL_Quit: _running = false; break; Case SDL_KEYDOWN: {Switch (ev-> key.keysym.sym) {case SDLK_ESCAPE: _running = false; break; }}}} Void app_sdl :: render () {SDL_Rect r; Int w, h; SDL_GetWindowSize (Win, & amp; H, & amp; nbsp;); RW = 200; RH = 200; Rx = W / 2- (RW / 2); R.Y. = H / 2- (RH / 2); // SDL_SetRenderDrawColor (renderer, 0x00, 0x00, 0, 0xff); SDL_RenderClear (renderer); SDL_SetRenderDrawColor (renderer, 0xff, 0xff, 0, 0xff); SDL_RenderFillRect (Renderer, & amp; r); SDL_RenderPresent (renderer); }  

Header:

  // // AppSdl.h // sdlgaim // // Created by Home 28/4/14 // Copyright ( C) 2014 Hyperm All Rights Reserved. // #ifndef __sdlgaim__AppSdl__ #define __sdlgaim__AppSdl__ #include & lt; Iostream & gt; # Include & lt; SDL2 / SDL.h & gt; Struct app_sdl {app_sdl (); ~ App_sdl (); // Application status (bus facility instead of 0, 1, ...) ANIM APJUETE {APPOO = 0, APPFILD = 1}; // Destruct the application called by the Destructor, do not call manually. Zero destruction (); Init Init (Int width, intensity height, Const char * title); // Run the app, which is called by your code, Int Run (Int width, intensity height, Const char * title); // Event to process the SDL program called zero (SDL_Event * ev); To render the contents in buffer is called // zero (); // The application is in the event loop; Bull_ring; SDL_Window * win; SDL_Renderer * Renderer; }; #endif / * defined (__ sdlgaim__AppSdl__) * /  

Now, you can see, when I include the CPP file and do this: app_sdl app; Return app.run (640, 480, APPTITLE); In my main integer, everything is going fine. But when I include the HEADER file instead, this happens:

  Undefined symbols for architecture x86_64: "ap_sdl :: run (int, int, four-constant *)", from Referenced: The main reference to _ .o is referred to as "app_sdl :: app_sdl ()",: "_main" in main.o is referred to as "app_sdl :: ~ app_sdl ()",: _main in main.o ld : Symbol not found for architecture (s) x86_64 clag: error: failed with linker command failure code 1 (Use -V to view invitation Anyone knows what's going on here? And what should I do? 

As you know, the CPP file is also not included, it is the right thing to do so.

When you add the source file in the console command If you forget for the error then you will.

I have never used xcode, but

  • target-> build steps-> compile source

  • Comments

    Popular posts from this blog

    import - Python ImportError: No module named wmi -

    Editing Python Class in Shell and SQLAlchemy -

    c# - MySQL Parameterized Select Query joining tables issue -