Giter Site home page Giter Site logo

Add MS-Windows support ? about xeft HOT 17 CLOSED

 avatar commented on August 22, 2024
Add MS-Windows support ?

from xeft.

Comments (17)

 avatar commented on August 22, 2024 1

Yes it works , thank you ! 👍

from xeft.

casouri avatar casouri commented on August 22, 2024

Thanks. I modified Makefile and it should produce dll on windows now, could you verify?

from xeft.

mcrosson avatar mcrosson commented on August 22, 2024

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)

from xeft.

 avatar commented on August 22, 2024

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

from xeft.

casouri avatar casouri commented on August 22, 2024

Hmmm, could you explain what does this change fix?

from xeft.

 avatar commented on August 22, 2024

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.

from xeft.

mcrosson avatar mcrosson commented on August 22, 2024

@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

from xeft.

mcrosson avatar mcrosson commented on August 22, 2024

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)

from xeft.

 avatar commented on August 22, 2024

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.

from xeft.

mcrosson avatar mcrosson commented on August 22, 2024

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.

from xeft.

mcrosson avatar mcrosson commented on August 22, 2024

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 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]"

from xeft.

mcrosson avatar mcrosson commented on August 22, 2024

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.

from xeft.

casouri avatar casouri commented on August 22, 2024

Ah, yes, duh. I fixed the makefile. IIUC that's the only thing that needs fixing right?

from xeft.

 avatar commented on August 22, 2024

Yes, issue solved confirmed , thank you.

from xeft.

mcrosson avatar mcrosson commented on August 22, 2024

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 💯

from xeft.

 avatar commented on August 22, 2024

I'll draft a PR on the windows instruction stuff later, I run emacs master branch in msys2 on windows as daily.

from xeft.

panmengguan avatar panmengguan commented on August 22, 2024

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 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]"

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"

from xeft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.