Compiling and linking jitter external with msys/Mingw on Windows

bens1984's icon

I'm trying to build a jitter external on windows and am stuck at linking to the jitter library. I know my dev environment is fine, the collect example builds fine. Now I am modifying the makefile to try and build a jitter object (one that I have working on Mac, it doesn't do anything platform dependent). It compiles fine and links to my 3rd party libraries, but fails on several screens full of lines like this:

undefined reference to '_imp___jit_sym_mop'

which it repeats for any jit.sym.xxx in the code (char, long, getinfo, getdata, etc.).

The link line of my makefile is:

LDFLAGS = -shared -L$(C74SUPPORT)/max-includes -L$(C74SUPPORT)/msp-includes -L$(C74SUPPORT)/jit-includes -ljitlib -lMaxAPI -lmaxcrt -static-libgcc -mno-cygwin

It has the jitlib.lib file (if I rename the file the linker returns a different error), but it seems to be missing a DLL or something. Has anyone succeeded in building a jitter object this way?

bens1984's icon

as a proof of the problem I'm using this makefile to test, building the jit.split example with mingw.

My only guess is that jitlib.lib is built for MSVC only, and not mingw compatible?

NAME = jit.split

SRC = $(NAME).c
SRC += max.$(NAME).c

C74SUPPORT = ../../c74support
SRC += $(C74SUPPORT)/max-includes/common/basic_c_strings.c
SRC += $(C74SUPPORT)/max-includes/common/dllmain_win.c

CC = mingw32-gcc-4.4.0

CFLAGS = -c -DWIN_VERSION -DWIN_EXT_VERSION -D_WINDOWS -D_USRDLL -D_WINDLL -I$(C74SUPPORT)/max-includes -I$(C74SUPPORT)/msp-includes -I$(C74SUPPORT)/jit-includes -mno-cygwin

LDFLAGS = -shared -L$(C74SUPPORT)/max-includes -L$(C74SUPPORT)/msp-includes -L$(C74SUPPORT)/jit-includes -lMaxAPI -lmaxcrt -ljitlib -fvisibility=default -static-libgcc -mno-cygwin --def $(NAME).def

# using -static-libgcc in the above line means that throwing exceptions across DLL boundaries won't work,
# but it also means that we don't depend on the libgcc dll

Debug:
    $(CC) $(CFLAGS) -g $(SRC)
    $(CC) -o $(NAME).mxe $(NAME).o max.$(NAME).o basic_c_strings.o dllmain_win.o $(LDFLAGS)

Release:
    $(CC) $(CFLAGS) $(SRC)
    $(CC) -o $(NAME).mxe $(NAME).o max.$(NAME).o basic_c_strings.o dllmain_win.o $(LDFLAGS)

clean:
    rm -f *.o
    rm -f $(NAME).mxe
Timothy Place's icon

I'm not 100% sure if this is your problem or not, but there is no _jit_sym_mop symbol. There is a __jit_sym_jit_mop symbol, which is what I assume you meant to use?