Halfbax
Erfahrenes Mitglied
Ich habe 5 Fehler und 1 Warnung, die meinerseits keinen Aufschluss geben, wo der Fehler liegt. Ich bitte euch mir zu helfen.
Fehler:
main.cpp
SDL2_class.cpp
Fehler:
Code:
Fehler 1 error LNK2005: "public: void __thiscall sdl::c_window(int,int,int,int)" (?c_window@sdl@@QAEXHHHH@Z) ist bereits in main.obj definiert. C:\Users\****\documents\visual studio 2013\Projects\Prototype\Prototype\SDL2_class.obj Prototype
Fehler 2 error LNK2005: "public: void __thiscall sdl::destroy(void)" (?destroy@sdl@@QAEXXZ) ist bereits in main.obj definiert. C:\Users\****\documents\visual studio 2013\Projects\Prototype\Prototype\SDL2_class.obj Prototype
Fehler 3 error LNK2005: "public: bool __thiscall sdl::init(void)" (?init@sdl@@QAE_NXZ) ist bereits in main.obj definiert. C:\Users\****\documents\visual studio 2013\Projects\Prototype\Prototype\SDL2_class.obj Prototype
Fehler 4 error LNK2005: "public: void __thiscall sdl::set_image(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,int,int)" (?set_image@sdl@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HHHH@Z) ist bereits in main.obj definiert. C:\Users\****\documents\visual studio 2013\Projects\Prototype\Prototype\SDL2_class.obj Prototype
Warnung 5 warning LNK4098: Standardbibliothek "msvcrt.lib" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden. C:\Users\****\documents\visual studio 2013\Projects\Prototype\Prototype\MSVCRTD.lib(cinitexe.obj) Prototype
Fehler 6 error LNK1169: Mindestens ein mehrfach definiertes Symbol gefunden. C:\Users\****\documents\visual studio 2013\Projects\Prototype\Debug\Prototype.exe 1 1 Prototype
main.cpp
Code:
#include "SDL2_class.cpp"
int main(int argc, char* argv[])
{
sdl w;
if (w.init() == false)
{
return 0;
}
w.set_image("test1.bmp", NULL, NULL, 20, 80);
w.destroy();
return 0;
}
SDL2_class.cpp
Code:
#include <SDL.h>
#include <stdio.h>
#include <iostream>
class sdl
{
public:
bool init();
void c_window(int width_W, int height_W, int xPos_W, int yPos_W);
void destroy();
void set_image(std::string path, int src_x, int src_y, int dst_x, int dst_y);
private:
SDL_Window* window = NULL;
SDL_Surface* surface = NULL;
};
bool sdl::init()
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("Fehler bei der Initialisierung");
return false && 0;
}
surface = SDL_GetWindowSurface(window);
SDL_UpdateWindowSurface(window);
return true;
}
void sdl::c_window(int width_W, int height_W, int xPos_W, int yPos_W)
{
window = SDL_CreateWindow("Prototype Test", width_W, height_W, xPos_W, yPos_W, SDL_WINDOW_SHOWN);
}
void sdl::destroy()
{
SDL_DestroyWindow(window);
SDL_Quit();
}
void sdl::set_image(std::string path, int src_x, int src_y, int dst_x, int dst_y)
{
SDL_Surface* img = NULL;
SDL_Rect a, b;
a.x = src_x, a.y = src_y;
b.x = dst_x, b.y = dst_y;
img = SDL_LoadBMP(path.c_str());
if (img == false)
{
printf("Fehler beim laden von ", path);
}
SDL_BlitSurface(img, NULL, surface, &b);
SDL_UpdateWindowSurface(window);
SDL_Delay(5000);
}