tclswig

Compile TCL C extension for windows


I successfully compiled my C-extension to TCL using SWIG wrapper, it works in Linux, and compiled successfully under Windows in MSYS64 environment (no errors or warnings), but when I try to load this module in TCL script, I got this:

this library or a dependent library could not be found in library path

My Makefile is:

all: filter.dll
CC=gcc
BUILD=build

filter.dll: $(BUILD)/filter.o $(BUILD)/filter_wrap.o 
    mkdir -p $(BUILD)
    $(CC) -shared  $(BUILD)/filter.o $(BUILD)/filter_wrap.o $(BUILD)/../tclStubLib.o -o $(BUILD)/filter.dll

$(BUILD)/filter.o: filter.h filter.c
    mkdir -p $(BUILD)
    $(CC) -c filter.c -fPIC -Wall -O3 -g -march=native -o $(BUILD)/filter.o

$(BUILD)/filter_wrap.o: filter_wrap.c filter.h
    mkdir -p $(BUILD)
    $(CC) -c filter_wrap.c -I\C:\msys64\usr\lib\tcl8.6 -fPIC -O3 -DUSE_TCL_STUBS -o $(BUILD)/filter_wrap.o

clean: rm -rf $(BUILD) filter.dll

Obviously there is some missing libraries but I don't understand which ones. Thank you in advance!


Solution

  • The source of issue was the wrong MSYS environment, it should be MINGW64