Project

General

Profile

First dynamic build question

Added by Mikayel Egibyan almost 7 years ago

Hi,

I want to integrate exiv2 to my project.

{Windows 8.1 x64, VS2013} Professional, DM

The integration process is the following:

1. I mention the files location
2. I take the required .dll files
3. I look into corresponding .lib files and parse everything to the location I need.

As in case with exiv2 I take the exiv2, libexpat, zlib1 {.lib, .dll} for x64 release build. I can't take msvc{p, r}90d since there are no .lib files for those two.
The build goes fine and it recognize the #include <exiv2/exiv2.hpp> fine. I have initialization of libraries done separately (from working application I include the library, this works fine with other libraries).

Once I call
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fileName);
thought the build goes fine, the library initialization fails, with no error. b.t.w having in the code Exiv2::Image::AutoPtr image; doesn't brake the initialization.

Any ideas?

Thanks,
Mikayel


Replies (9)

RE: First dynamic build question - Added by Mikayel Egibyan almost 7 years ago

I fixed it. The issue was in the wrong order of loading the dependencies.

RE: First dynamic build question - Added by Abhinav Badola almost 7 years ago

Mikayel Egibyan wrote:

I fixed it. The issue was in the wrong order of loading the dependencies.

Hi Mikayel,

It is great that you were able to solve this problem. Cheers..!!

I just wished if you could share your findings with us.
(I mean the right order of loading the binaries in Windows environment.)

Maybe we should add such topics in our Wiki under the Sub-heading Development Topics. (http://dev.exiv2.org/projects/exiv2/wiki)
And it would be great if your information and findings could help the other Exiv2 users/developers on how to get started with Exiv2 for their own projects.

I understand that I am asking you to take some time to help us improve our support, but it would really be great if you do.

We would really appreciate and share your findings and I am pretty sure a lot of other budding developers will also benefit at large from your guidance. :)

Eagerly looking forward for your positive response. :)

RE: First dynamic build question - Added by Robin Mills almost 7 years ago

Well done, Mikayel

Like Abhinav, I'm very pleased that you've been able to fix this for yourself. I usually recommend:

  1. add your code code to a sample applications (such as exifprint.exe) and get the code building and running from there.
    Of course - your program will be called exifprint.exe - however you'll be very confident that your code works!
  2. copy <exiv2dir>/msvc2005/exifprint to <exiv2dir>/msvc2005/yourprojectname and get that to build and run.
    By using <exiv2dir>/msvc2005/exifprint as a template, you can build 32/64 dll/static debug/release "out of the box".
    By using <exiv2dir>/msvc2005/exifprint as a template, your include path, dependent libraries and link order are already set for you.
    Your program will now be called yourprojectname.exe.
    Revert your changes to <exiv2dir>/msvc2005/exifprint
  3. move <exiv2dir>/msvc2005/yourprojectname to the desired destination in your buildtree.
  4. It's a good idea for your buildtree to reference the <exiv2dir>/msvc2005 instead of copying libs and dlls.
    When you reference <exiv2dir>, you can update <exiv2dir> occasionally and rebuild with little effort.

Of course, there's more than one way to do everything in software and if you're happy with your solution that is fine.

I have updated <exiv2dir>/msvc2005/ReadMe.txt to include the advice above. r3600 http://dev.exiv2.org/projects/exiv2/repository/revisions/3600

Robin

RE: First dynamic build question - Added by Mikayel Egibyan almost 7 years ago

The point was following that in VS2013 you need to use msvs{p|r}120.dll instead of msvs{p|r}90.dll. Also the right order to load the libraries is following:
"msvcp120", "msvcr120", "libexpat", "zlib1", "exiv2". I am not sure about xmpsdk.lib, since it's a static library.

Mikayel

RE: First dynamic build question - Added by Robin Mills almost 7 years ago

I've added the following additional information to msvc2005/ReadMe.txt r3601 and r3602

The correct include paths and compiler options are revealed in Visual Studio, by examining exifprint/Properties/C++/Command Line:

/Od /I "C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\../include" 
/I "C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\../include/exiv2" 
/I "C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\../xmpsdk/include" 
/I "C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\../../expat/lib" 
/I "C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\../../zlib" 
/I "C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\/../../curl/include" 
/I "C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\/../../libssh/include" 
/I "C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\xssl/Win32/Release/include" 
/D "WIN32" /D "_NDEBUG" /D "_CONSOLE" /D "BUILD_GETOPT" /D "EXV_HAVE_DLL" /D "_MBCS" 
/Gm /EHsc /MD /Fo"build/x64/ReleaseDLL\\" /Fd"build/x64/ReleaseDLL\vc80.pdb" 
/FR"build/x64/ReleaseDLL\\" /W3 /nologo /c /Zi /TP /errorReport:prompt
The correct library link order is revealed in Visual Studio, by examining exifprint/Properties/Linker/Command Line:
/OUT:"C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\bin/x64/ReleaseDLL\exifprint.exe" 
/INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"build/x64/ReleaseDLL\exifprint.exe.intermediate.manifest" 
/SUBSYSTEM:CONSOLE /MACHINE:X64 /ERRORREPORT:PROMPT kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
"..\bin\x64\releasedll\libexiv2.lib" "..\bin\x64\releasedll\xmpsdk.lib" 
"..\bin\x64\releasedll\libexpat.lib" "..\bin\x64\releasedll\zlib1.lib"
I don't believe you have to explicitly link msvc{r|p}XXX as they are linked automatically by the version of Visual Studio.
800=Visual Studio 2005, 900=2008, 100=2010, 110=2012, 120=2013.

I added a couple of tools in <exiv2dir>/msvc2005/tools/bin/depends32.exe and depends64.exe which reveal the dynamic libraries required to load a binary:

C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\bin\x64\releasedll>depends64 exiv2.exe
libexpat.dll
PSAPI.DLL
NSI.dll
API-MS-Win-Core-DelayLoad-L1-1-0.dll
API-MS-Win-Core-Interlocked-L1-1-0.dll
RPCRT4.dll
API-MS-Win-Core-LocalRegistry-L1-1-0.dll
msvcrt.dll
WS2_32.dll
zlib1.dll
API-MS-Win-Security-Base-L1-1-0.dll
API-MS-Win-Core-Profile-L1-1-0.dll
API-MS-Win-Core-Util-L1-1-0.dll
API-MS-Win-Core-Fibers-L1-1-0.dll
API-MS-Win-Core-ErrorHandling-L1-1-0.dll
API-MS-Win-Core-Debug-L1-1-0.dll
API-MS-Win-Core-String-L1-1-0.dll
API-MS-Win-Core-ProcessEnvironment-L1-1-0.dll
API-MS-Win-Core-Localization-L1-1-0.dll
API-MS-Win-Core-SysInfo-L1-1-0.dll
API-MS-Win-Core-Misc-L1-1-0.dll
API-MS-Win-Core-NamedPipe-L1-1-0.dll
API-MS-Win-Core-LibraryLoader-L1-1-0.dll
API-MS-Win-Core-ThreadPool-L1-1-0.dll
API-MS-Win-Core-IO-L1-1-0.dll
API-MS-Win-Core-File-L1-1-0.dll
API-MS-Win-Core-Synch-L1-1-0.dll
API-MS-Win-Core-Handle-L1-1-0.dll
API-MS-Win-Core-Memory-L1-1-0.dll
API-MS-Win-Core-Heap-L1-1-0.dll
API-MS-Win-Core-ProcessThreads-L1-1-0.dll
KERNELBASE.dll
ntdll.dll
API-MS-Win-Core-RtlSupport-L1-1-0.dll
KERNEL32.dll
libexiv2.dll
  Not found: MSVCR80.dll
  Not found: MSVCP80.dll
exiv2.exe
  Not found: MSVCR80.dll
  Not found: MSVCP80.dll

C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\bin\x64\releasedll>
You can inspect build information using exiv2 -v -V (verbose version):
C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\bin\x64\releasedll>exiv2 -v -V
exiv2 0.24 001800 (64 bit build)
Copyright (C) 2004-2013 Andreas Huggel.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
exiv2=0.24.0
platform=windows
compiler=MSVC
bits=64
dll=1
debug=0
version=8.00
date=Feb  1 2015
time=21:45:35
svn=3592
ssh=0
curl==0
id=$Id: version.cpp 3564 2015-01-11 21:38:40Z robinwmills $
executable=C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\bin\x64\releasedll\exiv2.exe
library=C:\Windows\SYSTEM32\ntdll.dll
library=C:\Windows\system32\kernel32.dll
library=C:\Windows\system32\KERNELBASE.dll
library=C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\bin\x64\releasedll\libexiv2.dll
library=C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\bin\x64\releasedll\zlib1.dll
library=C:\Windows\WinSxS\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6195_none_88e41e092fab0294\MSVCR80.dl
library=C:\Windows\system32\msvcrt.dll
library=C:\Windows\system32\WS2_32.dll
library=C:\Windows\system32\RPCRT4.dll
library=C:\Windows\system32\NSI.dll
library=C:\Windows\WinSxS\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6195_none_88e41e092fab0294\MSVCP80.dl
library=C:\Windows\system32\PSAPI.DLL
library=C:\cygwin64\home\rmills\gnu\exiv2\video-write\msvc2005\bin\x64\releasedll\libexpat.dll
have_regex=0
have_strerror_r=0
have_gmtime_r=0
have_inttypes=0
have_libintl=0
have_lensdata=1
have_iconv=0
have_memory=0
have_memset=0
have_lstat=0
have_stdbool=0
have_stdint=0
have_stdlib=0
have_strlib=0
have_strchr=0
have_strerror=0
have_strerror_r=0
have_strings_h=0
have_strtol=0
have_mmap=0
have_munmap=0
have_sys_stat=0
have_timegm=0
have_unistd_h=0
have_sys_mman=0
have_libz=1
have_xmptoolkit=1
have_bool=0
have_strings=0
have_sys_types=0
have_unistd=0
The keys library=path are based on the actual libraries loaded in memory by exiv2.exe. The output of exiv2.exe -v -V is used by our test suite to verify that we are using the correct libraries and not some other bandits which happen to reside on the host machine.

Robin

RE: First dynamic build question - Added by Maciej Witkowski over 5 years ago

Hello,
I got exactly same problem:

Mikayel Egibyan wrote:

The integration process is the following:

1. I mention the files location
2. I take the required .dll files
3. I look into corresponding .lib files and parse everything to the location I need.

As in case with exiv2 I take the exiv2, libexpat, zlib1 {.lib, .dll} for x64 release build. I can't take msvc{p, r}90d since there are no .lib files for those two.
The build goes fine and it recognize the #include <exiv2/exiv2.hpp> fine. I have initialization of libraries done separately (from working application I include the library, this works fine with other libraries).

Once I call
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fileName);
thought the build goes fine, the library initialization fails, with no error. b.t.w having in the code Exiv2::Image::AutoPtr image; doesn't brake the initialization.

My configuration:
Windows 7 Professional, x64, VS2013 Professional,libraries built under VS2012, project with QT.

Additional Include Directories:
C:\gnu\trunk\include\exiv2

Additional Library Directories(Debug configuration):
C:/gnu/trunk/msvc2005/bin/x64/DebugDLL

Additional Dependencies(Debug configuration):
C:\gnu\trunk\msvc2005\bin\x64\DebugDLL\libexiv2.lib
C:\gnu\trunk\msvc2005\bin\x64\DebugDLL\xmpsdk.lib
C:\gnu\trunk\msvc2005\bin\x64\DebugDLL\libexpat.lib
C:\gnu\trunk\msvc2005\bin\x64\DebugDLL\zlib1.lib

Both .lib and .dll of libexiv2 are present in following location:

On start of debugging i got following system error: "The program can't start because libexiv2.dll is missing from your computer. Try reinstalling the program to fix the problem."
Any ideas how to fix this problem?

Thanks in advance,
Maciej

RE: First dynamic build question - Added by Robin Mills over 5 years ago

You may have to set the "Working Directory" in Visual Studio. Windows searches the current directory, and then each directory on your PATH.

Is your executable called xmpsample.exe ? It should be OK. BUT if your executable is called foo.exe, it should be built into the same directory as libexiv2.dll and it'll run.

Use the DOS prompt to navigate to c:\gnu\trun\msvc2005\bin\x86\DebugDLL and execute your program from there. Also try debugging one of the samples such as exifprint. Set the debugger argument to http://clanmills.com/Stonehenge.jpg

There's very little wrong here. Plug away for a few more minutes and you will get this to work.

RE: First dynamic build question - Added by Robin Mills over 5 years ago

Another thought. I don't believe you can build the libraries with VS2012 and your application with VS2013. You should build everything with one version of Visual Studio.

RE: First dynamic build question - Added by Maciej Witkowski over 5 years ago

Robin Mills wrote:

BUT if your executable is called foo.exe, it should be built into the same directory as libexiv2.dll and it'll run.

That was the problem, thanks a lot.

Robin Mills wrote:

Another thought. I don't believe you can build the libraries with VS2012 and your application with VS2013. You should build everything with one version of Visual Studio.

Looks like some parts are working, some aren't, luckily the most important part for me is working.

    (1-9/9)