georust / gdal

Rust bindings for GDAL
https://crates.io/crates/gdal
MIT License
339 stars 92 forks source link

Error reported when cross compiling on Windows #524

Open allenlu2008 opened 4 months ago

allenlu2008 commented 4 months ago

I need to cross-compile the Linux environment on Windows. Run the command as follows:

cargo build --release --target=x86_64-unknown-linux-musl

output:

Compiling gdal-sys v0.9.1 Compiling nalgebra v0.30.1 Compiling itertools v0.10.5 Compiling log v0.4.20 Compiling float_next_after v1.0.0 Compiling bitflags v2.4.2 Compiling rand v0.8.5 Compiling lazy_static v1.4.0 Compiling dotenv v0.15.0 Compiling gdal v0.16.0 Compiling geo v0.28.0 error: could not find native static library gdal_i, perhaps an -L flag is missing?

error: could not compile gdal-sys (lib) due to 1 previous error warning: build failed, waiting for other jobs to finish...

but cargo build --release

complie success。

why?

allenlu2008 commented 4 months ago

and on linux:

= note: /usr/lib64/libgdal.so: undefined reference to PQcmdStatus@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQfname@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQsetNoticeProcessor@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQftable@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQstatus@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQftablecol@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQconnectdb@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQescapeStringConn@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to lo_close@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQputCopyEnd@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQgetvalue@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQgetisnull@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQftype@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQfmod@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to lo_creat@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQresultStatus@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to lo_read@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQexec@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQsetClientEncoding@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQgetlength@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQputCopyData@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQgetResult@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to lo_write@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQfinish@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQclear@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQerrorMessage@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQnfields@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference tolo_open@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to PQexecParams@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference toPQntuples@RHPG_9.6' /usr/lib64/libgdal.so: undefined reference to `PQresultErrorMessage@RHPG_9.6' collect2: error: ld returned 1 exit status

= note: some extern functions couldn't be found; some native libraries may need to be installed or have their path specified = note: use the -l flag to specify native libraries to link = note: use the cargo:rustc-link-lib directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile geo2png (bin "geo2png") due to previous error

Quietly-20201113 commented 2 months ago

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\rasterband.rs:44:24 | 44 | NearestNeighbour = GDALRIOResampleAlg::GRIORA_NearestNeighbour, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\rasterband.rs:46:16 | 46 | Bilinear = GDALRIOResampleAlg::GRIORA_Bilinear, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\rasterband.rs:48:13 | 48 | Cubic = GDALRIOResampleAlg::GRIORA_Cubic, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\rasterband.rs:50:19 | 50 | CubicSpline = GDALRIOResampleAlg::GRIORA_CubicSpline, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\rasterband.rs:52:15 | 52 | Lanczos = GDALRIOResampleAlg::GRIORA_Lanczos, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\rasterband.rs:54:15 | 54 | Average = GDALRIOResampleAlg::GRIORA_Average, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\rasterband.rs:56:12 | 56 | Mode = GDALRIOResampleAlg::GRIORA_Mode, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\rasterband.rs:58:13 | 58 | Gauss = GDALRIOResampleAlg::GRIORA_Gauss, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:29:15 | 29 | Unknown = GDALDataType::GDT_Unknown, | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:31:13 | 31 | UInt8 = GDALDataType::GDT_Byte, | ^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:34:12 | 34 | Int8 = GDALDataType::GDT_Int8, | ^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:36:14 | 36 | UInt16 = GDALDataType::GDT_UInt16, | ^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:38:13 | 38 | Int16 = GDALDataType::GDT_Int16, | ^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:40:14 | 40 | UInt32 = GDALDataType::GDT_UInt32, | ^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:42:13 | 42 | Int32 = GDALDataType::GDT_Int32, | ^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:45:14 | 45 | UInt64 = GDALDataType::GDT_UInt64, | ^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:48:13 | 48 | Int64 = GDALDataType::GDT_Int64, | ^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:50:15 | 50 | Float32 = GDALDataType::GDT_Float32, | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

error[E0308]: mismatched types --> C:\Users\dell.cargo\registry\src\index.crates.io-6f17d22bba15001f\gdal-0.16.0\src\raster\types.rs:52:15 | 52 | Float64 = GDALDataType::GDT_Float64, | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32

For more information about this error, try rustc --explain E0308. error: could not compile gdal (lib) due to 19 previous errors

本地安装gdal 3.8.4 rust插件0.16.0