compiling functions using opencv library to 64bit dll

Hi,

I wrote some simple routines using opencv 2.4.4 and i had no problems to run the code. The development environment is MS Visual Studio 2010.
My original aim is to build a 64bit dll file which I can use from IDL (interactive data language). Building simple dlls WITHOUT the opencv stuff works well and I can call these functions from IDL. By using opencv classes the build succeeds without any problems. But when I try to use the dll I get an error:
"Not a valid WIN32 application".

So what I did is to check all properties of my project, especially:

Configuration Properties:
Configuration Type: Dynamic Library (.dll)
Use of MFC: Use MFC in a Static Library

C/C++:
Preprocessor: added WIN64
Code Generation: Multi threaded (/MT)

Command Line:
/I"C:\Program Files (x86)\opencv\build\include" /I"C:\Program Files\Exelis\IDL82\external\include" /I"C:\Program Files (x86)\opencv\include" /Zi /nologo /W3 /WX- /O2 /Oi /GL /D "WIN32" /D "WIN64" /D "CV_DLL" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "HARALICK_IDL_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fp"x64\Release\haralick_idl.pch" /Fa"x64\Release\" /Fo"x64\Release\" /Fd"x64\Release\vc100.pdb" /Gd /errorReport:queue

Linker:
Advanced: Target Machine : MachineX64 (/MACHINE:X64)

Command line:
/OUT:"D:\Prozessorframework\Visual Studio 2010\Projects\haralick_idl\x64\Release\haralick_idl.dll" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Program Files (x86)\opencv\build\x64\vc10\lib" /DLL "opencv_core244.lib" "opencv_imgproc244.lib" "opencv_highgui244.lib" "opencv_ml244.lib" "opencv_video244.lib" "opencv_legacy244.lib" /MANIFEST /ManifestFile:"x64\Release\haralick_idl.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\Prozessorframework\Visual Studio 2010\Projects\haralick_idl\x64\Release\haralick_idl.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /PGD:"D:\Prozessorframework\Visual Studio 2010\Projects\haralick_idl\x64\Release\haralick_idl.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /ERRORREPORT:QUEUE

dumpbin tells me that everything is ok with my dll...
The only thing I realized with dumpbin /dependents is, that there is still an external dependency to opencv_core244.dll (and others if I use the full code). So linking to a static dll seems not to work?

Thanks in advance,
Jens
You need to build OpenCV as a static library too if you want to get rid of OpenCV DLLs depedency.
I found static libs in my opencv folder (opencv\build\x64\vc10\staticlib). But when I try to use them I get the following linker errors:

opencv_core244.lib(persistence.obj) : error LNK2001: unresolved external symbol gzeof
1>opencv_core244.lib(persistence.obj) : error LNK2001: unresolved external symbol gzclose
1>opencv_core244.lib(persistence.obj) : error LNK2001: unresolved external symbol gzrewind
1>opencv_core244.lib(persistence.obj) : error LNK2001: unresolved external symbol gzgets
1>opencv_core244.lib(persistence.obj) : error LNK2001: unresolved external symbol gzputs
1>opencv_core244.lib(persistence.obj) : error LNK2001: unresolved external symbol gzopen
1>D:\Prozessorframework\Visual Studio 2010\Projects\haralick_idl\x64\Release\haralick_idl.dll : fatal error LNK1120: 6 unresolved externals
After building opencv as a static library I can build my dll.
BUT: The external dependency to opencv_core244.dll still remains and I cannot use it from IDL...
Is there any linker option I forgot to set?
These errors comes from zlib library, which OpenCV uses internally. You need to link against zlib too.

After correct building OpenCV statically there should be no depedency on any OpenCV DLLs, are you sure you feed newer opencv .lib files to linker input ??? It should be huge in size.
Didn't knew that I have to add the opencv projects that I use in my functions to the solution. After adding these and defining the dependencies in the property page everything works.
Thanks!
Topic archived. No new replies allowed.