# C++에서 Torchvision 사용

**URL:** <https://discuss.pytorch.kr/t/c-torchvision/891>\
**Category:** 묻고 답하기\
**Created:** [12월 27, 2022, 12:01오전 UTC](https://discuss.pytorch.kr/t/c-torchvision/891 "2022-12-27T00:01:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LHS5284](https://discuss.pytorch.kr/letter_avatar_proxy/v4/letter/l/76d3ee/32.png) [@LHS5284](https://discuss.pytorch.kr/u/LHS5284)\
**Post date:** [12월 27, 2022, 12:01오전 UTC](https://discuss.pytorch.kr/t/c-torchvision/891/1 "2022-12-27T00:01:47Z")

</div>

안녕하세요. 저는 MaskRCNN을 C언어로 구현하기 프로그램 개발중에 있습니다.

기존 파이썬으로 Pretrained된 모델을 C언어에서 사용하기 위해 개발 중 Torchvision의 Header file을 include 해야하는 것을 알게 되었습니다.

#include \<torchvision/vision.h\>

find\_package(TorchVision REQUIRED)  
target\_link\_libraries(my-target PUBLIC TorchVision::TorchVision)

Torchvision cpp를 컴파일이 정상적으로 생성되어 구동테스트를 하려 하였으나, Cmake Configuration 단계에서 다음과 같은 에러가 발생하여 도움을 요청드립니다.

1. CMakeList 내역  
cmake\_minimum\_required(VERSION 3.10)  
project(hello-world)  
find\_package(TorchVision REQUIRED)  
find\_package(Python3 COMPONENTS Development)  
add\_executable(hello-world main.cpp)  
target\_compile\_features(hello-world PUBLIC cxx\_range\_for)  
target\_link\_libraries(hello-world TorchVision::TorchVision)  
set\_property(TARGET hello-world PROPERTY CXX\_STANDARD 14)

2. 에러내역  
[CMake] CMake Error at D:/vision-mainr1/build/TorchVisionConfig.cmake:50 (include):  
1\> [CMake] include could not find requested file:  
1\> [CMake]  
1\> [CMake] D:/vision-mainr1/build/TorchVisionTargets.cmake  
1\> [CMake] Call Stack (most recent call first):  
1\> [CMake] CMakeLists.txt:7 (find\_package)  
1\> [CMake] CMake Error at D:/vision-mainr1/build/TorchVisionConfig.cmake:52 (target\_include\_directories):  
1\> [CMake] Cannot specify include directories for target "TorchVision::TorchVision"  
1\> [CMake] which is not built by this project.  
1\> [CMake] Call Stack (most recent call first):  
1\> [CMake] CMakeLists.txt:7 (find\_package)  
1\> [CMake] CMake Error at D:/vision-mainr1/build/TorchVisionConfig.cmake:55 (target\_compile\_definitions):  
1\> [CMake] Cannot specify compile definitions for target "TorchVision::TorchVision"  
1\> [CMake] which is not built by this project.  
1\> [CMake] Call Stack (most recent call first):  
1\> [CMake] CMakeLists.txt:7 (find\_package)  
1\> [CMake] CMake Error at D:/vision-mainr1/build/TorchVisionConfig.cmake:59 (target\_link\_libraries):  
1\> [CMake] Cannot specify link libraries for target "TorchVision::TorchVision" which  
1\> [CMake] is not built by this project.  
1\> [CMake] Call Stack (most recent call first):  
1\> [CMake] CMakeLists.txt:7 (find\_package)  
1\> [CMake] -- Configuring incomplete, errors occurred!

---

<div class="post-metadata">

**Author:** ![LHS5284](https://discuss.pytorch.kr/letter_avatar_proxy/v4/letter/l/76d3ee/32.png) [@LHS5284](https://discuss.pytorch.kr/u/LHS5284)\
**Post date:** [1월 2, 2023, 12:34오후 UTC](https://discuss.pytorch.kr/t/c-torchvision/891/2 "2023-01-02T12:34:41Z")

</div>

😀.... 해결하였습니다.

---

<div class="post-metadata">

**Author:** ![system](https://discuss.pytorch.kr/uploads/default/original/3X/d/3/d386c1e2f73d2d5491cbada2ba7cab1202db4d07.png) [@system](https://discuss.pytorch.kr/u/system)\
**Post date:** [2월 1, 2023, 12:35오후 UTC](https://discuss.pytorch.kr/t/c-torchvision/891/3 "2023-02-01T12:35:18Z")

</div>

2월 1, 2023, 12:35오후 UTC에 닫힘

이 글은 마지막 댓글이 달린지 오래(30일)되어 자동으로 닫혔습니다. 댓글 대신 새로운 글을 작성해주세요! 🙂
