Thread: linker error when using libjpeg

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    40

    linker error when using libjpeg

    I've been trying for hours but I can't seem to find what I am doing wrong.

    the include section:
    Code:
    #define _WIN32_WINNT 0x0500 // code will only run on Win2000 or higher - necessary for using queue timers
    //#define WIN32_LEAN_AND_MEAN
    
    #include <windows.h>
    #include <stdlib.h>
    #include <tchar.h>
    #include <stdio.h>
    extern "C" {
    #include "jpeglib.h"
    #include "jerror.h"
    }
    #include <Mmsystem.h>	// winmm.lib header, used for playing sound
    #undef MessageBox
    #include "AbstractGame.h" // needed to use abstract class as basis for all games
    #include "AbstractMode.h" // needed to use abstract class as basis for all modes
    
    #include <vector>			// using std::vector for tab control logic#include <vector>
    #include <queue>
    #include <algorithm>
    using namespace std;
    
    #include "Defines.h"
    
    //-----------------------------------------------------------------
    // Pragma Library includes
    //-----------------------------------------------------------------
    #pragma comment(lib, "msimg32.lib")		// used for transparency
    #pragma comment(lib, "winmm.lib")		// used for sound
    and then I get a linker error for each function I use(from the libjpeg).
    I'm not experienced with libs and dlls but when I take a look at jpeglib.h and I see what I presume are some sort of prototypes, I feel like I should be including something else but I don't have a clue. Other people who had this issue fixed it by putting the include in the extern "C" but this isn't the case with me.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Have you actually set your linker settings to link with libjpeg?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    40
    No I didn't but you saying that is enough for me to know I did have to something extra. I retried of building the source code, and eventually it worked to make a lib which when included made the linker errors disappear. Had to read the documentation a few more times before it worked, and at the time that I posted I was too tired to try the reading again so I posted but it seems now that this was fairly easy if you take time to read the manual a few times ^^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker problem... no idea
    By cyreon in forum C Programming
    Replies: 2
    Last Post: 04-03-2009, 02:53 PM
  2. libjpeg problems linking in cpp
    By parad0x13 in forum C++ Programming
    Replies: 4
    Last Post: 07-19-2008, 04:29 PM
  3. linker
    By George2 in forum C++ Programming
    Replies: 6
    Last Post: 02-23-2008, 01:25 AM
  4. Linker errors in VC++ 2005
    By C+/- in forum C++ Programming
    Replies: 0
    Last Post: 05-18-2007, 07:42 AM
  5. MSVis-Studio C++ libraries and linker errors
    By kellydj in forum Windows Programming
    Replies: 10
    Last Post: 03-12-2002, 02:03 PM