chafa icon indicating copy to clipboard operation
chafa copied to clipboard

windows port

Open crmabs opened this issue 2 years ago • 12 comments

Hi, Before I'm getting lost in the maze I'd like to ask this: Is it possible to compile it for windows? I can imagine that the question sounds rather stupid , sorry about that. I'm just hoping it's not. I tried compiling in different environments (cygwin, mingw, etc) but so far I wasn't able to squeeze out an exe. It all went well, hunted down packages then re-run your scripts like a good boy,... close-yet-so-far So - Could you pls point me to the right direction? Is it possible at all or flat out nonsense? Thanks: Andras

ps: Alright, now I noticed that the INSTALL contains info about compiling to different platforms. So the question above is answered. Instead I got a cheeky one: I'm looking for one proper way to do it, possibly with/close to the simplicity of the linux compile. My head is spinning from the so many options and possibilities regarding cross compiling.

crmabs avatar Apr 26 '22 08:04 crmabs

It's a good question.

It's meant to be "not too hard" to get it working (I kept portability in mind while writing it -- for instance, it uses GLib, which provides Windows compatibility wrappers for threading and I/O). But AFAIK no one has so far actually built it successfully on Windows. That includes me, because I haven't had the time to try it yet :)

In past projects, I've used MXE and (later) some awful scripts of my own to do cross-compilation, but I don't know if that's a good option anymore.

@oakes mentioned using Scoop to install the toolchain in #72. It's a similar issue to this one, but with a twist: He's using an embedded GLib, which makes the build more self-contained.

How far are you getting? Are you getting past configure, running make?

hpjansson avatar Apr 26 '22 13:04 hpjansson

Hi, Comparing to this the linux build is nothing. :))) I know, packages available widely. But to see the process I tried to build on linux first. And it's always very interesting how others solve stuff...

So, autogen.sh ends up successfully: --- Success! You can now run tools/chafa/chafa, or install everything --- using make install or sudo make install.

Make fails ... make output https://drive.google.com/file/d/1u7m87MDS9jY_U0q0ZFlqk4La9lfw8_-i/view?usp=sharing

autogen output https://drive.google.com/file/d/1DBYg26j6HhI_1EUuDMHjopz_aXpdkFgc/view?usp=sharing

Mingw64 was used for the adventure.

This is getting interesting, many thanks for your time!!!

crmabs avatar Apr 27 '22 20:04 crmabs

Maybe we can setup a CI for windows build and see how far it goes

cdluminate avatar Apr 27 '22 23:04 cdluminate

according to the buildlog, the build failed because the linker cannot find _spawnv

bin/sh ../libtool  --tag=CC   --mode=link gcc -Wall -Wextra -Wmissing-prototypes -ffast-math  -DLODEPNG_NO_COMPILE_ENCODER -DLODEPNG_NO_COMPILE_DISK -DLODEPNG_NO_COMPILE_CPP -DLODEPNG_NO_COMPILE_CRC -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -mms-bitfields -I/mingw64/include  -g -O2 -fvisibility=hidden   -o term-info-test.exe term-info-test.o -L/mingw64/lib -lglib-2.0 -lintl  ../chafa/libchafa.la 
libtool: link: gcc -Wall -Wextra -Wmissing-prototypes -ffast-math -DLODEPNG_NO_COMPILE_ENCODER -DLODEPNG_NO_COMPILE_DISK -DLODEPNG_NO_COMPILE_CPP -DLODEPNG_NO_COMPILE_CRC -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -mms-bitfields -I/mingw64/include -g -O2 -fvisibility=hidden -o .libs/term-info-test.exe term-info-test.o  -L/mingw64/lib ../chafa/.libs/libchafa.a -lglib-2.0 -lintl
./.libs/lt-term-info-test.c: In function 'main':
./.libs/lt-term-info-test.c:319:16: warning: implicit declaration of function '_spawnv'; did you mean 'spawnv'? [-Wimplicit-function-declaration]
  319 |   rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
      |                ^~~~~~~
      |                spawnv
/usr/lib/gcc/x86_64-pc-msys/11.2.0/../../../../x86_64-pc-msys/bin/ld: /tmp/ccyz6v8N.o: in function `main':
/a/repo/chafa/tests/./.libs/lt-term-info-test.c:319: undefined reference to `_spawnv'
collect2: error: ld returned 1 exit status
strip: './term-info-test.exe': No such file
../libtool: line 11128: ./term-info-test.exe: No such file or directory
make[2]: Leaving directory '/a/repo/chafa/tests'
Making all in tools

cdluminate avatar Apr 27 '22 23:04 cdluminate

Awesome work. It's not looking too bad, you're both probably running into a Libtool issue, or something similar to it. I've added a few commits to master that may help to work around it.

Let me know if the error goes away or not.

If it doesn't, ./autogen.sh --disable-shared could also help. You won't be getting the shared library then, but I guess it's of limited use on Windows anyway unless you're building another app on top of Chafa with conflicting license terms or something.

hpjansson avatar Apr 28 '22 16:04 hpjansson

I expect there will be a few more issues to solve once it builds to make it pass the "actually does something" test :-)

hpjansson avatar Apr 28 '22 16:04 hpjansson

@cdluminate @crmabs Did you get a chance to rerun the build with current master? I'm hoping commits https://github.com/hpjansson/chafa/commit/f7e600b1f96798f6189daec4a3a1761963f6c15d and https://github.com/hpjansson/chafa/commit/395e9f63174734088149123de2600c2cb429b933 will improve things.

hpjansson avatar May 09 '22 15:05 hpjansson

@hpjansson sorry not yet. I'm back soon and trust me I'll report the progress.

crmabs avatar May 28 '22 13:05 crmabs

chafa_dos

Well well well.

hpjansson avatar Jun 28 '22 01:06 hpjansson

I'm still curious to hear if it builds successfully in the various Windows-oriented environments. It'd be nice to get it into repositories/package managers too (I've been using MXE and am submitting a PR there).

hpjansson avatar Jul 01 '22 00:07 hpjansson

For me I still get the same SIGSEGV I mentioned in #72 but it's great that it builds with mingw now.

oakes avatar Jul 01 '22 05:07 oakes

@oakes Thanks for testing it again. I might take a crack at Scoop this weekend, see if I can make sense of it.

hpjansson avatar Jul 01 '22 18:07 hpjansson

We eventually solved this in #72. Chafa is now available in MXE and I know about a couple of people who've built it successfully there. I've also got static Windows binaries on the download page.

I think that's all for this issue. Please reopen if there's anything else!

hpjansson avatar Jan 31 '23 02:01 hpjansson