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.
相关问题
- Sorting 3 numbers without branching [closed]
- How to get the background from multiple images by
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
If you want debug mode as well in MSVC. Follow AthanasiusOfAlex's method, build the release, then:
Build and you're done!
Here is how I've built libjpeg using MinGW on Windows :
1. Get MinGW with MSYS
I've got a copy from http://sourceforge.net/projects/mingw/. Quoting from www.mingw.org :
We will need it to run the
configure
script that comes with libjpeg sources.2. Get libjpeg sources
From http://www.ijg.org/, take the Unix format package (the Windows one won't work with this procedure). I took the
jpeg_8d
version.3. Prepare a building directory
I've made a temporary directory named
tmp
inD:\
, but you could choose whatever suits your needs. The thing that matters is the name of paths in MSYS. As it brings some * Unixity * to Windows, paths cannot be used in their original form. In a nutshell:C:\path\to\file
becomes/c/path/to/file
in MSYS land, an soD:\tmp
becomes/d/tmp
.Decompress the libjpeg sources in
D:\tmp
, so you have ajpeg-8d
directory in there.Create a
jpeg-build
directory insideD:\tmp
, it will hold the built library.Now everything is ready for the build.
4. ./configure, make, make install
That is the mantra of building in Unix land. An option should be added to redirect the install process to
D:\tmp\jpeg-build
.Run the following commands in an MSYS shell (also named MinGW shell in Windows start menu):
As an additional step, you can run
make test
for safety.These commands will build both static and shared versions of libjpeg.
5. Take the goods, delete the temporaries
If everything runs fine, you can delete the
D:\tmp\jpeg-8d
directory, but keep thejpeg-build
one. It contains:include
directory, containing libjpeg headers. You can move them to your compiler's headers directory.lib
directory, with.a
file to pass to the linker. You can move them to your compiler's library directory.bin
directory, holding the libjpeg shared librarylibjpeg-8.dll
and jpeg tools.share
directory, containingman
pages for the jpeg tools.You can now build your program and link it against libjpeg by indicating the right include and library paths.
You can find many details about the libjpeg building and installation process in
install.txt
inside the source package.I hope this will be useful.
If you don't happen to have Visual Studio 2010 installed, here is what works on Visual Studio 2017:
Basic / Common steps:
cd
) to where you extracted the library sourceVS 2017 Approach:
Include the Windows SDK v7.1A directory (required for Win32.Mak by nmake later on) by running:
set INCLUDE=%INCLUDE%;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
Run
nmake /f makefile.win setup-v15
(note the v15 for VS2017 here)From here on follow what @AthanasiusOfAlex explained to upgrade the Visual Studio 2010 solution to the Visual Studio version you are running. If you want the Debug configuration, follow what @SteveEng explained.
Errors you might stumble across:
nmake
fails and tells you it doesn't know how to make jconfig.h, manually rename the filejconfig.vc
tojconfig.h
nmake
fails and tells you Win32.Mak cannot be found, manually copy it from the SDK dir mentioned in step #4 to the libjpeg source directory. If you don't happen to have that SDK version installed, download the file from a trustworthy resource.nmake
fails and tells you it doesn't know how to makesetup-v15
, trial and error your way through starting withsetup-v10
,setup-v11
, etc... These are VS versions and one of them should work as long as you have any VS version later than VS 2008 installed.Hope this helps people going through similar pain with this.
To compile
libjpeg
9 in Visual Studio 2012, here are the steps (after unzipping the archive file):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 (possiblyC:\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.In the Visual Studio command prompt, open to
%jpegsrc%
:cd %jpegsrc%
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
andapps.sln
.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.Save and build each solution as normal. (You have to build the
jpeg.sln
solution beforeapps.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
.It is really simple to build jpeg.lib with VS10.
First, download the libjpeg source code in zip format. At the time I'm writing this you can find it here.
Then extract the contents of the zip file to your disk.
Then open a VS2010 command prompt shell (or call vcvarsall.bat on any command prompt window), cd to the jpeg source directory (jpeg-8d in the download referenced above) and type the following:
This will generate two VS2010 solutions, and a bunch of project files. The solutions are:
jpeg.sln
, which buildsjpeg.lib
apps.sln
, which builds the sample applications.Good luck!