Re: Jolt Physics Wrapper

new topic     » goto parent     » topic index » view thread      » older message » newer message

I was able to build the zig-gamedev library with GCC using the following Makefile. This works for me on Windows 10 and Ubuntu 20.04.

That being said, I haven't actually tested anything and Jolt seems to make heavy use of threads so it may not be stable for use with Euphoria at this time.

# Recursive wildcard function https://stackoverflow.com/a/18258352 
rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) 
 
SOURCES = $(filter-out %/JoltPhysicsC_Extensions.cpp,$(call rwildcard,libs,*.cpp)) 
OBJECTS = $(patsubst %.cpp,%.o,$(SOURCES)) 
 
ifeq ($(OS),Windows_NT) 
TARGET = joltc.dll 
else 
TARGET = libjoltc.so 
endif 
 
CXX = g++ 
CXXFLAGS = -std=c++17 -Ilibs -fPIC -O2 -s -DJPH_DEBUG_RENDERER 
LDFLAGS = -shared 
 
ifdef BITS32 
CXXFLAGS += -m32 
LDFLAGS += -m32 
else ifdef BITS64 
CXXFLAGS += -m64 
LDFLAGS += -m64 
endif 
 
all : $(TARGET) 
 
$(TARGET) : $(OBJECTS) 
	$(CXX) $(LDFLAGS) -o $@ $^ 
 
$(OBJECTS) : %.o : %.cpp ; 
	$(CXX) $(CXXFLAGS) -o $@ -c $< 
 
ifeq ($(OS),Windows_NT) 
clean : 
	@del /S $(subst /,\,$(OBJECTS) $(TARGET)) >NUL 2>&1 || (exit 0) 
else 
clean : 
	@rm -f $(OBJECTS) $(TARGET) 
endif 
 
.PHONY : all clean 

One thing I noticed building with GCC is that this line in JoltPhysicsC_Extensions.cpp causes a build error (and is in general a big no-no) so I've filtered it out. I don't think it's necessary.

// We do this because we add some low-level functions which need access to private fields. 
// Also, we static assert offsets of some private fields (see bottom of this file). 
#define private public 

You should be able to build on Windows using TDM-GCC with these steps:

> git clone ~https://github.com/michal-z/zig-gamedev 
> cd zig-gamedev\libs\zphysics 
(save Makefile to zphysics directory) 
> mingw32-make 

If you want to make separate 32-bit and 64-bit libraries, you can do something like this:

(build a separate 32-bit library) 
> mingw32-make BITS32=1 TARGET=joltc32.dll 
> mingw32-make clean 
 
(build a separate 64-bit library) 
> mingw32-make BITS64=1 TARGET=joltc64.dll 
> mingw32-make clean 

Don't forget to add -j4 to run build faster in parallel. (Use your number of CPU cores.)

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu