Ask Your Question
0

Linking staticlib in mvs2013 release gives external errors [closed]

asked 2016-12-04 19:11:15 -0500

Nocs gravatar image

updated 2016-12-08 06:50:46 -0500

I have multiple errors LNK2001: unresolved external symbol error "opencv_highgui2413.lib(cap_vfw.obj) when i try to use the staticlib folder instead of lib and dlls in mvs2013 windows 10 and release option in project build. The statilib i am trying to use is opencv-2.4.13.exe

  • By C/C++ linking the include directory to : D:\OpenCV\build\include
  • By Linker linking the include dependancies to : D:\OpenCV\build\x86\vc12\staticlib And using : No Incremental linking
  • By Linker input additional dependancies entering each one .lib inside the folder of staticlib without "d"
  • By C/C++ using runtime library to : Multi-Threaded(/MT)

Is there anything i do wrong or is it something else ? Windows 10 - mvs2013 - The project i create to test is only a VideoCapture webcam test

My Test project is working fine if i dont use the staticlib and use the lib with dlls but since i want a staticlib i test it with the above linkings of opencv and it has errors in every function of object opecv_highgui2413.lib

Thanks in advance for any kind of help to solve this issue

@LBerger request :

  • C/C++ command line /GS /GL /analyze- /W3 /Gy /Zc:wchar_t /I"D:\OpenCV\build\include"/Zi /Gm- /O2 /Fd"Release\vc120.pdb" /fp:precise /D "WIN32" /D "_CONSOLE" /D "_LIB" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MT /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\TestVideo.pch"

  • LINKER command line /OUT:"D:\TestVideo\Release\TestVideo.exe" /MANIFEST /LTCG /NXCOMPAT /PDB:"D:\TestVideo\Release\TestVideo.pdb" /DYNAMICBASE "opencv_calib3d2413.lib" "opencv_contrib2413.lib" "opencv_core2413.lib" "opencv_features2d2413.lib" "opencv_flann2413.lib" "opencv_gpu2413.lib" "opencv_highgui2413.lib" "opencv_imgproc2413.lib" "opencv_legacy2413.lib" "opencv_ml2413.lib" "opencv_nonfree2413.lib" "opencv_objdetect2413.lib" "opencv_ocl2413.lib" "opencv_photo2413.lib" "opencv_stitching2413.lib" "opencv_superres2413.lib" "opencv_ts2413.lib" "opencv_video2413.lib" "opencv_videostab2413.lib" "IlmImf.lib" "libjasper.lib" "libjpeg.lib" "libpng.lib" "libtiff.lib" "zlib.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /OPT:REF /SAFESEH /INCREMENTAL:NO /PGD:"D:\TestVideo\Release\TestVideo.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Release\TestVideo.exe.intermediate.manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"D:\OpenCV\build\x86\vc12\staticlib" /TLBID:1

And Here is the small test which work with dynamic built of openv and not with static maby could help someone to help me out :

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace cv;
using namespace std;

int main(){

    Mat CamFrame;
    VideoCapture CaptureCam(CV_CAP_ANY);
    ..... alla others not needed cause even with VideoCapture it pops up all errors
    ..... if i remove VideoCapture no errors at all it builds in release mode and static opencv with all libs inside
    return 0; 
}

@LBerger yes it builds it without errors but it doesn`t show the image at all, it opens the window and stays with gray backroung and no image is loaded inside, the image is on the same folder with my executable so it has something to ... (more)

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by LBerger
close date 2016-12-08 15:22:19.915445

Comments

1

Can you insert in your post command line and link line (in project properties )

LBerger gravatar imageLBerger ( 2016-12-05 03:44:36 -0500 )edit

@LBerger i updated my quesion with your request. I can provide also the unresolved external on "opencv_highgui2413.lib(cap_vfw.obj)" library which functions had the errors on

Nocs gravatar imageNocs ( 2016-12-05 08:41:20 -0500 )edit

It doesn`t compile with any version i downloaded, it always pops up the same unresolved external about (cap_vfw.obj) inside the opencv_highgui2413.lib ... any suggestion ?

Nocs gravatar imageNocs ( 2016-12-05 20:00:38 -0500 )edit

in your cmd line you have /MACHINE:X86. is Opencv 2.4.13 in x86?

LBerger gravatar imageLBerger ( 2016-12-06 01:32:13 -0500 )edit

yes thats for sure, i havent test the debug static though, cause i need to implement it after my tests to a solution that need to be build in release mode, but i will try the debug later just to see if it has something to do with the release option instead of the debug.

Nocs gravatar imageNocs ( 2016-12-06 04:33:41 -0500 )edit

I have tested also the staticlib in debug mode with the debug .libs also has the same 20 errors refering to the openv_highgui2413d.lib(cap_vfw.obj), it has something to do with the staticlib and this lib. Do i need to use included headers or any other files from opencv inside my project except the libs ?

Nocs gravatar imageNocs ( 2016-12-06 17:42:55 -0500 )edit

Can you give full path to lib in your link command line?

Make a small program like main()[Mat x; return;} and link with core and imgproc. when it works add in source VideoCapture and libs...

LBerger gravatar imageLBerger ( 2016-12-07 01:46:00 -0500 )edit

@LBerger. yes if i remove the VideoCapture it builds in static with Mat and all the libs included with no errors. When i enter the Videocapture cap(CV_CAP_ANY); it pops up all the 20 errors. Do i need to define or redefine anything else from higigui.hpp into my cpp file in order to work with static mode ? The problem seems to be in the highgui.lib when in static build

Nocs gravatar imageNocs ( 2016-12-07 09:35:14 -0500 )edit

try something like this

Mat x=imread("lena.jpg");
imshow("image",x);

can you give full error messages

LBerger gravatar imageLBerger ( 2016-12-07 11:27:50 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2016-12-08 15:17:12 -0500

Nocs gravatar image

updated 2016-12-08 15:23:54 -0500

The solution to this problem if anyone encounter it again is this post as LBerger very well pointed to
http://stackoverflow.com/questions/16...

You need to include the Vfw32.lib inside your project along with all the opencv static lib files and includes. The Vfw32.lib is not inside the Opencv libraries but it is in windows visual studio

The solved answered goes to LBerger ^.^ Thanks LBerger

edit flag offensive delete link more
0

answered 2016-12-05 12:17:07 -0500

LBerger gravatar image

With my configuration opencv 3.1-dev and opencv contrib using VS 2015 windows 10 64 bits and cmake to generate project :

/OUT:"C:\Users\Laurent.PC-LAURENT-VISI\Documents\Visual Studio 2013\MachineLearning\build\Release\mlOCV.exe" /MANIFEST /NXCOMPAT /PDB:"C:/Users/Laurent.PC-LAURENT-VISI/Documents/Visual Studio 2013/MachineLearning/build/Release/mlOCV.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_calib3d310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_core310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_features2d310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_flann310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_highgui310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_imgcodecs310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_imgproc310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_ml310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_objdetect310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_photo310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_shape310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_stitching310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_superres310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_video310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_videoio310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_videostab310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_aruco310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_bgsegm310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_bioinspired310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_ccalib310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_datasets310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_dnn310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_dpm310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_face310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_fuzzy310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_line_descriptor310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_optflow310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_phase_unwrapping310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_plot310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_reg310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_rgbd310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_saliency310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_sfm310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_stereo310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_structured_light310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_surface_matching310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_text310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_tracking310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_xfeatures2d310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_ximgproc310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_xobjdetect310.lib" "G:\Lib\opencv\static2015\lib\Release\opencv_xphoto310.lib" "G:\Lib\opencv\static2015\3rdparty\lib\Release\libprotobuf.lib" "G:\Lib\OpenBLAS\build\lib\libopenblas.lib" "G:\Lib\opencv\static2015\lib\Release\correspondence.lib" "G:\Lib\opencv\static2015\lib\Release\simple_pipeline.lib" "G:\Lib\opencv\static2015\lib\Release\multiview.lib" "G:\Lib\opencv\static2015\lib\Release\numeric.lib" "comctl32.lib" "setupapi.lib" "ws2_32.lib" "G:\Lib\opencv\static2015\3rdparty\lib\Release\libjpeg.lib" "G:\Lib\opencv\static2015\3rdparty\lib\Release\libwebp.lib" "G:\Lib\opencv\static2015\3rdparty\lib\Release\libpng.lib" "G:\Lib\opencv\static2015\3rdparty\lib\Release\libtiff.lib" "G:\Lib ...
(more)
edit flag offensive delete link more

Comments

Thanks for the response i am on my way for testing it i will let you know, I tried with every possible option in the Linker options but cant make it work :/... i am downloading also the 3.1 version to check if it can work with it in static

Nocs gravatar imageNocs ( 2016-12-05 13:09:26 -0500 )edit

please check if you have Vfw32.lib

LBerger gravatar imageLBerger ( 2016-12-08 09:50:54 -0500 )edit

Thanks for the response, i have searched and i dont have any Vfw32.lib inside the opencv.2.4.13 prebuilted. I found the cap_vfw.cpp i added to the project which was in the source folder not in the build i added also the precomp.hpp which needs to be with it and again it pops the same errors exactly. Is it something with imcombatibility with my system or i am doing something wrong cause i think it has to do something with static lib since its ok with dynamic libs :/ I use the prebuild latest version 2.4.13 what else can i check after all this ?

Nocs gravatar imageNocs ( 2016-12-08 11:51:55 -0500 )edit
1

Have you read this post?

LBerger gravatar imageLBerger ( 2016-12-08 11:57:04 -0500 )edit

Holly crap, you are right, the Vfw32.lib is in the mvs2013 and i was searching for it inside opencv :s Thanks yes that solved it

Nocs gravatar imageNocs ( 2016-12-08 15:15:33 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-04 19:09:50 -0500

Seen: 343 times

Last updated: Dec 08 '16