View Full Version : Trouble with jpeglib.h
brtnrdr
2004.08.24, 11:07 PM
i'm trying to use jpeglib.h and libjpeg in xcode to lode jpeg textures for a quake bsp file loader. however, xcode doesn't link to the library and i have a lot of "symbol undefined" errors, so it looks like it's not linking. I've changed the header and library paths in the target, and if i change them for the build settings, then my project doesn't find sdl. i'm very stuck.
any help at all is greatly appreciated.
-nick
FCCovett
2004.08.25, 01:09 AM
There's an example of how to load JPG, PNG, and TGA pictures using C and Carbon, and then create textures with them, on this source code: http://webpages.charter.net/utopiaplanetia/BasicCarbonStruct.dmg
wadesworld
2004.08.25, 06:50 AM
Have you added the library to your project?
Wade
FCCovett
2004.08.25, 12:23 PM
Nope. I use Carbon to load JPG images. In that source code, you can see how to load an JPG image and access its data buffer to create a texture with it. You wouldn't need to use libjpeg then.
aaronsullivan
2004.08.25, 12:27 PM
I've changed the header and library paths in the target, and if i change them for the build settings, then my project doesn't find sdl. i'm very stuck.
You can ADD paths instead of changing them... you didn't delete the path to the SDL stuff did you? Just put them both on the same line seperated by a space (use quotes around paths that contain a name with spaces)
brtnrdr
2004.08.25, 05:31 PM
ya, i did change the paths. the reason that the sdl framework was being lost was because i was changing the build style, not the target. but now i am and it still doesn't link to libjpeg. the library isn't added to my project because it resides in /sw/lib which you can't see in a file dialog box, only through the terminal.
anyone have any ideas?
-nick
wadesworld
2004.08.25, 11:43 PM
the library isn't added to my project because it resides in /sw/lib which you can't see in a file dialog box, only through the terminal.
anyone have any ideas?
-nick
Sure you can. When the dialog box is open, just start typing the path (/sw/lib). As soon as you hit that first / a "Go to folder" dialog box will open, allowing you to navigate to the folder.
An alternative method is to drag and drop the file into your project from the Finder. You can either choose "Go To Folder" from the Go menu and type the /sw/lib path in, or you can just go to the terminal and type "open /sw/lib".
Wade
brtnrdr
2004.08.26, 09:15 AM
thanks for telling me how to include the library, however there are still undefined symbols. is there anywhere specific it needs to go. the library is linking, as there is an "-ljpeg" in the error window. i'm really lost as to where to even start to try and fix this. any other ideas.
thanks.
-nick
brtnrdr
2004.08.26, 09:21 AM
nevermind, thanks a lot to everyone who helped, i got it working somehow not 2 minutes after i posted today. i ended up adding the jpeglib.h, jconfig.h and jmoreconfig.h files to my project and now it works.
thanks again.
-nick
FCCovett
2004.08.26, 12:30 PM
Another satisfied customer of iDevGames. :)
jarfish
2004.11.30, 06:47 PM
i'm essentially trying to do the same as brtndr.
basically, just loading a jpeg for use a texture.
i've been able to compile jpeglib, but all attempts
to compile against it using xcode have failed. xcode
really doesn't like static libraries.
if anyone has any hints here, please let me know.
thanks,
jarfish
OneSadCookie
2004.11.30, 08:00 PM
Xcode has no problems with static libraries, and libjpeg just works.
Hello, people, we can't help you unless you tell us what error messages you're getting! We're not psychic!
jarfish
2004.12.06, 10:23 AM
if i include the jpeglib in my xcode project
and make even the smallest reference to
it (even just including one function), then
xcode just returns with....
Building target “jXGLapp” with build style “Development” (optimization:level ‘0’, debug-symbols:on) — (1 error, 7 warnings)
/usr/bin/g++-3.3 -o "/Users/jarfish/Code/Projects (OSX)/Historia/build/jXGLapp.app/Contents/MacOS/jXGLapp" "-L/Users/jarfish/Code/Projects (OSX)/Historia/build" "-L/Users/jarfish/Code/Projects (OSX)/Historia/lib" "-F/Users/jarfish/Code/Projects (OSX)/Historia/build" "-F/Users/jarfish/Code/Projects (OSX)/jpeg_framework/build" -filelist "/Users/jarfish/Code/Projects (OSX)/Historia/build/Historia.build/jXGLapp.build/Objects-normal/jXGLapp.LinkFileList" -framework Cocoa -framework OpenGL -ljpeg -arch ppc -prebind -Wl,-no_arch_warnings
ld: warning prebinding disabled because of undefined symbols
ld: Undefined symbols:
jpeg_CreateDecompress(jpeg_decompress_struct*, int, unsigned long)
ld: Undefined symbols:
Obviously, the libjpeg library is not being seen by xcode,
even though it's included in the project. Any sincere help
would be appreciated.
best,
jarfish
wadesworld
2004.12.06, 03:53 PM
Is your porject small enough that you could do a clean build on it and then stuff/zip it up for one of us to download?
It certainly should work - the fastest way to help would be to look at the project.
Wade
jarfish
2004.12.07, 06:41 PM
i think i've isolated the problem. i've gotten jpeglib
to work in xcode in a simple project that just used
obj-c and c files.
however, when i changed any file suffix to either
.mm (obj-c++) or .cpp (c++), the compiler returns
with "undefined symbols"--even if there is no
change to the code.
unfortunately, for the project that i'm working on,
there's already a lot of c++ code, so i need xcode
to compile that and link the jpelib.
thanks for your help.
+ jarfish
wadesworld
2004.12.08, 01:07 AM
Again, the easiest solution would be to let us see the project.
However, what you're describing sounds a little bit like the function prototypes aren't marked extern "C". If you're including the header properly, I'd be surprised if that were the case.
Again, a LOT of people use libjpeg without issue in C++ projects.
Wade
OneSadCookie
2004.12.08, 03:17 PM
extern "C" {
#include <jpeglib.h>
}
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.