Skip to content

Ask pkg-config where MEOS is and which families it has - #13

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/cgo-pkg-config
Aug 15, 2026
Merged

Ask pkg-config where MEOS is and which families it has#13
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:fix/cgo-pkg-config

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

The generated cgo preamble asks pkg-config for the MEOS include dir, link path and family macros.

The alternative is a hardcoded /usr/local (and /opt/homebrew) plus a hand-kept list of ten -D family macros mirroring the if(ALL) loop in MobilityDB CMakeLists. Both are assumptions about a machine rather than facts about the library, and the -D list is the one that bites: the public headers gate declarations on those macros, so a list that disagrees with the installed library either declares a symbol that cannot link or hides a family the library provides. The macros do not follow from -DALL either, which selects families at configure time and never reaches a compiler.

The installed meos.pc carries both, so the preamble asks for them. This also makes the binding relocatable: PKG_CONFIG_PATH selects which libmeos to build against, which lets a build target a private prefix instead of a machine-wide directory shared with every other process on the host. A prefix outside the loader default search path needs LD_LIBRARY_PATH or ldconfig.

H3 ships no pkg-config file, so meos_h3.hs <h3api.h> keeps its include dir named in the preamble; GEOS and GSL resolve from the default include path.

go build ./functions/ against a private prefix exits 0, with each of the 13 meos*.h headers resolving inside that prefix.

The cgo preamble hardcoded /usr/local (and /opt/homebrew) as the place to find
libmeos, plus a hand-kept list of ten -D family macros mirroring the if(ALL)
loop in MobilityDB's CMakeLists. Both are assumptions about a machine rather
than facts about the library, and the -D list is the one that bites: the public
headers gate declarations on those macros, so a list that disagrees with the
installed library either declares a symbol that cannot link or hides a family
the library provides. The macros are not derivable from -DALL either, which
selects families at configure time and never reaches a compiler.

The installed meos.pc now reports both, so the preamble asks for them. This
also makes the binding relocatable: PKG_CONFIG_PATH selects which libmeos to
build against, which is what lets a build target a private prefix instead of
inheriting a machine-wide directory shared with everything else on the host.

H3 ships no pkg-config file, so meos_h3.h's <h3api.h> keeps its include dir
named here; GEOS and GSL resolve from the default include path.
@estebanzimanyi
estebanzimanyi merged commit 6df1a86 into MobilityDB:main Aug 15, 2026
2 checks passed
@estebanzimanyi
estebanzimanyi deleted the fix/cgo-pkg-config branch August 15, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant