Y2theZ
Y2theZ

Reputation: 10402

use relative path for a library dependency,

i am working on a C++ project.

I am using OpenCV library. I added the directories to my system PATH. And added all the necessary items to Properties → VC++ Directories and to the Linker → Input → Additional Dependencies. (I followed This Guide

The project runs fine and i am able to use the OpenCV library.

However I need to send the project to another person.

is there a way for me to send it and he will be able to run the project without having to install OpenCV and doing all the necessary setups?

If no, I will tell him to install OpenCV. However he will need to change the paths in the directories and dependencies to the path of his local pen CV. So is there a way to make the path relative and not absolute? instead of using C:/OpenCV/OpenCV2 I use something like %(OpenCVDirectory)/OpenCV2

Thank you very much for any help.

Upvotes: 2

Views: 1101

Answers (1)

Camford
Camford

Reputation: 780

Yes you can. You can do it in a couple of different ways.

  1. Define your own environment variable. Let's call it CV_PATH. You can expanded in VC project by doing $(CV_PATH). Your friend can then define his CV_PATH and it should work.

  2. The better way is to use Property Sheet. Define the installation location as a build macro in your property sheet, let's call it CV_PATH again. You use it the same way as before, $(CV_PATH). There other advantages of using property sheet, especially if you want all your projects to have the same settings for certain things.

Upvotes: 2

Related Questions