0

I'm currently using this tutorial: https://www.youtube.com/watch?v=44tO977slsU&list=PLhfAbcv9cehhkG7ZQK0nfIGJC_C-wSLrx&index=3

But I've been getting this error on the first line that I don't know how to address as a beginner.
It says it's unresolved externals

I've been trying to look at some of the windows config advice, but I don't know how to apply it to this tutorial.

here's the code:

#include "Header.hpp"

Game::Game(){}
Game::~Game(){}

void Game::init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen)
{
    int flags = 0;
    if (fullscreen) { flags = SDL_WINDOW_FULLSCREEN; }

    if (SDL_Init(SDL_INIT_EVERYTHING) == 0) {
        std::cout << "Subsystems initialized" << std::endl;
        window = SDL_CreateWindow(title, xpos, ypos, width, height, flags);
        if (window) { std::cout << "Windows created" << std::endl; }

        renderer = SDL_CreateRenderer(window, -1, 0);
        if (renderer) {
            SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);

            std::cout << "renderer created" << std::endl;
        }

         isRunning == true; } else { isRunning == false; }
    }

void  Game::handleEvents() {
    SDL_Event event;
    SDL_PollEvent(&event);
    switch (event.type) {
    case SDL_QUIT:
        isRunning = false;
        break;

    default:
        break;
    }
}

void Game::update() { count++; std::cout << count << std::endl; }

void Game::render() {
    SDL_RenderClear(renderer);
    SDL_RenderPresent(renderer);

}

void Game::clean() {
    SDL_DestroyWindow(window);
    SDL_DestroyRenderer(renderer);
    SDL_Quit();
    std::cout << "Game cleaned" << std::endl;

}

this is is the header file, if it'll help:

#ifndef Header_hpp
#define Header_hpp


#include <iostream>

#include "SDL.h"


class Game {
public:
    Game();
    ~Game();
    void init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen);
    void handleEvents();
    void update();
    void render();
    void clean();

    bool running(){ return isRunning; }
private:
    int count = 0;
    bool isRunning;

    SDL_Window  *window;
    SDL_Renderer *renderer;


};

#endif / * Header_hpp */

I'm genuinely clueless on what could be causing this so I guess I'll include the main.cpp as well if something can be found there:

#include "Header.hpp"

Game* game = nullptr;



int main(int argc, const char * argv[]) {

    game = new Game();
    game->init("Birchengine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, false);

    while (game->running()) {
        game->handleEvents();
        game->update();
        game->render();

    }
    game->clean();

    return 0;
}

What could be the cause of this error, and how do I prevent it in the future?

  • In the video's description is a link to another video explaining the required setup. You probably haven't followed it through. – walnut Oct 05 '19 at 21:08
  • ***What could be the cause of this error*** you likely missed adding libraries to your linker settings. – drescherjm Oct 05 '19 at 21:10
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – drescherjm Oct 06 '19 at 01:11
  • @drescherjm I tried to setup the sdl2 libraries, but still didn't strike much luck. apparently it now say's there's no errors, but it doesn't run and still displays errors in the error list. What do you think I should do? https://imgur.com/a/7iDVRvc – Tomato3 Oct 06 '19 at 14:39
  • @uneven_mark I tried to setup the sdl2 libraries, but still didn't strike much luck. apparently it now say's there's no errors, but it doesn't run and still displays errors in the error list. What do you think I should do? imgur.com/a/7iDVRvc – Tomato3 Oct 06 '19 at 14:40
  • @Tomato3 I do not have enough experience with Visual Studio to verify your setup. Have you actually rebuild the project after making the configuration changes? – walnut Oct 06 '19 at 16:28
  • Related to the new error: [https://wiki.libsdl.org/FAQWindows#I_get_.22Undefined_reference_to_.27SDL_main.27.22_...](https://wiki.libsdl.org/FAQWindows#I_get_.22Undefined_reference_to_.27SDL_main.27.22_...) – drescherjm Oct 06 '19 at 21:19

0 Answers0