0

I installed the library with vcpkg: https://github.com/Microsoft/vcpkg

In the PowerShell (Admin):

.\vcpkg install libjpeg-turbo:x64-windows-static
.\vcpkg integrate install

I added reference to the library in :

Configuration Properties > C/C++ > General > Additional Include Directories : [path]libjpeg-turbo-gcc\include

Configuration Properties > Linker > General > Additional Library Directories:[path]libjpeg-turbo-gcc\lib

Configuration Properties > Linker > Input > Additional Dependencies :

  • libjpeg.a
  • libjpeg.dll.a
  • libturbojpeg.a
  • libturbojpeg.dll.a

But I obtain the linking errors:

  • LNK2019 : unresolved external symbol __imp___iob referenced in function _output_message libjpeg.a(jerror.c.obj)
  • LNK2019 : unresolved external symbol _sscanf referenced in function _jinit_memory_mgr libjpeg.a(jmemmgr.c.obj)

  • LNK2019 : unresolved external symbol _sprintf referenced in function _format_message libjpeg.a(jerror.c.obj)

I tried to add the libturbojpeg.dll and libjpeg-62.dll from the libjpeg-turbo-gcc\bin folder but I obtain a link error LNK1107 invalid or corrupt file: cannot read at 0x3D0 \libjpeg-turbo-gcc\bin\libturbojpeg.dll.

Which files do I have to include and where to find them? Thank you in advance.

Hel
  • 137
  • 2
  • 9
  • 1
    `*.a` files are probably for the g++ or clang toolchain. From the error messages you are using MSVC. – Richard Critten Nov 15 '19 at 12:46
  • 1
    Files ending in `.a` are typically static libraries for Cygwin or MinGW encironments. For MSVC you should link with files ending in `.lib`. Unless the documentation specifies otherwise? – Some programmer dude Nov 15 '19 at 12:47
  • ok thank you. I downloaded libjpeg-turbo-gcc but I needed libjpeg-turbo64. Many thanks! – Hel Nov 15 '19 at 12:52
  • The non static build: `libjpeg-turbo:x64-windows` version in `vcpkg` worked for me a few weeks ago as I have it installed. The file names are `jpeg.lib` and `turbojpeg.lib` along with their dlls in both the debug and release folders. – drescherjm Nov 15 '19 at 12:54
  • Thank you for your comment. I don't find the dll. Where is the debug and release folder? I just have bin, classes, doc, include and lib. – Hel Nov 15 '19 at 13:16
  • You will need to create an import library for MS VC++ format. Check [this thread](https://stackoverflow.com/questions/9946322/how-to-generate-an-import-library-lib-file-from-a-dll/53838952#53838952) – Victor Gubin Nov 15 '19 at 13:20
  • Are you trying to use `vcpkg` or not? If you are perhaps there is a bug in the static build. – drescherjm Nov 15 '19 at 13:22
  • @drescherjm Yes I installed the library with the option static and the other time just with: .\vcpkg install libjpeg-turbo:x64-windows . It is not picked up by Visual Studio. – Hel Nov 15 '19 at 13:28
  • Then you have the libraries you need. Are you using `CMake` with visual studio or nuget or some other method for visual studio integration? You probably want to tag the question for `vcpkg` – drescherjm Nov 15 '19 at 13:29
  • No I don't use cmake or nuget, I tried with a simple windows console app. So I just need to add: jpeg.lib, jpeg-static.lib, turbojpeg.lib, turbojpeg-static.lib ? Only these 4 .lib files? If I add the dlls jpeg62.dll and turbojpeg.dll I obtain LNK1104. – Hel Nov 15 '19 at 13:36
  • You don't link to `dlls` so never add these to the Additional Library Directories. The dlls should be placed in the same folder as the executable. – drescherjm Nov 15 '19 at 13:42
  • Thank you for your answer. I removed the references to libjpeg-turbo in Additional Library Directories and Additional Include Directories but Visual Studio can't find the includes. – Hel Nov 15 '19 at 13:50
  • You need to set the include paths in Visual Studio. It should not be `libjpeg-turbo-gcc\include`. It probably should be `c:\vcpkg\installed\x64-windows\include` – drescherjm Nov 15 '19 at 13:58
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/202416/discussion-between-hel-and-drescherjm). – Hel Nov 15 '19 at 14:02
  • Thank you for your answer. I removed the static install to avoid any conflict. I set the include to C:\Documents\C++\lib\vcpkg\installed\x64-windows\include. But I still have linker issues : LNK2019 unresolved external symbol _jpeg_std_error referenced in function "private: bool __thiscall ImageData::do_read_JPEG_file(struct jpeg_decompress_struct *,char *)" (?do_read_JPEG_file@ImageData@@AAE_NPAUjpeg_decompress_struct@@PAD@Z) I also put the 2 dlls: jpeg62.dll, turbojpeg.dll where I expect the executable (project folder \ debug) – Hel Nov 15 '19 at 14:36
  • I suggest you could refer to the link: https://stackoverflow.com/questions/48740107/link-libjpeg-turbo-in-vs-c-2017 – Jeaninez - MSFT Nov 18 '19 at 05:33
  • Thank you for your answer, this is what I used as a base before posting on this forum. – Hel Nov 18 '19 at 13:13

1 Answers1

0

Please find what did work for me at the end. Using vcpkg:

.\vcpkg install libjpeg-turbo:x64-windows
.\vcpkg integrate install

In Visual Studio don't reference any libraries or it will lead to linker errors, only add the include to vcpkg installed libraries:

Configuration Properties > C/C++ > General > Additional Include Directories:

[vcpkg path] \vcpkg\installed\x64-windows\include
Hel
  • 137
  • 2
  • 9