Help With libjpeg
I need to use libjpeg for a project. I followed the install instructions I found online
And ended up with this...
Now I need to link the files lib when I compile my project...
How do I do this?
I would have thought (the project is an opengl model viewer)
but it doesn't work and I get
I have also tried
Does this mean I haven't installed it correctly?
I actually had to create the /usr/local/lib directory, when I first tried to build the lib I got
Sorry for the noob question.
Thanks
Spinner
Code:
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.aCode:
zippy:/usr/local/lib luke$ ls
libjpeg.a libjpeg.laHow do I do this?
I would have thought (the project is an opengl model viewer)
Code:
zippy:~/Desktop/project spinner$ g++ -o Viewer 3dsLoader.o ImageLoader.o Viewer.o -Wall -framework OpenGL -framework GLUT -L/usr/local/libCode:
/usr/bin/ld: Undefined symbols:
jpeg_std_error(jpeg_error_mgr*)
jpeg_read_header(jpeg_decompress_struct*, int)
jpeg_read_scanlines(jpeg_decompress_struct*, unsigned char**, unsigned int)
jpeg_CreateDecompress(jpeg_decompress_struct*, int, unsigned long)
jpeg_start_decompress(jpeg_decompress_struct*)
jpeg_finish_decompress(jpeg_decompress_struct*)
jpeg_resync_to_restart(jpeg_decompress_struct*, int)
jpeg_destroy_decompress(jpeg_decompress_struct*)
collect2: ld returned 1 exit statusI have also tried
Code:
zippy:~/Desktop/project spinner$ g++ -o Viewer 3dsLoader.o ImageLoader.o Viewer.o -Wall -framework OpenGL -framework GLUT -ljpeg
/usr/bin/ld: Undefined symbols:
jpeg_std_error(jpeg_error_mgr*)
jpeg_read_header(jpeg_decompress_struct*, int)
jpeg_read_scanlines(jpeg_decompress_struct*, unsigned char**, unsigned int)
jpeg_CreateDecompress(jpeg_decompress_struct*, int, unsigned long)
jpeg_start_decompress(jpeg_decompress_struct*)
jpeg_finish_decompress(jpeg_decompress_struct*)
jpeg_resync_to_restart(jpeg_decompress_struct*, int)
jpeg_destroy_decompress(jpeg_decompress_struct*)
collect2: ld returned 1 exit statusI actually had to create the /usr/local/lib directory, when I first tried to build the lib I got
Code:
/usr/bin/install -c libjpeg.la /usr/local/lib/libjpeg.la
install: /usr/local/lib/libjpeg.la: No such file or directory
make: *** [install-lib] Error 71
zippy:~/Desktop/jpeg/jpeg-6b spinner$ sudo mkdir /usr/local/libSorry for the noob question.
Thanks
Spinner
Thanks to NCarter and ThemsAllTook on the iDG IRC channel, I now have an answer!
I thought I should post it incase anyone else has the same issue in the future.
My #include statement needed to specify it was a C lib, rather than C++
The correct way to do this is apparently
Hope that helps someone.
Thanks to IRC channel for the prompt and friendly advice!
I thought I should post it incase anyone else has the same issue in the future.
My #include statement needed to specify it was a C lib, rather than C++
The correct way to do this is apparently
Code:
extern "C" {
#include <jpeglib.h>
}Hope that helps someone.
Thanks to IRC channel for the prompt and friendly advice!
You picked a good forum to ask this question: the MAF isn't exactly full of developers. 
As I said there: most headers take into account C++ by having extern "C" between #ifdef __cplusplus ... #endif macros. Though you shouldn't have to worry about this very often with third party resources, it's a good thing to remember if you ever write anything in C which you then use in C++.

As I said there: most headers take into account C++ by having extern "C" between #ifdef __cplusplus ... #endif macros. Though you shouldn't have to worry about this very often with third party resources, it's a good thing to remember if you ever write anything in C which you then use in C++.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Statically linking to libjpeg? | bronxbomber92 | 5 | 2,847 |
Mar 3, 2007 02:31 PM Last Post: bronxbomber92 |
|

