小编use*_*079的帖子

c ++未定义的静态变量引用

我不知道为什么这段代码不起作用.所有的源文件都编译好了,但是当我尝试链接它们时,编译器会因为未定义的引用错误而对我大喊大叫.这是代码:

main.cpp中:

#include "SDL/SDL.h"
#include "Initilize.cpp"

int main(int argc, char* args[]) 
{
    //Keeps the program looping
    bool quit = false;
    SDL_Event exit;
    //Initilizes, checks for errors
    if(Initilize::Start() == -1) 
    {
        SDL_Quit();
    }
    //main program loop
    while(quit == false) 
    {
        //checks for events
        while(SDL_PollEvent(&exit)) 
        {
            //checks for type of event;
            switch(exit.type) 
            {
                case SDL_QUIT:
                quit = true;
                break;
            }
        }
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

Initilize.h:

#ifndef INITILIZE_H
#define INITILIZE_H
#include "SDL/SDL.h"

/* Declares surface screen, its attributes, and Start(); */
class …
Run Code Online (Sandbox Code Playgroud)

c++ linker sdl reference undefined

8
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

linker ×1

reference ×1

sdl ×1

undefined ×1