How to fix LNK2019 error while building.
Added by Mikayel Egibyan almost 7 years ago
Hi,
I have asked this question previously and fixed it myself by that time. This time the method I did before, and others recommendation didn't work.
The difference from the previous try is that now I get the error just while building.
I have only:
#include <exiv2/exiv2.hpp>
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open("C:\\Users\\User\\Desktop\\IMG_4702.jpg");
in my code. (Having only #include <exiv2/exiv2.hpp>
causes no problem).
Process:
I have x64 Windows 8.1, VS2013. I have build the exiv2, libexpat and zlib1. As a result I collected exiv2{.dll|.lib}, libexpat{.dll|.lib}, zlib1{.dll|.lib}, xmpsdk.lib, msvc{p|r}120.dll in one folder with all the sources from ...exiv2/src. I do an exeternal (not from VS2013) "/O2 /EHsc /MD /D WIN_ENV=1 build, setting in the compiler options the libraries to be everything but msvc{p|r}120.dll, the linker options are {"/MACHINE:x64"}, the include directory and the library directory is the directory where I have the coppied staff. In a result, I copy everything generated (exiv2.dll, libexpat.dll, msvcp12.dll, msvcr120.dll, xmpsdk.lib, zlib1.dll, myProject.dll) to my build location.
Any ideas???
Thanks!
Replies (3)
RE: How to fix LNK2019 error while building. - Added by Mikayel Egibyan almost 7 years ago
Here is the full error output if it helps:
@SA?AV?$auto_ptr@VImage@Exiv2@
main.obj : error LNK2019: unresolved external symbol "public: static class std::auto_ptr<class Exiv2::Image> __cdecl Exiv2::ImageFactory::open(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?open@ImageFactory@Exiv2@std
@AEBV?$basic_string@DU?$char_traits@D@std@V?$allocator@D@2
@4@Z) referenced in function ErrorDescription
@SA?AV?$auto_ptr@VImage@Exiv2@
C:\Users\User\WolframWorkspaces\Base\Exiv2Tools\build\Exiv2Tools\LibraryResources\Windows-x86-64\Working-user-pc-29060-23644-1\Exiv2Tools.dll : fatal error LNK1120: 1 unresolved externals
CreateLibrary::cmperr: Compile error: main.obj : error LNK2019: unresolved external symbol "public: static class std::auto_ptr<class Exiv2::Image> __cdecl Exiv2::ImageFactory::open(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?open@ImageFactory@Exiv2@std
@AEBV?$basic_string@DU?$char_traits@D@std@V?$allocator@D@2
@4@Z) referenced in function ErrorDescription
CreateLibrary::cmperr: Compile error: C:\Users\User\WolframWorkspaces\Base\myProject\build\myProject\LibraryResources\Windows-x86-64\Working-user-pc-29060-23644-1\myProject.dll : fatal error LNK1120: 1 unresolved externals
RE: How to fix LNK2019 error while building. - Added by Robin Mills almost 7 years ago
Please post your code and project/solution/code files and I will investigate.
RE: How to fix LNK2019 error while building. - Added by Robin Mills over 6 years ago
I've copied your code above, and added some code from samples/exifprint.exe to generate output.
// Mikael.cpp #include <exiv2/exiv2.hpp> #include <iostream> int main(int argc,const char** argv) { if ( argc < 2 ) { std::cout << "syntax: " << argv[0] << " image-path" << std::endl; return 1; } Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]); if ( !image.get() ) { std::cout << "unable to open " << argv[1] << std::endl; return 2; } Exiv2::ExifData &exifData = image->exifData(); image->readMetadata(); if (exifData.empty()) { std::cout << "no exif data in " << argv[1] << std::endl; return 3; } std::cout << "-- begin -- " << argv[0] << " " << argv[1] << " -- begin --" << std::endl; Exiv2::ExifData::const_iterator end = exifData.end(); for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) { const char* tn = i->typeName(); std::cout << std::setw(44) << std::setfill(' ') << std::left << i->key() << " " << "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << i->tag() << " " << std::setw(9) << std::setfill(' ') << std::left << (tn ? tn : "Unknown") << " " << std::dec << std::setw(3) << std::setfill(' ') << std::right << i->count() << " " << std::dec << i->value() << "\n"; } std::cout << "--- end --- " << argv[0] << " " << argv[1] << " --- end ---" << std::endl; return 0; }I've compiled, linked and run this with the following three batch files: c.bat l.bat and r.bat (compile, link and run)
cl /c Mikael.cpp /Od /I "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\../include" /I "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\../include/exiv2" /I "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\../xmpsdk/include" /I "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\../../expat/lib" /I "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\../../zlib" /I "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\/../../curl/include" /I "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\/../../libssh/include" /I "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\openssl/Win32/ReleaseDLL/include" /D "WIN32" /D "_NDEBUG" /D "_CONSOLE" /D "BUILD_GETOPT" /D "EXV_HAVE_DLL" /D "_MBCS" /Gm /EHsc /MD /W3 /nologo /Zi /TP /errorReport:prompt
@echo off link /OUT:"Mikael.exe" /INCREMENTAL:NO /NOLOGO /SUBSYSTEM:CONSOLE /MACHINE:X86 /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 "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\bin\win32\releasedll\xmpsdk.lib" "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\bin\win32\releasedll\zlib1.lib" "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\bin\win32\releasedll\libexiv2.lib" "C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\bin\win32\releasedll\libexpat.lib" Mikael.obj
@echo off set oldpath=%PATH% set PATH=C:\cygwin64\home\rmills\gnu\exiv2\trunk\msvc2005\bin\Win32\ReleaseDLL;%PATH% Mikael.exe R.jpg exifprint.exe R.jpg set PATH=%oldpath%And here's the output:
c:\temp\Mikael>r.bat -- begin -- Mikael.exe R.jpg -- begin -- Exif.Image.Orientation 0x0112 Short 1 1 Exif.Image.XResolution 0x011a Rational 1 72/1 Exif.Image.YResolution 0x011b Rational 1 72/1 Exif.Image.ResolutionUnit 0x0128 Short 1 2 Exif.Image.Software 0x0131 Ascii 29 Adobe Photoshop CS Macintosh Exif.Image.DateTime 0x0132 Ascii 20 2007:01:28 11:28:40 Exif.Image.ExifTag 0x8769 Long 1 164 Exif.Photo.ColorSpace 0xa001 Short 1 65535 Exif.Photo.PixelXDimension 0xa002 Long 1 2160 Exif.Photo.PixelYDimension 0xa003 Long 1 345 Exif.Thumbnail.Compression 0x0103 Short 1 6 Exif.Thumbnail.XResolution 0x011a Rational 1 72/1 Exif.Thumbnail.YResolution 0x011b Rational 1 72/1 Exif.Thumbnail.ResolutionUnit 0x0128 Short 1 2 Exif.Thumbnail.JPEGInterchangeFormat 0x0201 Long 1 302 Exif.Thumbnail.JPEGInterchangeFormatLength 0x0202 Long 1 1688 --- end --- Mikael.exe R.jpg --- end --- Exif.Image.Orientation 0x0112 Short 1 1 Exif.Image.XResolution 0x011a Rational 1 72/1 Exif.Image.YResolution 0x011b Rational 1 72/1 Exif.Image.ResolutionUnit 0x0128 Short 1 2 Exif.Image.Software 0x0131 Ascii 29 Adobe Photoshop CS Macintosh Exif.Image.DateTime 0x0132 Ascii 20 2007:01:28 11:28:40 Exif.Image.ExifTag 0x8769 Long 1 164 Exif.Photo.ColorSpace 0xa001 Short 1 65535 Exif.Photo.PixelXDimension 0xa002 Long 1 2160 Exif.Photo.PixelYDimension 0xa003 Long 1 345 Exif.Thumbnail.Compression 0x0103 Short 1 6 Exif.Thumbnail.XResolution 0x011a Rational 1 72/1 Exif.Thumbnail.YResolution 0x011b Rational 1 72/1 Exif.Thumbnail.ResolutionUnit 0x0128 Short 1 2 Exif.Thumbnail.JPEGInterchangeFormat 0x0201 Long 1 302 Exif.Thumbnail.JPEGInterchangeFormatLength 0x0202 Long 1 1688 c:\temp\Mikael>