Skip to content

Link error, Libtorch 1.5 on Windows #37124

@slaweks17

Description

@slaweks17

🐛 Bug

Large number of link errors when trying rebuild an existing program with the new 1.5 version of Libtorch on Windows

To Reproduce

Steps to reproduce the behavior:

  1. Create a following program

#include <torch/torch.h>
int main(int argc, char** argv) {
torch::Tensor x_t;
}

  1. Try to build it. The compilation is successful, the link fails with messages like
    LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl at::Tensor::Tensor(void)" (_imp??0Tensor@at@@qeaa@XZ) referenced in function main Pytorch15 C:\progs\c++\CTorch\Pytorch15\test.obj 1

Environment

Windows 10, Visual Studio 2019, toolset either v141 or v142, the linker options:
/OUT:"C:\progs\c++\CTorch\x64\Debug\Pytorch15.exe" /MANIFEST /NXCOMPAT /PDB:"C:\progs\c++\CTorch\x64\Debug\Pytorch15.pdb" /DYNAMICBASE "torch.lib" "c10.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X64 /INCREMENTAL /PGD:"C:\progs\c++\CTorch\x64\Debug\Pytorch15.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Debug\Pytorch15.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\progs2\libtorch_debug\lib" /TLBID:1

The program builds and works when liked with libtorch 1.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions