Compiling libjpeg

NiVeR picture NiVeR · Sep 29, 2012 · Viewed 39.3k times · Source

Is there anyone who succeed to include libjpeg in some compiler? I tried everything: Dev C++, VS10, CodeBlocks, copy the headers and the lib by hand, add with the linker but nothing. Right now I am really confisued as there is not an official guide on how to compile it in any compiler. I would be really happy if someone could provide a tutorial on how the library can be compiled in any compiler. Thank you in advance.

Answer

AthanasiusOfAlex picture AthanasiusOfAlex · Sep 27, 2013

To compile libjpeg 9 in Visual Studio 2012, here are the steps (after unzipping the archive file):

  1. Download the file WIN32.MAK (for example, from http://www.bvbcode.com/code/f2kivdrh-395674-down), and place a copy in the root source code directory (possibly C:\jpeg-9, but it depends where you unzipped it). I will refer to this directory as %jpegsrc% from now on. Having this file is important; otherwise step 3 will produce an error.

  2. In the Visual Studio command prompt, open to %jpegsrc%:

    cd %jpegsrc%

  3. At the same command prompt, execute the following:

    NMAKE /f makefile.vc setup-v10

    This will create two Visual Studio 2010 solutions in %jpegsrc%: jpeg.sln and apps.sln.

  4. Open each solution in Visual Studio 2012. Each one will prompt you to update all the projects to 2012 format. Click on “Update.” One time I did it, the prompt did not appear. In case that happens, right-click on the jpeg solution in the Solution Explorer, and choose “Update VC++ projects...,” which will produce the same prompt.

  5. Save and build each solution as normal. (You have to build the jpeg.sln solution before apps.sln, since the latter depends on the former.)

Note: this process should work correctly in Visual Studio 2010, without the updating, but I have not tested it.

Update: This method still works in Visual Studio 2015 for libjpeg-9a.