Closed v0dro closed 5 years ago
Which GR run-time are you using? Did you build GR from source?
No. I downloaded the Debian binaries from here: https://gr-framework.org/c.html
On a side note: what sort of information do you expect me to post with an error?
On a side note: what sort of information do you expect me to post with an error?
In order to reproduce the problem, the following pieces of information are helpful:
Till now we could not reproduce your particular issue. Could you post a list of your installed Debian packages? You get a list of manually installed packages by running:
apt-mark show manual
Maybe we can setup an environment that leads to a break of the PNG output.
Could you try to run a minimal C example?
main.c
:
#include <gr.h>
int main(void) {
double x[] = {0.1, 0.9};
gr_clearws();
gr_polyline(sizeof(x) / sizeof(x[0]), x, x);
gr_updatews();
return 0;
}
Makefile
:
GRDIR = /usr/local/gr
INCLUDES = -I$(GRDIR)/include
CFLAGS = -Wall -g $(INCLUDES)
LIBS = -L$(GRDIR)/lib -lGR
LDFLAGS = $(LIBS) -Wl,-rpath,$(GRDIR)/lib
main: main.o
$(CC) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -c $(CFLAGS) $<
clean:
rm -f main *.o
.PRECIOUS: %.o
.PHONY: clean
You can run
make GRDIR=<path-to-your-gr-directory>
export GKS_WSTYPE=png
export GKS_FONTPATH=<path-to-your-gr-directory>
./main
and should get a gks.png
file.
Sure. Let me try it out and get back to you.
Ah. The example that you have elaborated works for me. However, when I use beginprint
it fails to ouput anything.
Here's the C example I used:
#include <gr.h>
int main(void) {
double x[] = {0.1, 0.9};
gr_beginprint("hello.png");
gr_polyline(sizeof(x) / sizeof(x[0]), x, x);
gr_endprint();
return 0;
}
Might there be some issue with beginprint?
The way the GKS workspaces work is very confusing. Is there any documentation that points to the exact behavior? How can I output a file with a given filename using the workspaces approach?
On a side note, it would be great if the PNG output could be determined via a C API call rather than ENV variables.
You can always define a file path and an output type from your shell:
export GKS_FILEPATH="<path>"
export GKS_WSTYPE="<type>"
e.g.
export GKS_FILEPATH="hello.png"
export GKS_WSTYPE="png"
The way the GKS workspaces work is very confusing. Is there any documentation that points to the exact behavior? How can I output a file with a given filename using the workspaces approach?
You can find the documentation for workstation types at https://gr-framework.org/workstations.html.
Ah. The example that you have elaborated works for me. However, when I use
beginprint
it fails to ouput anything.
I tried your example in a fresh Debian stretch Docker container with our latest GR runtime (https://gr-framework.org/downloads/gr-latest-Debian-x86_64.tar.gz). For me, both versions (environment variables and beginprint
/endprint
) work. Which version of Debian do you use? Maybe our runtime does not work on older or very new Debian branches.
Here you go:
➜ gr git:(axeslbl-docs) cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Ok, currently I have no idea why it does not work for you...
Could you set the GRDIR
variable before running your example with beginprint
/endprint
?
export GRDIR=<path-to-your-gr-directory>
Maybe GR tries to load a plugin of another GR installation or does not find the PNG output plugin at all.
This is a complete test script:
#!/bin/bash
get_gr () {
local GR_BINARY_URL="https://gr-framework.org/downloads/gr-latest-Debian-x86_64.tar.gz"
curl -O -L "${GR_BINARY_URL}" && \
tar -xvf "gr-latest-Debian-x86_64.tar.gz"
}
run_example1 () (
cat << 'EOF' > Makefile
GRDIR = /usr/local/gr
INCLUDES = -I$(GRDIR)/include
CFLAGS = -Wall -g $(INCLUDES)
LIBS = -L$(GRDIR)/lib -lGR
LDFLAGS = $(LIBS) -Wl,-rpath,$(GRDIR)/lib
test1: test1.o
$(CC) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -c $(CFLAGS) $<
clean:
rm -f test1 *.o
.PRECIOUS: %.o
.PHONY: clean
EOF
cat << 'EOF' > test1.c
#include <gr.h>
int main(void) {
double x[] = {0.1, 0.9};
gr_clearws();
gr_polyline(sizeof(x) / sizeof(x[0]), x, x);
gr_updatews();
return 0;
}
EOF
export GRDIR="$(pwd)/gr"
export GKS_WSTYPE="png"
export GKS_FILEPATH="test1.png"
make GRDIR="${GRDIR}" && \
./test1 && \
make clean
)
run_example2 () (
cat << 'EOF' > Makefile
GRDIR = /usr/local/gr
INCLUDES = -I$(GRDIR)/include
CFLAGS = -Wall -g $(INCLUDES)
LIBS = -L$(GRDIR)/lib -lGR
LDFLAGS = $(LIBS) -Wl,-rpath,$(GRDIR)/lib
test2: test2.o
$(CC) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -c $(CFLAGS) $<
clean:
rm -f test2 *.o
.PRECIOUS: %.o
.PHONY: clean
EOF
cat << 'EOF' > test2.c
#include <gr.h>
int main(void) {
double x[] = {0.1, 0.9};
gr_beginprint("test2.png");
gr_polyline(sizeof(x) / sizeof(x[0]), x, x);
gr_endprint();
return 0;
}
EOF
export GRDIR="$(pwd)/gr"
make GRDIR="${GRDIR}" && \
./test2 && \
make clean
)
main () {
local GR_TMP_DIR="$(mktemp -d)"
cd "${GR_TMP_DIR}" && \
get_gr && \
run_example1 && \
run_example2 && \
if [[ -s "test1.png" ]] && diff -q "test1.png" "test2.png"; then
echo "Both tests created the same graphics output."
else
echo "The tests wrote different graphics files."
fi
if [[ -n "${GR_TMP_DIR}" ]]; then
rm -rf "${GR_TMP_DIR}"
fi
}
main "$@"
Could you try to run that?
OK. I'll investigate and get back to you.
The example you showed worked. I used those settings for my code and it worked too. Thank you very much for your patience.
I've made a Ruby wrapper for GR 0.37, and while it displays properly to a window, when saving to PNG I get the following error:
Here's my script: