0

when I start debugging the rust project in macOS 13.2 with M1 chip, show error like this:

 = note: ld: warning: ignoring file /Users/xiaoqiangjiang/anaconda3/lib/libpq.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
          ld: warning: ignoring file /Users/xiaoqiangjiang/anaconda3/lib/libiconv.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
          Undefined symbols for architecture arm64:
            "_PQclear", referenced from:
                _$LT$diesel..pg..connection..raw..RawResult$u20$as$u20$core..ops..drop..Drop$GT$::drop::hb78a4002b9ec51a3 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQcmdTuples", referenced from:
                diesel::pg::connection::result::PgResult::rows_affected::h6fc7050c44616d71 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.9.rcgu.o)
            "_PQconnectdb", referenced from:
                diesel::pg::connection::raw::RawConnection::establish::h669ea9459decf201 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQerrorMessage", referenced from:
                diesel::pg::connection::raw::last_error_message::h56cf968bffcd8b19 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQexec", referenced from:
                diesel::pg::connection::raw::RawConnection::exec::hb6a574ec4cb649f5 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQexecPrepared", referenced from:
                diesel::pg::connection::raw::RawConnection::exec_prepared::ha55c50860b15623a in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQfinish", referenced from:
                diesel::pg::connection::raw::RawConnection::establish::h669ea9459decf201 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
                _$LT$diesel..pg..connection..raw..RawConnection$u20$as$u20$core..ops..drop..Drop$GT$::drop::h6a760cfb23afcede in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQfnumber", referenced from:
                diesel::pg::connection::result::PgResult::field_number::hfbd378d7c043f319 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.9.rcgu.o)
            "_PQgetisnull", referenced from:
                diesel::pg::connection::result::PgResult::is_null::h183bbf84e1abdc77 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.9.rcgu.o)
            "_PQgetlength", referenced from:
                diesel::pg::connection::result::PgResult::get::h40c475852722de32 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.9.rcgu.o)
            "_PQgetvalue", referenced from:
                diesel::pg::connection::result::PgResult::get::h40c475852722de32 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.9.rcgu.o)
            "_PQntuples", referenced from:
                diesel::pg::connection::result::PgResult::num_rows::h5c8aee3238814c6f in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.9.rcgu.o)
            "_PQprepare", referenced from:
                diesel::pg::connection::raw::RawConnection::prepare::he10c0df4c8adb638 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQresultErrorField", referenced from:
                diesel::pg::connection::result::get_result_field::h637430fff254a165 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.9.rcgu.o)
            "_PQresultErrorMessage", referenced from:
                diesel::pg::connection::raw::RawResult::error_message::h98cf12a87da5b8b0 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQresultStatus", referenced from:
                diesel::pg::connection::result::PgResult::new::hac4426e7885c9efd in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.9.rcgu.o)
            "_PQsetNoticeProcessor", referenced from:
                diesel::pg::connection::raw::RawConnection::set_notice_processor::h041a3f01b677771b in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
            "_PQstatus", referenced from:
                diesel::pg::connection::raw::RawConnection::establish::h669ea9459decf201 in libdiesel-04495e608cd5cfd6.rlib(diesel-04495e608cd5cfd6.diesel.8e10f71b-cgu.3.rcgu.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

what should I do to fixed this issue? seems it using the anaconda libpq path. which path should I use? I have already tried to install libpq using this command:

brew install postgresql libpq

this is the libpq of my system:

> sudo find / -name 'libpq.dylib' 2>&1 | grep -v 'Operation not permitted'|grep -v 'Not a directory'|grep -v "No such file or directory"
Password:
/System/Volumes/Data/Users/xiaoqiangjiang/anaconda3/pkgs/libpq-12.9-h1c9f633_3/lib/libpq.dylib
/System/Volumes/Data/Users/xiaoqiangjiang/anaconda3/lib/libpq.dylib
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/MacOSX-SDKs/MacOSX10.7.sdk/usr/lib/libpq.dylib
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/MacOSX-SDKs/MacOSX10.9.sdk/usr/lib/libpq.dylib
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/MacOSX-SDKs/MacOSX10.8.sdk/usr/lib/libpq.dylib
/System/Volumes/Data/opt/homebrew/lib/libpq.dylib
/System/Volumes/Data/opt/homebrew/Cellar/postgresql@14/14.7/lib/postgresql@14/libpq.dylib
/System/Volumes/Data/opt/homebrew/Cellar/postgresql@14/14.6_1/lib/postgresql@14/libpq.dylib
/System/Volumes/Data/opt/homebrew/Cellar/libpq/15.2/lib/libpq.dylib
/Users/xiaoqiangjiang/anaconda3/pkgs/libpq-12.9-h1c9f633_3/lib/libpq.dylib
/Users/xiaoqiangjiang/anaconda3/lib/libpq.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/MacOSX-SDKs/MacOSX10.7.sdk/usr/lib/libpq.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/MacOSX-SDKs/MacOSX10.9.sdk/usr/lib/libpq.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/MacOSX-SDKs/MacOSX10.8.sdk/usr/lib/libpq.dylib
/opt/homebrew/lib/libpq.dylib
/opt/homebrew/Cellar/postgresql@14/14.7/lib/postgresql@14/libpq.dylib
/opt/homebrew/Cellar/postgresql@14/14.6_1/lib/postgresql@14/libpq.dylib
/opt/homebrew/Cellar/libpq/15.2/lib/libpq.dylib

I also tried to add config like this in Cargo.toml:

[target.aarch64-apple-darwin]
rustflags = '-L /opt/homebrew/lib'
spark
  • 663
  • 1
  • 5
  • 18

0 Answers0