我正在尝试使用WASM数据库层创建NodeJS应用程序。我使用Rust,Diesel作为数据库驱动程序,并使用wasm-pack
作为Web Assembly编译器。
但是,当我尝试使用wasm-pack
构建服务时,尝试链接libpq
库失败。设置了PQ_LIB_DIR
环境变量,并且diesel-cli
正常工作。但是,当我尝试编译我的服务时,它失败并显示以下错误:
error: linking with `rust-lld` failed: exit code: 1
= note: rust-lld: error: unable to find library -llibpq
我该如何解决?
我的系统:
libpq在postgreSQL安装二进制文件中可用
例如,PosgreSQL Binary Download Site如果打开zip发行版postgresql-12.0-1-windows-x64-binaries.zip
,则可以看到
pgsql \ lib \ libpq.dll和pgsql \ lib \ libpq.lib
您需要指定LD_LIBRARY_PATH,或者可以在编译器参数中指定-L来告知将自动选择那些文件的文件夹路径
如果使用过安装程序,则安装文件夹中应该有相同的文件
您也可以参考此stackoverflow链接How to I tell Rust where to look for a static library?