Skip to content

Commit

Permalink
add pg_config --libdir to linker search path (#1932)
Browse files Browse the repository at this point in the history
On Windows, the linker needs `postgres.lib` to link against. So add
`pg_config --libdir` to linker search path.
  • Loading branch information
usamoi authored Oct 29, 2024
1 parent ae0335b commit 7969a47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pgrx-bindgen/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,12 @@ fn generate_bindings(
)
})?;
}

let lib_dir = pg_config.lib_dir()?;
println!(
"cargo:rustc-link-search={}",
lib_dir.to_str().ok_or(eyre!("{lib_dir:?} is not valid UTF-8 string"))?
);
Ok(())
}

Expand Down
4 changes: 4 additions & 0 deletions pgrx-pg-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ impl PgConfig {
Ok(self.run("--bindir")?.into())
}

pub fn lib_dir(&self) -> eyre::Result<PathBuf> {
Ok(self.run("--libdir")?.into())
}

pub fn postmaster_path(&self) -> eyre::Result<PathBuf> {
let mut path = self.bin_dir()?;
path.push("postgres");
Expand Down

0 comments on commit 7969a47

Please sign in to comment.