2

Following https://pytorch.org/cppdocs/installing.html, I have

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(example-app)

find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

include_directories(
    "${TORCH_INCLUDE_DIRS}" # libtorch headers
)

add_executable(example-app example-app.cpp)
target_link_libraries(example-app "${TORCH_LIBRARIES}")
set_property(TARGET example-app PROPERTY CXX_STANDARD 14)

This works but links to the shared Torch libraries; how can I link to the static ones instead?

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
  • 2
    Did you try calling CMake with `BUILD_SHARED_LIBS` off? `cmake -DBUILD_SHARED_LIBS=OFF ..` This [response](https://stackoverflow.com/a/60832196/3987854) may also be helpful. – Kevin Sep 15 '20 at 15:17

0 Answers0