Cargo dependency build error - found staticlib `rustc` instead of rlib or dylib

Wondering if anyone might have some advise on some new errors I've never seen before attempting to compile a rust sample for getting started with postgres.

Background is that I'm trying to become familiar with integrating the postgres driver using JSON. I have a simple hello world example working fine, but in order to use the specialized postgres JSON types requires additional hurdles. And so I'm having a go at this tutorial page: Postgres Example

This article seems to dive into integrating specialized postgres types with Rust, however when I try to compile the first sample I'm hitting an obstacle compiling the postgres_macro crate dependency.

Here's my Cargo.toml

[package]
name = "day11"
version = "0.1.0"
edition = "2018"

[dependencies]
postgres = "0.19.2"
postgres_macros = "0.1.13"
rustc-serialize = "0.3.24"
time = "0.3.3"
postgres_array = "0.11.0"

Here's the cargo build error output:

argo build
    Updating crates.io index
   Compiling postgres_macros v0.1.13
error[E0462]: found staticlib `rustc` instead of rlib or dylib
 --> /home/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/postgres_macros-0.1.13/src/lib.rs:4:1
  |
4 | extern crate rustc;
  | ^^^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using --crate-type lib
  = note: the following crate versions were found:
          crate `rustc`: /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.asan.a
          crate `rustc`: /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.tsan.a
          crate `rustc`: /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.lsan.a
          crate `rustc`: /home/chris/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.msan.a

error: could not compile `postgres_macros` due to previous error

Is there something I need to drop into the Cargo.toml to request that postgres_macros be compiled as a lib?

It looks like postgres_macros is using rustc internals in order to implement a custom procedural macro. What you are seeing is rustc trying (and failing) to find a valid pre-compiled rustc library that it can link with.

I'd suggest looking for an alternate example to work with, or maybe removing postgres_macros and seeing if you can get the example working anyway.

Considering postgres_macros hasn't seen any changes since 2017 it will almost certainly no longer compile because rustc's internals have changed significantly since then. The rustc-serialize crate will probably have a similar problem.

Thanks. I actually had the same thought.

They make use of the macro run! right from the get go, I'll need to see how much they require it. Alas, I may need to find a better example on how to use JSON datatype in PG!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.