i use CodeBlocks with mingw compiler.
for use 'Graphics.h', i must add the 'libbgi.a' library.
but i continue with some compiler\linker error: "ld.exe||cannot find -lbgi|".
yes i add the linker options:
"-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32"
heres my testing code:
#include <iostream>
#include <graphics.h>
#include <conio.h>
using namespace std;
int main()
{
int gdriver = DETECT, gmode;
int x1 = 200, y1 = 200;
int x2 = 300, y2 = 300;
//clrscr();
initgraph(&gdriver, &gmode, NULL);
line(x1, y1, x2, y2);
getch();
closegraph();
return 0;
}
(i need find, too, the another 'conio.h' too)
maybe the problem it can the library compatibly :(
x86_64-w64-mingw32-g++.exe -Wall -g -std=gnu++98 -m32
Using -m32 or -m64 almost always result in errors because most MinGW GCC toolchains do not have both sets of libraries.
Tim S.
You can use this to build WinBGI:
CC = g++
OUT_FILE_NAME = winbgi.a
CFLAGS = -fPIC -O0 -g -Wall -c -fpermissive
INC =
OBJ_DIR = obj
OUT_DIR = lib
# Enumerating of every *.cpp as *.o and using that as dependency
$(OUT_FILE_NAME): $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(wildcard *.cpp))
ar -r -o $(OUT_DIR)/$@ $^
#Compiling every *.cpp to *.o
$(OBJ_DIR)/%.o: %.cpp dirmake
$(CC) -c $(INC) $(CFLAGS) -o $@ $<
dirmake:
@if not exist $(OUT_DIR) mkdir $(OUT_DIR)
@if not exist $(OBJ_DIR) mkdir $(OBJ_DIR)
clean:
@if exist $(OBJ_DIR) rmdir /S /Q $(OBJ_DIR)
@if exist $(OUT_DIR)\$(OUT_FILE_NAME) del $(OUT_DIR)\$(OUT_FILE_NAME)
@if exist Makefile.bak del Makefile.bak
rebuild: clean build
Create a file named Makefile in the WinBGI folder, paste the code above, open a console in the WinBGI folder and execute:
We also do not forget about .PHONY (https://stackoverflow.com/questions/2145590/what-is-the-purpose-of-phony-in-a-makefile)
.PHONY: clean dirmake rebuild