Open gAndy50 opened 3 months ago
https://github.com/JettMonstersGoBoom/tigr I have an example "examples/hellodll" for building TIGR as a DLL. just changes to the tigr.h file. and some compile flags. I haven't tested on OSX or Linux though. it "should" work.
Thanks. I tried to build it, but I keep getting __mingw_winmain undefined reference error. I'm trying to build it under Windows.
that's odd. I'm using x86_64-w64-mingw32 version 13.2.0. to double check I didn't miss anything, I completely removed the archive from my machine and pulled that version, it compiled with makefile there ?
When I do this: gcc -c tigr.c - It compiles fine (It works fine using mingw32-make as well) But when I do this: gcc -shared -o tigr.dll tigr.o - it comes up with the __ming_winmain errors.
-DTIGR_BUILDSHARED is needed for the DLL, -DTIGR_SHARED is needed for the executable that references it. please see the makefile provided.
Alright, I think I almost got it. I did mingw32-make, it outputs this: gcc ../../tigr.c -DTIGR_BUILDSHARED -shared -I../.. -Os -s -DTIGR_SHARED -s -lopengl32 -lgdi32 -o tigr.dll But these errors appear: undefined reference to `__mingw_winmain_hInstance
that error when building the DLL ? I'm not really sure what's going on there. did you clean any .o or .dll files first ?
I can't figure out why it isn't building either, I'll try a few more things.
I just installed w64devkit and git on a clean machine and still don't have any issues ? I don't see how mingw would be different for something this trivial.
I figured it out. The error was coming from the WinMain function. To build a DLL, you don't need a Winmain function.
add to line 2699 in tigr.c #ifndef TIGR_BUILDSHARED add to line 2724 in tigr. c #endif
--begin of makefile CFLAGS += -Os -s LDFLAGS += -shared ifeq ($(OS),Windows_NT) CFLAGS += -DTIGR_SHARED LDLIBS += -lopengl32 -lgdi32 LIBEXT := .dll else CFLAGS += -fPIC LIBPRE := lib UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) LDLIBS += -framework OpenGL -framework Cocoa LIBEXT := .dylib else LDLIBS += -lGLU -lGL -lX11 LIBEXT := .so endif endif
$(LIBPRE)tigr$(LIBEXT): tigr.c gcc $(CFLAGS) -DTIGR_BUILDSHARED $(LDFLAGS) -o $@ $< $(LDLIBS) -- end of make file
--build DLL or shared library tigr.dll: tigr.c gcc -Os -s -DTIGR_SHARED -DTIGR_BUILDSHARED -shared -o $@ $< -lopengl32 -lgdi32
Thanks to https://github.com/ghaberek for his help with this.
I agree you shouldn't need it, but it also shouldn't cause an issue with building and linking a dll. At least you got it resolved.
Yes, it does seem odd, but I got it to work and have a DLL now. Thanks for your help as well.
added the change to my repo. just incase someone else runs into this.
Sounds good. I've made a wrapper for the TIGR library for OpenEuphoria. https://github.com/gAndy50/EuTigr
Is it possible to build TIGR as a DLL or shared library?