Mail Archives: cygwin/2001/08/29/14:16:04
Daniel G. Aliaga wrote:
> I recently installed CYGWIN. Its great!
>
> I'm porting code that uses the standard JPEG library. I specify the library
> on the link line, but I get error messages such as the following (one for
> every jpeg call):
>
> ....: undefined reference to 'import stub for
> jpeg_read_header(jpeg_decompress_struct *, int)'
Did you "interpret" this error message? I've never seen gcc/ld spell
stuff out in that much detail. Ordinarily, the error would be
"undefined reference to __imp__jpeg_read_header" in this case.
> and so forth, etc.
>
>
> I suppose this has something to do with DLLs vs libraries. It seems
> libjpeg.a and libjpeg.dll.a are already in /usr/lib. I suppose the
> installation properly created them. cjpeg and djpeg work just fine.
Yes, static lib, import lib, and DLL are all included in the dist.
> Is there something special I need to do during link time? I come from a Unix
> background. My compile line is something simple like:
>
> "g++ -o myprogram myprogram.C -ljpeg -lm"
>
First, you should probably split compilation and linking into two
separate steps (not *really* necessary, but often illuminating). Second,
you need to decide whether you want to link statically or dynamically.
Static:
add -DJPEG_STATIC (or -DALL_STATIC) when compiling
add -static when linking (this will cause the linker to hunt for
"libjpeg.a" instead of "libjpeg.dll.a" when given "-ljpeg".
Dynamic:
Strange -- what you have should work (minus the -lm, but that shouldn't
affect anything). The system header files are set up to define/declare
things appropriately for a dynamic link. Please try:
g++ -c -o myprogram.o myprogram.C
g++ -o myprogram myprogram.o -ljpeg
(BTW, I'm not sure that the jpeg library is C++ safe...)
--Chuck
P.S. personal mail makes me LESS likely to respond, not more. I get
five or more messages a day of cygwin-related personal mail that belongs
on the list. Most of it goes in the trash.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -