 .../calib3d/include/opencv2/calib3d/calib3d.hpp    |  6 ++
 .../contrib/include/opencv2/contrib/contrib.hpp    |  7 +-
 modules/core/include/opencv2/core/core.hpp         |  6 ++
 modules/core/include/opencv2/core/pragma_lib.hpp   | 91 ++++++++++++++++++++++
 .../include/opencv2/features2d/features2d.hpp      |  6 ++
 modules/flann/include/opencv2/flann/flann.hpp      | 10 ++-
 modules/gpu/include/opencv2/gpu/gpu.hpp            |  8 +-
 .../highgui/include/opencv2/highgui/highgui.hpp    |  6 ++
 .../imgproc/include/opencv2/imgproc/imgproc.hpp    |  8 +-
 modules/legacy/include/opencv2/legacy/legacy.hpp   |  6 ++
 modules/ml/include/opencv2/ml/ml.hpp               |  6 ++
 .../nonfree/include/opencv2/nonfree/nonfree.hpp    |  6 ++
 .../include/opencv2/objdetect/objdetect.hpp        |  6 ++
 modules/photo/include/opencv2/photo/photo.hpp      |  6 ++
 .../include/opencv2/stitching/stitcher.hpp         |  6 ++
 modules/ts/include/opencv2/ts/ts.hpp               |  6 ++
 .../include/opencv2/videostab/videostab.hpp        |  6 ++
 17 files changed, 191 insertions(+), 5 deletions(-)

diff --git a/modules/calib3d/include/opencv2/calib3d/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d/calib3d.hpp
index fb70eef..f1fd9e2 100644
--- a/modules/calib3d/include/opencv2/calib3d/calib3d.hpp
+++ b/modules/calib3d/include/opencv2/calib3d/calib3d.hpp
@@ -748,4 +748,10 @@ CV_EXPORTS_W  int estimateAffine3D(InputArray src, InputArray dst,
 
 #endif
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("calib3d")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
diff --git a/modules/contrib/include/opencv2/contrib/contrib.hpp b/modules/contrib/include/opencv2/contrib/contrib.hpp
index 65da22c..257de64 100644
--- a/modules/contrib/include/opencv2/contrib/contrib.hpp
+++ b/modules/contrib/include/opencv2/contrib/contrib.hpp
@@ -970,5 +970,10 @@ namespace cv
 
 #endif
 
-#endif
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("contrib")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
 
+#endif
diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp
index 9ffe7d4..324721a 100644
--- a/modules/core/include/opencv2/core/core.hpp
+++ b/modules/core/include/opencv2/core/core.hpp
@@ -4643,4 +4643,10 @@ protected:
 #include "opencv2/core/operations.hpp"
 #include "opencv2/core/mat.hpp"
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("core")
+#endif
+
 #endif /*__OPENCV_CORE_HPP__*/
diff --git a/modules/core/include/opencv2/core/pragma_lib.hpp b/modules/core/include/opencv2/core/pragma_lib.hpp
new file mode 100644
index 0000000..0e9a2ad
--- /dev/null
+++ b/modules/core/include/opencv2/core/pragma_lib.hpp
@@ -0,0 +1,91 @@
+/*! \file pragma_include.hpp
+    \brief #pragmas for auto library linking
+ */
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+//  By downloading, copying, installing or using the software you agree to this license.
+//  If you do not agree to this license, do not download, install,
+//  copy or use the software.
+//
+//
+//                           License Agreement
+//                For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+//   * Redistribution's of source code must retain the above copyright notice,
+//     this list of conditions and the following disclaimer.
+//
+//   * Redistribution's in binary form must reproduce the above copyright notice,
+//     this list of conditions and the following disclaimer in the documentation
+//     and/or other materials provided with the distribution.
+//
+//   * The name of the copyright holders may not be used to endorse or promote products
+//     derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_PRAGMA_LIB_HPP__
+#define __OPENCV_PRAGMA_LIB_HPP__ 1
+
+#if (defined(_MSC_VER) && !defined(PRAGMA_COMMENT_SUPPORT)) \
+  && !defined(CVAPI_EXPORTS)
+#define PRAGMA_COMMENT_SUPPORT 1
+#elif !defined(PRAGMA_COMMENT_SUPPORT)
+#define PRAGMA_COMMENT_SUPPORT 0
+#endif
+
+#ifndef CV_MAJOR_VERSION
+#pragma message("WARM: Any OpenCV header included before pragma_lib.hpp")
+#include "opencv2/core/version.hpp"
+#endif
+
+// version string which contains in library's file name such as "232"
+#define OPENCV_LIBVERSTR \
+  CVAUX_STR(CV_MAJOR_VERSION) \
+  CVAUX_STR(CV_MINOR_VERSION) \
+  CVAUX_STR(CV_SUBMINOR_VERSION)
+
+// generate #pragma arguments string
+#ifndef _DEBUG // Release
+#define OPENCV_COMMENT_LIB_FNAME(name) \
+comment(lib, "opencv_" name OPENCV_LIBVERSTR ".lib")
+#else          // Debug
+#define OPENCV_COMMENT_LIB_FNAME(name) \
+comment(lib, "opencv_" name OPENCV_LIBVERSTR "d.lib")
+#endif
+
+// defined macro search,
+// OPENCV_DEFINE_SEARCH(modulename) is only true
+// when header file of modulename is included.
+#define OPENCV_DEFINE_SEARCH(modulename) \
+  ( \
+  defined( __OPENCV_##modulename##_HPP__ )        || \
+  defined(  _OPENCV_##modulename##_HPP_ )         || \
+  defined( __OPENCV_##modulename##_H__ )          || \
+  defined( __OPENCV_##modulename##_##name##_C_H ) \
+  )
+
+#ifndef OPENCV_AUTO_LINK
+#define OPENCV_AUTO_LINK 1
+#endif
+
+#endif // #ifndef __OPENCV_PRAGMA_LIB_HPP__
diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp
index 0b6d884..6bde158 100644
--- a/modules/features2d/include/opencv2/features2d/features2d.hpp
+++ b/modules/features2d/include/opencv2/features2d/features2d.hpp
@@ -1602,6 +1602,12 @@ protected:
 
 #endif /* __cplusplus */
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("features2d")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
 
 /* End of file. */
diff --git a/modules/flann/include/opencv2/flann/flann.hpp b/modules/flann/include/opencv2/flann/flann.hpp
index 93dd89c..aee45ea 100644
--- a/modules/flann/include/opencv2/flann/flann.hpp
+++ b/modules/flann/include/opencv2/flann/flann.hpp
@@ -40,8 +40,8 @@
 //
 //M*/
 
-#ifndef _OPENCV_FLANN_HPP_
-#define _OPENCV_FLANN_HPP_
+#ifndef __OPENCV_FLANN_HPP__
+#define __OPENCV_FLANN_HPP__
 
 #ifdef __cplusplus
 
@@ -424,4 +424,10 @@ FLANN_DEPRECATED int hierarchicalClustering(const Mat& features, Mat& centers, c
 
 #endif // __cplusplus
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("flann")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
diff --git a/modules/gpu/include/opencv2/gpu/gpu.hpp b/modules/gpu/include/opencv2/gpu/gpu.hpp
index f62b9a4..b6086ac 100644
--- a/modules/gpu/include/opencv2/gpu/gpu.hpp
+++ b/modules/gpu/include/opencv2/gpu/gpu.hpp
@@ -871,7 +871,7 @@ CV_EXPORTS void HoughCirclesDownload(const GpuMat& d_circles, OutputArray h_circ
 
 //! finds arbitrary template in the grayscale image using Generalized Hough Transform
 //! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
-//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
+//! Guil, N., Gonzalez-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
 class CV_EXPORTS GeneralizedHough_GPU : public Algorithm
 {
 public:
@@ -2495,4 +2495,10 @@ CV_EXPORTS void calcWobbleSuppressionMaps(
 
 } // namespace cv
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("gpu")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif /* __OPENCV_GPU_HPP__ */
diff --git a/modules/highgui/include/opencv2/highgui/highgui.hpp b/modules/highgui/include/opencv2/highgui/highgui.hpp
index c511beb..c16a684 100644
--- a/modules/highgui/include/opencv2/highgui/highgui.hpp
+++ b/modules/highgui/include/opencv2/highgui/highgui.hpp
@@ -250,4 +250,10 @@ protected:
 
 #endif
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("highgui")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp
index 34d59e1..15d83c2 100644
--- a/modules/imgproc/include/opencv2/imgproc/imgproc.hpp
+++ b/modules/imgproc/include/opencv2/imgproc/imgproc.hpp
@@ -498,7 +498,7 @@ enum
 
 //! finds arbitrary template in the grayscale image using Generalized Hough Transform
 //! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
-//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
+//! Guil, N., Gonzalez-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
 class CV_EXPORTS GeneralizedHough : public Algorithm
 {
 public:
@@ -1258,6 +1258,12 @@ protected:
 
 #endif /* __cplusplus */
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("imgproc")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
 
 /* End of file. */
diff --git a/modules/legacy/include/opencv2/legacy/legacy.hpp b/modules/legacy/include/opencv2/legacy/legacy.hpp
index 1144131..56823ff 100644
--- a/modules/legacy/include/opencv2/legacy/legacy.hpp
+++ b/modules/legacy/include/opencv2/legacy/legacy.hpp
@@ -3499,6 +3499,12 @@ CVAPI(CvSeq*) cvSegmentFGMask( CvArr *fgmask, int poly1Hull0 CV_DEFAULT(1),
 }
 #endif
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("legacy")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
 
 /* End of file. */
diff --git a/modules/ml/include/opencv2/ml/ml.hpp b/modules/ml/include/opencv2/ml/ml.hpp
index d6246be..c99821e 100644
--- a/modules/ml/include/opencv2/ml/ml.hpp
+++ b/modules/ml/include/opencv2/ml/ml.hpp
@@ -2134,4 +2134,10 @@ CV_EXPORTS bool initModule_ml(void);
 #endif // __cplusplus
 #endif // __OPENCV_ML_HPP__
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("ml")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 /* End of file. */
diff --git a/modules/nonfree/include/opencv2/nonfree/nonfree.hpp b/modules/nonfree/include/opencv2/nonfree/nonfree.hpp
index 3510f02..9f57638 100644
--- a/modules/nonfree/include/opencv2/nonfree/nonfree.hpp
+++ b/modules/nonfree/include/opencv2/nonfree/nonfree.hpp
@@ -52,6 +52,12 @@ CV_EXPORTS bool initModule_nonfree();
     
 }
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("nonfree")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
 
 /* End of file. */
diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp
index 644599c..d70bd37 100644
--- a/modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+++ b/modules/objdetect/include/opencv2/objdetect/objdetect.hpp
@@ -1053,4 +1053,10 @@ CV_EXPORTS Ptr<Detector> getDefaultLINEMOD();
 
 #endif
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("objdetect")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
diff --git a/modules/photo/include/opencv2/photo/photo.hpp b/modules/photo/include/opencv2/photo/photo.hpp
index 6697377..92528ba 100644
--- a/modules/photo/include/opencv2/photo/photo.hpp
+++ b/modules/photo/include/opencv2/photo/photo.hpp
@@ -88,4 +88,10 @@ CV_EXPORTS_W void fastNlMeansDenoisingColoredMulti( InputArrayOfArrays srcImgs,
 
 #endif //__cplusplus
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("photo")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
diff --git a/modules/stitching/include/opencv2/stitching/stitcher.hpp b/modules/stitching/include/opencv2/stitching/stitcher.hpp
index e274deb..c0df4f6 100644
--- a/modules/stitching/include/opencv2/stitching/stitcher.hpp
+++ b/modules/stitching/include/opencv2/stitching/stitcher.hpp
@@ -171,4 +171,10 @@ private:
 
 } // namespace cv
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("stitching")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif // __OPENCV_STITCHING_STITCHER_HPP__
diff --git a/modules/ts/include/opencv2/ts/ts.hpp b/modules/ts/include/opencv2/ts/ts.hpp
index bf6e7e9..9ae4908 100644
--- a/modules/ts/include/opencv2/ts/ts.hpp
+++ b/modules/ts/include/opencv2/ts/ts.hpp
@@ -580,4 +580,10 @@ int main(int argc, char **argv) \
 
 #endif
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("ts")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #include "ts_perf.hpp"
diff --git a/modules/videostab/include/opencv2/videostab/videostab.hpp b/modules/videostab/include/opencv2/videostab/videostab.hpp
index 3f86089..a167d4b 100644
--- a/modules/videostab/include/opencv2/videostab/videostab.hpp
+++ b/modules/videostab/include/opencv2/videostab/videostab.hpp
@@ -52,4 +52,10 @@
 #include "opencv2/videostab/stabilizer.hpp"
 #include "opencv2/videostab/ring_buffer.hpp"
 
+// Auto linking by "#pragma comment(lib)" syntax
+#include "opencv2/core/pragma_lib.hpp"
+#if PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+#pragma OPENCV_COMMENT_LIB_FNAME("videostab")
+#endif // PRAGMA_COMMENT_SUPPORT && OPENCV_AUTO_LINK
+
 #endif
