Skip to content

Commit 4e98bad

Browse files
rholshausenclaude
andcommitted
fix(c examples): link pact_ffi cdylib instead of staticlib to pull in vendored Lua
corrosion defaults to linking consumers against the pact_ffi staticlib, but mlua's vendored Lua build is only baked in by cargo when linking the cdylib, causing undefined lua_* symbol errors when building the C consumer/provider examples. Restrict corrosion_import_crate to the cdylib crate type so it links against libpact_ffi.so instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent d947345 commit 4e98bad

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

c/consumer/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,15 @@ find_package(BZip2 REQUIRED)
5050
find_package(ZLIB REQUIRED)
5151

5252
# The Pact FFI is a Rust project
53+
#
54+
# We only import the cdylib crate type here (rather than the default, which
55+
# would prefer the staticlib). pact_ffi pulls in native static libraries via
56+
# dependencies' build scripts (e.g. mlua's vendored Lua), which cargo bakes
57+
# into the cdylib at link time but does not surface to corrosion for the
58+
# staticlib, causing missing symbol errors when linking against libpact_ffi.a.
5359
corrosion_import_crate(
5460
MANIFEST_PATH "${PACT_FFI_ROOT}/Cargo.toml"
61+
CRATE_TYPES cdylib
5562
)
5663
corrosion_experimental_cbindgen(
5764
TARGET pact_ffi

c/provider/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,15 @@ find_package(BZip2 REQUIRED)
4949
find_package(ZLIB REQUIRED)
5050

5151
# The Pact FFI is a Rust project
52+
#
53+
# We only import the cdylib crate type here (rather than the default, which
54+
# would prefer the staticlib). pact_ffi pulls in native static libraries via
55+
# dependencies' build scripts (e.g. mlua's vendored Lua), which cargo bakes
56+
# into the cdylib at link time but does not surface to corrosion for the
57+
# staticlib, causing missing symbol errors when linking against libpact_ffi.a.
5258
corrosion_import_crate(
5359
MANIFEST_PATH "${PACT_FFI_ROOT}/Cargo.toml"
60+
CRATE_TYPES cdylib
5461
)
5562
corrosion_experimental_cbindgen(
5663
TARGET pact_ffi

0 commit comments

Comments
 (0)