plot icon indicating copy to clipboard operation
plot copied to clipboard

Build issue on Windows 10, Visual Studio 2022

Open FrankRay78 opened this issue 2 years ago • 7 comments

Build output when performing meson build

image

meson.build file with the offending line:

image

Any ideas what library 'm' is, and how I might be able to fix this error?

FrankRay78 avatar Feb 24 '23 14:02 FrankRay78

My mistake. Because this implementation of asciichart is written in C, and also because it uses meson for the build (which is cross-platform), I mistakenly believed the codebase would naturally be cross-platform as well. It turns out that it has been written for Linux and not Windows.

An example is the use of sigaction in animate.c, which is Linux only.

image

Compiling it on Windows results in the following build error:

image

The code would need to change with a conditional statement to include platform specific code, as per:

image

ref: https://medium.com/codex/running-open-source-software-on-windows-50dd1231cae9

The other problem I see is also the missing getopts C library/functions which also are not included on windows.

FrankRay78 avatar Feb 24 '23 20:02 FrankRay78

Correct, plot has not been tested on windows, and I don't have much knowledge of windows.

annacrombie avatar Feb 25 '23 00:02 annacrombie

I’m going to see if I can get it working on windows, I don’t think the code changes will be too extensive. If I do manage it, I’ll submit a PR for your consideration. I’d really like to be able to use plot in my cross-platform app, if possible. Nice work on the port btw.

FrankRay78 avatar Feb 25 '23 10:02 FrankRay78

Hello @annacrombie, I think I'm pretty close to having plot compile on both Linux and Windows now. I've persisted with this as largely a learning exercise, and it seems the Microsoft C compiler has a few known quirks when it comes to the meson build system. Can I please ask if you remember what Linux distros / compilers you used when developing plot? If you remember, I'd be interested in testing my changes on these to make sure I haven't introduced a regression somewhere.

FrankRay78 avatar Mar 24 '23 14:03 FrankRay78

I primarily develop on alpine linux with gcc. This is a pretty standard setup aside from the fact that alpine linux uses musl libc rather than glibc, which means that some non-standard extensions that some programs expect are not present.

One other thing since it seems you are intending on submitting a PR -- I prefer doing platform specific code without using #ifdefs when possible. One strategy I use a lot is this:

src = files(...)

if platform == 'windows'
  src += 'src/platform/windows/example.c'
else
  src += 'src/platform/posix/example.c'
endif
// include/platform/example.h

// Define some common api functions

void do_this(int);
// src/platform/windows/example.c

void
do_this(int)
{
  // windows-specific code
}
// src/platform/posix/example.c

void
do_this(int)
{
  // posix-specific code
}

annacrombie avatar Mar 25 '23 00:03 annacrombie