1. CGL Library

Hi all,

Anyone have an idea of how to make a makefile or cmake file to build this project, so it can be built into a DLL, so it can have a wrapper for Euphoria/Phix.

[https://github.com/Jaysmito101/cgl]

I've tried messing around with the directories and renaming things, but I can't get it to compile or build correctly.

new topic     » topic index » view message » categorize

2. Re: CGL Library

Looks like you need Glad and GLFW. Specifically, you need Glad for OpenGL 4.3 (or higher) with Core profile.

Extract glad.zip and glfw-3.4.bin.WIN64.zip (if building on Windows) into cgl/external. You should have these files:

  • external/glad/include/glad/glad.h
  • external/glad/include/KHR/khrplatform.h
  • external/glad/src/glad.c
  • external/glfw-3.4.bin.WIN64/include/GLFW/glfw3.h
  • external/glfw-3.4.bin.WIN64/include/GLFW/glfw3native.h
  • external/glfw-3.4.bin.WIN64/lib-mingw-w64/glfw3.dll

Here is your Makefile, which should work on Windows (with mingw32-make) and Debian, etc.

# Default commands/options 
CC = gcc 
LD = gcc 
CFLAGS = -O2 -s -fPIC -I$(GLAD)/include 
LDLIBS = -lm 
STRIP = strip 
 
# Common configuration 
GLAD = external/glad 
GLFW = external/glfw-3.4.bin.WIN64 
DEPENDS = $(GLAD)/include/glad/glad.h 
SOURCES = $(wildcard *.c) $(wildcard $(GLAD)/src/*.c) 
OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) 
 
# Detect platform 
ifeq ($(OS),Windows_NT) 
# Windows configuration 
  LIBGLFW = glfw3.dll 
  TARGET = cgl.dll 
  CFLAGS += -I$(GLFW)/include 
  DEPENDS += $(GLFW)/include/GLFW/glfw3.h 
  LDLIBS += $(LIBGLFW) 
else 
# Non-Windows configuration 
  TARGET = libcgl.so 
  LDLIBS += -lglfw 
endif 
 
all: $(TARGET) 
 
# Link shared library 
$(TARGET): $(OBJECTS) 
	$(LD) -shared -o $@ $^ $(LDLIBS) && $(STRIP) $@ 
 
# Build source files 
$(OBJECTS): %.o: %.c | $(DEPENDS) 
	$(CC) $(CFLAGS) -o $@ -c $< 
 
# Throw error if missing these dependencies 
$(GLAD)/include/glad/glad.h:; $(error GLAD not found: $@) 
$(GLFW)/include/GLFW/glfw3.h:; $(error GLFW not found: $@) 
 
ifeq ($(OS),Windows_NT) 
# Windows-specific rules 
 
# Add GLFW library as dependency for target library 
$(TARGET): | $(LIBGLFW) 
 
# Copy GLFW library to the local directory 
$(LIBGLFW): %.dll: $(GLFW)/lib-mingw-w64/%.dll 
	@copy /Y $(subst /,\,$<) $(subst /,\,$@) >NUL 
 
# Windows uses 'del' command not 'rm' 
clean: 
	@del /Q $(subst /,\,$(TARGET) $(LIBGLFW) $(OBJECTS)) 2>NUL 
 
else 
 
# Clean files using 'rm' command 
clean: 
	@$(RM) $(TARGET) $(OBJECTS) 
 
endif 
 
.PHONY: all clean 

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: CGL Library

Thanks,

however it says makefile: 36: target 'external/glad' doesn't match target pattern,

I downloaded the glad file with OpenGL 4.3 and core profile

EDIT: Got it to work with some help from chatGPT.

Thanks again Greg, you have been a great help.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu