Project

General

Profile

compiling under MSVC

Added by Arnold Wiegert over 5 years ago

After looking over the wiki and downloading the code, I am a bit confused.
The wiki at: http://dev.exiv2.org/projects/exiv2/wiki/Building_on_Windows_Using_Visual_Studio_Express_2012 talks about a directory trunk/msvc2012, but I cannot find such a directory in the tarball I downloaded, nor in the code I got via svn.

Do I really have to install MSVC 2005 ot 2008??


Replies (13)

RE: compiling under MSVC - Added by Robin Mills over 5 years ago

Good News. That's an error in the documentation.

You can build the projects in msvc2005 with Visual Studio 2005/8/10/12/13/15 Our build server builds them all every night. We support the works { Dynamic|Static x86|x64 Debug|Release }. msvc2003/exiv2.sln will build x86 with Visual Studio 2003/2005/2008 { Dynamic|Static Debug|Release }

So ... bottom line: Open msvc2005/exiv2.sln in Visual Studio 2012 and you should be able to build. The convertor takes a remarkably long time to run (1 or 2 minutes), however you only have to do that once.

Explanation:

At the end of the v0.24 release cycle, I discovered that the Visual Studio 2012 project convertor wasn't working correctly on msvc2005/exiv2.sln. I quickly added the msvc2012 tree to provide Visual Studio 2012 support for v0.24. However I fixed msvc2005/exiv2.sln early in v0.25 development, removed the msvc2012 tree, and forgot to update the Wiki Page about VS2012.

Support for Visual Studio 2013 and 2015 was added to the trunk for v0.26 (expected to ship in July 2016).

RE: compiling under MSVC - Added by Arnold Wiegert over 5 years ago

Thank you for the good news.
I have been able to do a compile under MSVC 2013 Express.
Now I'll have to worry about integrating it with the app.

RE: compiling under MSVC - Added by Raphael Attie about 5 years ago

In Windows 10, I've started to work under VS 2015 too, in addition to the mac/clang/clion build. So I'm interested to see that working in VS 2015. At the moment, here's what I did:

1) Get the exiv2libs from http://clanmills.com/files/exiv2libs.zip , put the unzipped files into c:\exiv2libs
2) Based on the MSVC 2003 documentation at step 2- and 3-, having used step 1) above, I thus skip the step of building expat and zlib.
3) With exiv2 files in c:\exiv2, I execute the msvc2003/copylibs.bat. Can't see anything, except the terminal showing for a fraction of a second and so can't see what it actually did.
4) I open the sln file in exiv2/msvc2005/exiv2.sln
5) VS 2015 tells me I have to upgrade the files. After a few minutes, I see a report with a failed upgrade for the file exiv2.vsprops, only warnings for the rest
6) Build/batch -> build/select all -> build , this fails.

Robin is sending updated instruction on this as I write these lines. I will report back here the corrected steps for anyone interested in building with VS 2015.

RE: compiling under MSVC - Added by Robin Mills about 5 years ago

The copylibs.bat file is of very little importance. It's used by the buildserver to install the library code every time it builds (because I have no idea where Jenkins actually performs the build!).

The important matter is to arrange the code as follows:

1.2  Install zlib and expat sources.
     I use the directory c:\gnu\exiv2 for this purpose, however the name isn't important.

     c:\gnu\exiv2>dir
     Directory of c:\gnu\exiv2
     2010-12-05  10:05     <DIR>    trunk     <--- this tree
     2012-05-04  23:35     <DIR>    expat     <--- "vanilla" expat   2.1.0  source tree
     2012-05-04  23:35     <DIR>    zlib      <--- "vanilla" zlib    1.2.7  source tree
     2012-05-04  23:35     <DIR>    curl      <--- "vanilla" curl    7.39.0 source tree
     2012-05-04  23:35     <DIR>    openssl   <--- "vanilla" openssl 1.0.1j source tree
     2012-05-04  23:35     <DIR>    libssh    <--- "vanilla" libssh  0.5.5  source tree
     c:\gnu\exiv2>
You can obtain the library code from the internet. I've put a copy here: http://clanmills.com/files/exiv2libs.zip

The libraries curl, openssl, libssh are only used when building the optional webready feature.

The Visual Studio convertor reports loads of warnings which can be ignored.

RE: compiling under MSVC - Added by Raphael Attie about 5 years ago

Ok, thanks for the advise. I realised also that copylibs.bat assumes we downloaded exiv2 source from svn repo while I downloaded the .tar.gz archive. So I was missing the "trunk" directory on top of what you otherwise get by downloading the .tar.gz archive, which i did. So the ../../ was putting the files one directory above where things should have been. Regardless, it's clearer now that I know where to copy things relative to the trunk directory.

RE: compiling under MSVC - Added by Robin Mills about 5 years ago

Thank you for looking into this. I've discovered there are several things "wobbling" here. "wobbling" is "well it works on my machine!".

I've reviewed everything I can and created a brand-new edition of http://clanmills.com/files/exiv2libs.zip (and http://clanmills.com/files/exiv2libs.tar.gz) and testing then everywhere. Getting to the very end of a software project is hard work. It's even harder without a test engineer to find stuff like this!

RE: compiling under MSVC - Added by Raphael Attie about 5 years ago

It compiled without apparent trouble in VS 2015, but I have a linker error when using libexiv2 in Qt Creator on Windows.

Error is LNK1104: cannot open file 'exiv2.lib'

yet the LIBS set the path as:
LIBS += -LC:\dev\exiv2\Win32\Debug - lexiv2

and the file "libexiv2.lib" is there.

I am really not a Windows expert, even less on VS 2015... To compile this, I was in "Debug" and "Win32" on the top scroll down menus.

Any idea ?

RE: compiling under MSVC - Added by Robin Mills about 5 years ago

Question 1: Which version of Qt are you using? You have to match the version of Exiv2 and Qt.

If you're using Qt/MinGW, you'll have to build and link Exiv2 build on MinGW. Good News: I build it every night and you can fetch the build from the buildserver. I can help you build Exiv2 for MinGW.

If you're using Qt/VS2015 your build "should" work. I'm totally confident that it will work. There is a Qt sample program in contrib/Qt I recommend you get try to get that working. Here are the build notes: http://clanmills.com/exiv2/qt.shtml

There have been several discussions over the years on Redmine about Qt. Try the search box. If you're stuck at the end of the day, I'll investigate this evening.

RE: compiling under MSVC - Added by Robin Mills about 5 years ago

You'll probably have to "decorate" your path. Those Unix things (like QMake) seldom understand DOS filenames such as c:\dev\exiv2\Win32\Debug as they treat the \ as an escape. So they see the string c:\dev\exiv2\Win32\Debug as c:devexiv2Win32Debug.

Try doubling up the \ as \\ Something like: c:\\dev\\exiv2\\Win32\\Debug

Here's a qmake file that has worked for me and uses qmake magic $$quote :

TARGET    = exiv2
QT       += core
QT       -= gui

# http://stackoverflow.com/questions/1011197/qt-static-linking-and-deployment
CONFIG   += static
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE  = app

win32 {
    # http://www.formortals.com/build-qt-static-small-microsoft-intel-gcc-compiler/
    QMAKE_CFLAGS_RELEASE =  /D "WIN32" /D "_NDEBUG" /D "_CONSOLE" /D "BUILD_GETOPT" /D "_MBCS" /FD /EHsc /MD /W3 /WX

    INCLUDEPATH  += $$quote(C:/gnu.test/exiv2/msvc64/include)
    LIBS         += $$quote(C:/gnu.test/exiv2/msvc64/exiv2lib/Win32/release/exiv2s.lib)
    LIBS         += $$quote(C:/gnu.test/exiv2/msvc64/xmpsdk/win32/release/xmpsdk.lib)
    LIBS         += $$quote(C:/gnu.test/exiv2/msvc64/expat/Win32/Release/libexpat.lib)
    LIBS         += $$quote(C:/gnu.test/exiv2/msvc64/zlib/Win32/Release/zlib1.lib)
}

SOURCES += $$quote(C:/gnu.test/exiv2/src/exiv2.cpp) \
           $$quote(C:/gnu.test/exiv2/src/actions.cpp)      \
           $$quote(C:/gnu.test/exiv2/src/getopt_win32.c)   \
           $$quote(C:/gnu.test/exiv2/src/localtime.c)      \
           $$quote(C:/gnu.test/exiv2/src/utils.cpp)

RE: compiling under MSVC - Added by Raphael Attie about 5 years ago

I found the problem. I was using Qt 5.7. For people used to mac like me, I'd like to spare hours of head-scratching to other poor souls used to Qt on mac and not windows.
The problem is due to a difference between the linking vocable between mac (unix?) and windows.

Simply put, you just have to write
LIBS += blah -llibexiv2
and not
LIBS += blah -lexiv2

So, Qt/windows here need the full name of the file, in addition to the -l

Now everything is working.

Thanks

RE: compiling under MSVC - Added by Raphael Attie about 5 years ago

cross-fire, i posted the above while you posted yours. I see that you used the $$quote. I didn't know that way.

With Qt, for include and link paths, you can also simply use quotes " " , which allows also to use blank space.

For example, to link something installed in Program Files:
LIBS += -L"C:\Program Files\blah1\blah2\" -lmylib

RE: compiling under MSVC - Added by Robin Mills about 5 years ago

Whatever way works, is the way that it works. At least you know how NASA put men on the Moon. They didn't have software to help them. They would have landed on Mars by mistake!

RE: compiling under MSVC - Added by Robin Mills about 5 years ago

I have investigated and fixed the convertor error message concerning exiv2.vsprops in Visual Studio 2015. #1250

    (1-13/13)