Cześć, próbuję skompilować mój program w konsoli ale linker wywala mi błędy. Szukam już godzinami jak to naprawić i nic. Wszystkie moje pliki mieszczą się w jednym folderze. Tutaj kod:
main.cpp
#include <iostream>
#define _USE_MATH_DEFINES
#define _WIN32_WINNT 0x0500
#include <cmath>
#include <windows.h>
#include "GraphicsFramework.hpp"
using namespace std;
int main() {
HWND console = GetConsoleWindow();
HDC hdc = GetDC( console );
GraphicsFramework gf(hdc);
gf.SetPen(CreatePen(PS_SOLID, 5, RGB(255, 255, 255)));
int angle = 45;
int len = 50;
while(1) {
Vector startPos = {
50,
50
};
Vector endPos = {
startPos.x + (int)(sin(angle * M_PI / 180) * len),
startPos.y - (int)(cos(angle * M_PI / 180) * len)
};
gf.DrawLine(startPos, endPos);
}
ReleaseDC(console, hdc);
return 0;
}
GraphicsFramework.hpp
#ifndef GRAPHICS_FRAMEWORK_H
#define GRAPHICS_FRAMEWORK_H
#include <windows.h>
#define _WIN32_WINNT 0x0500
#include "Vector.hpp"
class GraphicsFramework {
HDC hdc;
HPEN pen;
public:
GraphicsFramework(HDC hdc);
~GraphicsFramework();
void SetPen(HPEN pen);
void DestroyPen();
void DrawLine(Vector startPos, Vector endPos);
};
#endif
GraphicsFramework.cpp
#include "GraphicsFramework.hpp"
GraphicsFramework::GraphicsFramework(HDC hdc) {
this->hdc = hdc;
this->pen = NULL;
}
GraphicsFramework::~GraphicsFramework() {
this->DestroyPen();
}
void GraphicsFramework::SetPen(HPEN pen) {
this->pen = pen;
}
void GraphicsFramework::DestroyPen() {
if(this->pen != NULL) DeleteObject(this->pen);
}
void GraphicsFramework::DrawLine(Vector startPos, Vector endPos) {
if(this->pen != NULL) {
MoveToEx(hdc, start.x, start.y, NULL);
LineTo(hdc, end.x, end.y);
}
}
a kompiluje:
g++ -c main.cpp -std=c++11
g++-o main main.o -lgdi32
Co robię źle?
@edit
Właśnie, zapomniałem podać listę błędów:
main.o:main.cpp:(.text+0x3c): undefined reference to `GraphicsFramework::GraphicsFramework(HDC__*)'
main.o:main.cpp:(.text+0x6d): undefined reference to `GraphicsFramework::SetPen(HPEN__*)'
main.o:main.cpp:(.text+0x133): undefined reference to `GraphicsFramework::DrawLine(Vector, Vector)'
main.o:main.cpp:(.text+0x147): undefined reference to `GraphicsFramework::~GraphicsFramework()'
collect2.exe: error: ld returned 1 exit status