Skip to content

Commit 7969a47

Browse files
authored
add pg_config --libdir to linker search path (pgcentralfoundation#1932)
On Windows, the linker needs `postgres.lib` to link against. So add `pg_config --libdir` to linker search path.
1 parent ae0335b commit 7969a47

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pgrx-bindgen/src/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ fn generate_bindings(
343343
)
344344
})?;
345345
}
346+
347+
let lib_dir = pg_config.lib_dir()?;
348+
println!(
349+
"cargo:rustc-link-search={}",
350+
lib_dir.to_str().ok_or(eyre!("{lib_dir:?} is not valid UTF-8 string"))?
351+
);
346352
Ok(())
347353
}
348354

pgrx-pg-config/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ impl PgConfig {
323323
Ok(self.run("--bindir")?.into())
324324
}
325325

326+
pub fn lib_dir(&self) -> eyre::Result<PathBuf> {
327+
Ok(self.run("--libdir")?.into())
328+
}
329+
326330
pub fn postmaster_path(&self) -> eyre::Result<PathBuf> {
327331
let mut path = self.bin_dir()?;
328332
path.push("postgres");

0 commit comments

Comments
 (0)