Closed ghost closed 2 years ago
Thanks. I modified Makefile and it should produce dll on windows now, could you verify?
Yes it works , thank you ! 👍
any chance i can bump this ticket and @pRot0ta1p for knowing if youre running emacs inside msys2 or natively using the windows builds of emacs form the main site.
I cannot seem to get the latest code to build/run correctly per the information here. I will create a new ticket if pRot0ta1p can let me know more detail on how they are using the setup (inside msys2 or not)
I use emacs inside msys2, but I think the promlem is with the Makefile, try apply this patch to Makefile and make sure the compiled .dll file is inside your load-path
, when asked about make PREFIX
input nothing so the compiled .dll file will be at the same directory as xeft.el.
diff --git a/Makefile b/Makefile
index d890d78..c627f5d 100644
--- a/Makefile
+++ b/Makefile
@@ -7,17 +7,17 @@ LDFLAGS=-L$(PREFIX)/lib
LDLIBS=-lxapian
# Dylib extensions.
-ifeq ($(OS),Windows_NT)
- SOEXT = dll
-endif
ifeq ($(shell uname),Darwin)
SOEXT = dylib
else
SOEXT = so
endif
+ifeq ($(OS),Windows_NT)
+ SOEXT = dll
+endif
xapian-lite.$(SOEXT): module/xapian-lite.cc
$(CXX) $< -o $@ -shared $(CXXFLAGS) $(LDFLAGS) $(LDLIBS)
clean:
- rm -f *.so *.o
+ rm -f *.so *.o *.dll
Hmmm, could you explain what does this change fix?
The goal is to produce a dll file on windows, the catch with msys2 is that it is also a unix environment, so
ifeq ($(shell uname),Darwin)
SOEXT = dylib
else
SOEXT = so
endif
will cause SOEXT = so in msys2, this will compile a xapian-lite.so without error but emacs in mingw64 is a native win64 application ( the official win distribution of emacs is compiled with mingw64 toolchain) and only recognize the native dll file, so to fix this, I moved the ifeq Windows_NT part behind so SOEXT will be dll.
@pRot0ta1p Thank you for the clarity. I had come up with a similar process but I'm getting an error on GPL compatibility.
@casouri The patch will fixup the build for msys2 so the dll is properly generated and found by emacs when loading xeft.
For both of y'all: I'm getting a gpl compatibility error (below) when loading xeft
inside msys2 or with the native windows build of emacs. I'm not sure if its because I didn't pull the 11.x g++ or not and I'm 100% not sure how to get msys2 to install concurrent versions of g++ so I can use an older version.
The error: Module is not GPL compatible: "/home/kemonine/.emacs.d/xeft/xapian-lite.dll
Full build process:
export PATH=/mingw64/bin/:${PATH} # setup g++ binary discovery for make
pacman -Syyu # upgrade to latest software
# some of the below packages may be unneeded
pacman -S --needed mingw-w64-x86_64-xapian-core git base-devel mingw-w64-x86_64-toolchain # install needed tools
mkdir ~/.emacs.d
cd ~/.emacs.d
git clone https://github.com/casouri/xeft.git /opt/xeft
cd xeft
g++ -o xapian-lite.dll -shared -fPIC -I/mingw64/include -L/mingw64/include -lxapian -lWs2_32 -municode # build xeft
# add activation for xeft to init.el
# launch emacs then xeft with "M-x xeft [RET]"
Emacs init.el
:
(add-to-list 'load-path "~/.emacs.d/xeft")
(require 'xeft)
; xeft-database
; xeft-directory
; xeft-default-extension
; xeft-recursive
I have also tried the below changes to the code to try to force-export the plugin_is_GPL_compatible
but I still receive the compatibility error.
nano -w module/xapian-lite.cc
Change: int plugin_is_GPL_compatible;
To: __declspec(dllexport) int plugin_is_GPL_compatible;
Change:
int
emacs_module_init(struct emacs_runtime *ert)
To:
int __declspec(dllexport)
emacs_module_init(struct emacs_runtime *ert)
I'm not sure if its because I didn't pull the 11.x g++ or not and I'm 100% not sure how to get msys2 to install concurrent versions of g++ so I can use an older version.
I don't think Msys2 can have concurrent version fo g++, its rolling release-ish kinda like archlinux. Though I don't think older version of gcc is the problem either, the build proccess work back then.
In terms of your build proccess, I don't quite understand why you need to export PATH variable and call g++ manually instead of just invoke make
. As long as you use the MinGW x64 environmet provided by msys2 (the blue icon one) there is no need to export PATH.
mysy2 mingw x64 (blue icon)
well that is a new way of launching mysy2. I'll try that and report back soon. Thank you for the tip.
With the patch at https://github.com/casouri/xeft/issues/11#issuecomment-1225074440 I can run the below procedure to compile and use xeft inside msys2. The compiled dll won't work outside msys2 and trying to compile statically had a compile error. Not sure if this is worth exploring, I wouldn't mind using native emacs on Windows with xeft ;)
If you install the mingw-w64-x86_64-emacs
package you can invoke runemacs
from within the mysy2 mingw x64 (blue icon)
flavor of msys2 with a native ui.
# run mysy2 to install needed software
pacman -Syyu # upgrade to latest software
# some of the below packages may be unneeded
pacman -S --needed mingw-w64-x86_64-xapian-core git base-devel mingw-w64-x86_64-toolchain # install needed tools
# run mysy2 mingw x64 (blue icon) for build -- THIS IS CRITICAL
mkdir ~/.emacs.d
cd ~/.emacs.d
git clone https://github.com/casouri/xeft.git
cd xeft
make
# add activation for xeft to init.el
# launch emacs then xeft with "M-x xeft [RET]"
You can also auto run the msys2 mingw emacs directly from a windows shortcut (these can be pinned to the taskbar) using the below.
C:\msys64\usr\bin\mintty.exe -w hide /bin/env MSYSTEM=MINGW64 /bin/bash -l -i -c /mingw64/bin/runemacs.exe
It'll launch using the ~/.emacs.d
directory in your msys2 home directory and once it launches it'll have full access to C:
. You can even use chemacs2 or similar with profiles stored in C:
that are auto loaded by chemacs2 profiles.
Ah, yes, duh. I fixed the makefile. IIUC that's the only thing that needs fixing right?
Yes, issue solved confirmed , thank you.
Ah, yes, duh. I fixed the makefile. IIUC that's the only thing that needs fixing right?
the instructions i added to the ticket may be good for windows userts ; or at least knowing to use the flavor of mingw noted above and the msys2 package thatll get you a native emacs ui ; these ended up being really important things for me to start using xeft.
Good stuff too btw ; this does what I wanted 💯
I'll draft a PR on the windows instruction stuff later, I run emacs master branch in msys2 on windows as daily.
With the patch at #11 (comment) I can run the below procedure to compile and use xeft inside msys2. ~The compiled dll won't work outside msys2 and trying to compile statically had a compile error. Not sure if this is worth exploring, I wouldn't mind using native emacs on Windows with xeft ;)~
If you install the
mingw-w64-x86_64-emacs
package you can invokerunemacs
from within themysy2 mingw x64 (blue icon)
flavor of msys2 with a native ui.# run mysy2 to install needed software pacman -Syyu # upgrade to latest software # some of the below packages may be unneeded pacman -S --needed mingw-w64-x86_64-xapian-core git base-devel mingw-w64-x86_64-toolchain # install needed tools # run mysy2 mingw x64 (blue icon) for build -- THIS IS CRITICAL mkdir ~/.emacs.d cd ~/.emacs.d git clone https://github.com/casouri/xeft.git cd xeft make # add activation for xeft to init.el # launch emacs then xeft with "M-x xeft [RET]"
Does this solution only suitable for emacs installed from mingw? I use the native emacs binary from GNU Emacs mirror and follow this instruction. However, although the xapian-lite.dll has been properly generated, when I execute M-x xeft
, there is the following error:
xeft--require-xapian-lite: Module could not be opened: "c:/Users/xxx/.emacs.d/elpa/xeft-3.2/xapian-lite.dll"
For ms-windows I tried using msys2 to compile the module , and it turns out not hard to do.
All I need todo is first install package mingw-w64-x86_64-xapian-core and change the
xapian-lite.so
toxapian-lite.dll
in Makefile.Can you change the Makefile so it produce a .dll file in ms-windows instead of a .so file? This and the msys2 dependency is all it need to make xeft work on windows.