Compiling and Porting graphics.h using em++ and running it in the browser.

Dears User,
I am new here and not sure whether I am in the right place for this question.
I wanted to port my graphics.h program to the web.Never used emcascripten
to port anything to the web,I created a makefile.Here is the source code.
How can I create a javascript file from this main.cpp using graphics.h ,and ecmascripten.h
in a c or cpp file.

Natively graphics .h works only with .cpp extension.
Here is my makefile

LOPTIONS=-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32

emrun --no_browser --port 8080 .

$(CC) -o $(TARGET) $(SRC)/main.cpp $(INCLUDE) $(LIB) $(LOPTIONS)

rm -f $(TARGET)

.PHONY: clean

#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>

int main()
int gd = DETECT, gm;
initgraph(&gd, &gm, NULL);

circle(50, 50, 30);

return 0;

Probably not - this form is more for discussing the JavaScript standard (it's future, details about what the standard text means, etc).

Unless there's some tooling I'm not aware of, you're probably not going to find a one-to-one translation between your C++ code and JavaScript. Some topics you could look into, that might be helpful would be canvas, for low-level drawing of shapes and such, and setTimeout, for timeing needs. Perhaps a site like would work better for addressing any specific issues you have as you port the code. But, first, you may have to walk through a few tutorials.

1 Like