Ask Your Question
1

How to link opencv and other dll files to output exe of visual studio 2013

asked 2014-02-13 07:06:53 -0500

vsay gravatar image

I am new with visual studio, opencv.

I am using visual studio 2013, opencv and c++ for my project.

I configured (copied path) the opencv and other library to my computer environment system.

After run the project in visual studio, normally, there will be an exe file in the project.

I can copy the exe file in the project folder and copy to other place in my computer and it will run normally.

This is because my computer environment systems are configured with opencv and other library.

I want to do the same thing with other computers BUT I do not want to manually configure each computer with opencv and other libraries.

Are there any ways that I can do to link everythings all in exe file after run the project in visual studio 2013 so that I can run the exe without depend on the path of libaries and opencv?

Thank you.

edit retag flag offensive close merge delete

Comments

I think you can copy the exe along with the libs and dlls. Does that work for you?

GilLevi gravatar imageGilLevi ( 2014-02-13 08:30:13 -0500 )edit

@GilLevi I tried to copy dll put the same location as my exe files but it not works

vsay gravatar imagevsay ( 2014-02-13 08:47:12 -0500 )edit

You might find this link, helpful.

Y Simson gravatar imageY Simson ( 2014-05-07 07:30:30 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-02-14 17:16:32 -0500

Yes, of course but with some constraints: you must have all the static versions of the libraries you used for compiling your programs. I do not think this is possible, especially when you use some (>1) libraries and on Windows. If you use only OpenCV, you can link your program to static version (in the static folder of release OpenCV version - 2.4.8 may be) and copy VC 2013's .dll files (at least 2 files for Windows API, 2 files for MFC) with you program and it can run well on other Windows systems, but if you do not have static version of any using libraries, you can not do that. So my solution is that: copy all needed .dll files (in one folder) to your target machine, and every time you want to test your program on that, you just copy the program file (.exe) to the folder, without recopying needed .dll. Hope this help.

edit flag offensive delete link more

Comments

thank @tuannhtncould you describe the steps from scratch ? I am new with cmake, opencv and c++ ... All i know is in vs2013 after we compile the project we could get the exe file. i download opencv2.4.7.2.exe i install it and put in c:/opencv and when i create the project in vs2013 i just configure the path of linker and dependencies.

vsay gravatar imagevsay ( 2014-02-20 06:46:09 -0500 )edit

OK. Firstly, I suppose you want to avoid setting details (path to header and .lib files) for every project, right? For that purpose, you just config one time the global config with VS and after that, every time you create a new project, VS automatically use the global settings for your project. Just open any VC project, go to Property Manager tab (View->Property Manager if you do not know where), click on the Project Name, choose Debug|Win32 (or Release|Win32), choose properties of Microsoft.Cpp.Win32.User, go to VC++ Directory, add path to header and .lib files to Include Directories and Librariy Directories, and in the Linker/Input, add the names (or path to) of .lib files (eg. D:\opencvstable\build\x86\vc11\lib\*.lib). Save and exit.

tuannhtn gravatar imagetuannhtn ( 2014-02-20 07:07:34 -0500 )edit

The second purpose, as I understand, that you want to run your program on other Windows system with less copy .dll or other setting details? For that objective, just link your program with static .lib files (eg. D:\opencvstable\build\x86\vc11\staticlib\*.lib). With this step, you don't need to copy the .dll files to target machine, just your program. Hope this help.

tuannhtn gravatar imagetuannhtn ( 2014-02-20 07:10:10 -0500 )edit

Question Tools

Stats

Asked: 2014-02-13 07:06:53 -0500

Seen: 3,031 times

Last updated: Feb 14 '14