I grew up with Ruby as my first language; I know very little about C and lower layers. So it is difficult to accurately describe the problem. Still, I will write as much as I know.
The compile flags for GR.cr are copied from the original Dr. Makino implementation.
@[Link(ldflags: "-L `echo $GRDIR`/lib -lGR -Wl,-rpath,`echo $GRDIR`/lib")]
I used Crystal's macro to add a conditional branch for when the environment variable GRDIR is set and when it is not.
{% if env("GRDIR") %}
@[Link(ldflags: "-L `echo $GRDIR/lib` -lGR -Wl,-rpath,`echo $GRDIR/lib`")]
{% else %}
@[Link("gr")] # pkg-config
{% end %}
Here are some factors to consider.
- OS
- GR Framework
- Official binary
- homebrew
- apt (OBS)
- Crystal
I use Ubuntu and APT. In this case, GRDIR must be specified before execution. PKG_CONFIG_PATH must be set for pkg-config to detect APT (OBS) packages. I believe that is done correctly. On the other hand, when using Crystal's interpreter, it does not work when GRDIR is set. pkg-config works fine.
Why? I don't know but I think this has something to do with -rpath ?.
Oddly enough, on macOS + homebrew, pkg-config seems to work as expected even if GRDIR is not set. I have not tried crystal i on macOS.
I grew up with Ruby as my first language; I know very little about C and lower layers. So it is difficult to accurately describe the problem. Still, I will write as much as I know.
The compile flags for GR.cr are copied from the original Dr. Makino implementation.
I used Crystal's macro to add a conditional branch for when the environment variable GRDIR is set and when it is not.
{% if env("GRDIR") %} @[Link(ldflags: "-L `echo $GRDIR/lib` -lGR -Wl,-rpath,`echo $GRDIR/lib`")] {% else %} @[Link("gr")] # pkg-config {% end %}Here are some factors to consider.
I use Ubuntu and APT. In this case, GRDIR must be specified before execution. PKG_CONFIG_PATH must be set for pkg-config to detect APT (OBS) packages. I believe that is done correctly. On the other hand, when using Crystal's interpreter, it does not work when GRDIR is set. pkg-config works fine.
Why? I don't know but I think this has something to do with
-rpath?.Oddly enough, on macOS + homebrew,
pkg-configseems to work as expected even if GRDIR is not set. I have not tried crystal i on macOS.