Thread: Compiler errors when using libjpeg.

  1. #1
    Registered User Nikanoru's Avatar
    Join Date
    Jul 2003
    Posts
    8

    Compiler errors when using libjpeg.

    Hiya,

    I've been visiting the site for quite some time, and I love it. Because it's so great, I've never had to ask a question before, until now!

    I'm using the mingw-based 32 Dev-C++ compiler, and I want to add jpeg support to my game using the libjpeg library.

    I have no problem with any of the code (it's a lot easier than I expected), but for some reason I'm getting linker errors for every libjpeg function I use, even though I linked to libjpeg.a.

    I double checked to see if the libjpeg.a file was there, I double checked my notation (-ljpeg in the compiler options) ... I'm clueless.

    It's very strange that I'm getting these errors, because I'm using the imagelib devpack, especially made for Dev-C++.

    ---

    There's also another problem, when compiling I'm getting a "conflicting types" error, because of these lines:

    in jmorecfg.h:
    Code:
    /* INT32 must hold at least signed 32-bit values. */
    
    #ifndef XMD_H			/* X11/xmd.h correctly defines INT32 */
    typedef long INT32;
    #endif
    and in basetsd.h:
    Code:
    #ifndef XFree86Server
    typedef int INT32, *PINT32;
    #endif /* ndef XFree86Server */
    INT32 is indeed being defined twice. The header files are linked together. Commenting out that second line from the basetsd.h file seems to get rid of the error, but I don't think that's a wise thing to do. Anyone have any idea?

    Again, weird, since I'm using these official files.

    Any pointers at all would be greatly appreciated ...

  2. #2
    Disturbed Boy gustavosserra's Avatar
    Join Date
    Apr 2003
    Posts
    244
    What errors messages are you getting about the jpeg.a?
    About the second error... this cannot be avoided I think.. My sugestion is that cut off the int INT32. Remaining only the PINT32 and the long INT32... but it´s only a personal opinion!
    Nothing more to tell about me...
    Happy day =)

  3. #3
    Registered User Nikanoru's Avatar
    Join Date
    Jul 2003
    Posts
    8
    Yeah, I'll just comment out the int INT32 then, thanks.

    For the linker error, I'm just getting Dev-C++ standard linker error message:

    [Linker error] undefined reference to '(insert whatever function I typed here)'

    One error for every time I use a function.

  4. #4
    Registered User Nikanoru's Avatar
    Join Date
    Jul 2003
    Posts
    8
    Well, under Dev-C++, I just go to "Project options", and under the "Parameters" tab, in the "linker" space, I've got:

    -lopengl32 -lglu32 -ljpeg

    The documentation says I only need libjpeg.a if I want to use jpeg (de)compression.

    Everything works fine until I use any libjpeg functions. I can crate polygons with textures (from a .raw file), shading and blending, everything.

    I tried putting -ljpeg in front of those two, but no succes.
    Last edited by Nikanoru; 07-12-2003 at 02:20 PM.

  5. #5
    Registered User Nikanoru's Avatar
    Join Date
    Jul 2003
    Posts
    8
    Yup.

    Maybe it's some bug in Dev-C++ itself. I'll try and install an earlier version (I've got the latest one).
    Last edited by Nikanoru; 07-12-2003 at 02:59 PM.

  6. #6
    Registered User Nikanoru's Avatar
    Join Date
    Jul 2003
    Posts
    8
    NOOOO!

    Ahem.

    I thought it worked there for a moment (I didn't know the updater actually had later versions available than the site?) but after I tested out a few things and compiled a few times it started giving linker errors again for no reason at all!

    This seems to be happening every time I start over with my backupped file: it compiles fine, then I add the jpeg functions, it still compiles fine, but then after a few compiles it starts errorring again, even if I change it back to the way it was before it started!

    What? Huh? Do programs get "tired" all of a sudden?

  7. #7
    Registered User Nikanoru's Avatar
    Join Date
    Jul 2003
    Posts
    8
    Thanks for putting up with me and answering all these questions ...

    How would I go about doing that? Just put those lines in my code somewhere?

    BTW Salem, are you a Dev-C++ user yourself?

  8. #8
    Disturbed Boy gustavosserra's Avatar
    Join Date
    Apr 2003
    Posts
    244
    I think that could be the package... I already had problems with the packages downloaded from the Dev´s Page
    Nothing more to tell about me...
    Happy day =)

  9. #9
    Registered User Nikanoru's Avatar
    Join Date
    Jul 2003
    Posts
    8
    Well, I already tried using the libjpeg files from the official libjpeg site, with no different results. I've posted my question on the sourceforge.net Dev-C++ forum, maybe I'll get an answer there, even though the board is pretty slow (like, one reply in two days).

    I'll just give up for now and stick to .raw files until a solution presents itself. Thanks for all the help.

    I'll post my game when it's in the stage where it's ready for a tech demo.

  10. #10
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Where are the lib files? Are you sure that they are linking? Is the path of their location in the list of lib file paths?

  11. #11
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    I've got the same problem with Dev C++. Everything works fine except for the jpeg library. The compiler output looks like this:

    g++.exe ../_obj/BM3D.o ../_obj/world.o ../_obj/entity.o ../_obj/engine.o ../_obj/model.o ../_obj/winmsg.o ../_obj/viewport.o ../_obj/keyboard.o ../_obj/renderer.o ../_obj/image.o -o "..\_exe\BM3D.exe" -L"C:/Programme/Dev-Cpp/lib" -mwindows -lopengl32 -lglu32 -lglaux -lwinmm -ljpeg

    ../_obj/image.o(.text+0x68e):image.cpp: undefined reference to `jpeg_std_error(jpeg_error_mgr*)'
    ../_obj/image.o(.text+0x6ad):image.cpp: undefined reference to `jpeg_CreateDecompress(jpeg_decompress_struct*, int, unsigned)'
    ../_obj/image.o(.text+0x6c2):image.cpp: undefined reference to `jpeg_stdio_src(jpeg_decompress_struct*, _iobuf*)'
    ../_obj/image.o(.text+0x6d6):image.cpp: undefined reference to `jpeg_read_header(jpeg_decompress_struct*, int)'
    ../_obj/image.o(.text+0x6e8):image.cpp: undefined reference to `jpeg_start_decompress(jpeg_decompress_struct*)'
    ../_obj/image.o(.text+0x7f0):image.cpp: undefined reference to `jpeg_read_scanlines(jpeg_decompress_struct*, unsigned char**, unsigned)'
    ../_obj/image.o(.text+0x828):image.cpp: undefined reference to `jpeg_finish_decompress(jpeg_decompress_struct*)'
    ../_obj/image.o(.text+0x83a):image.cpp: undefined reference to `jpeg_destroy_decompress(jpeg_decompress_struct*)'
    I downloaded another jpeg.lib but it didn't work either.

  12. #12
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Ok, I finally found out, thanks to Per!

    libjpeg.a is a C lib with a C header and we were trying to use it in C++. M$ VC++ doesn't really care, but MinGW does. Long sentence short meaning, use this to include jpeglib:

    Code:
    extern "C" {
    #include "jpeglib.h"
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. bloodshed compiler errors
    By nerore in forum C++ Programming
    Replies: 5
    Last Post: 04-17-2004, 02:37 PM
  4. How to resolve linking errors?
    By m712 in forum C++ Programming
    Replies: 3
    Last Post: 11-03-2002, 10:17 PM
  5. Compiler errors
    By BellosX in forum C Programming
    Replies: 2
    Last Post: 09-21-2001, 03:24 AM