douhe8981 2018-05-15 10:28
浏览 195
已采纳

Windows上的CGO:已加载DLL的命名

I am trying to use gorocksdb which is a cgo package wapping the rocksdb library on windows.

  • I built the rocksdb library with vcpkg which gave me as output rocksdb-shared.dll. I set the build path to my PATH.
  • I installed msys64 in order to have gcc
  • I have set CGO_CFLAGS="-I/path/to/rocksdb/include" and CGO_LDFLAGS="-L/path/to/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd"
  • I have renammed rocksdb-shared.dll to librocksdb.dll because the linker requires the dll to start with lib
  • I do the go get ... command
  • I run my test go file and I get the error The programer can't start because rocksdb-shared.dll is missing ...
  • If I rename it back to rocksdb-shared.dll the build fails because the linker can't find librocksdb.dll
  • The only way to make it work is to have both rocksdb-shared.dll and librocksdb.dll in the PATH

Why the executable keeps loading rocksdb-shared.dll? I don't find any reference to it in the cgo package.

  • 写回答

1条回答 默认 最新

  • douyin7829 2018-05-15 11:29
    关注

    I think I found the answer to my question.

    I think I can't rename the compiled dll because the dll "reference" itself as this name. So it won't load properly.

    To resolve my problem I just renamed the parameter in the LDFLAG from -lrocksdb to -lrocksdb-shared in both my environement variable and in this file

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog