我有gloo库的修改版本。我能够编译和运行使用该库的程序(类似于您在gloo/gloo/examples
中找到的程序)。
现在,我想用我的库构建pytorch。
我用我的gloo版本替换了PyTorch中的third_party/gloo
文件夹,我正在尝试对其进行编译。
但是,我的gloo版本需要一些其他库和特殊的链接器选项。 这些链接器选项应在pytorch构建系统中的何处添加?
没有这些链接器选项,编译会因链接器错误而停止:
/pytorch/build/lib/libcaffe2_gpu.so: undefined reference to <my code>
/pytorch/build/lib/libcaffe2.so: undefined reference to <my code>
答案 0 :(得分:0)
其他链接器选项应添加到:
Caffe2_DEPENDENCY_LIBS
中的pytorch/caffe2/CMakeLists.txt
变量:
list(APPEND Caffe2_DEPENDENCY_LIBS <linker_options>)
C10D_LIBS
中的pytorch/torch/lib/c10d/CMakeLists.txt
变量:
list(APPEND C10D_LIBS <linker_options>)
其他库应具有“位置无关代码”(必须使用-fPIC
标志进行编译)。