LWJGL Forum

Archive => DevIL => Topic started by: numberR on May 05, 2005, 05:54:28

Title: DevIL on Mac OS X Tiger
Post by: numberR on May 05, 2005, 05:54:28
hello.

did anyone try DevIL on Tiger?
i'm getting following error when my ggame is just about to load image:

Bus error

and my game crashes.
any idea?

thanks

[edit]
game works if i use ImageIO instead of DevIL.
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 05, 2005, 09:16:56
Not aware of any issues generally - but haven't checked with tiger since I don't have a copy. I think elias has one, and I'l bug him to test/confirm any issues.

Bus errors are basically NullPointerException, renamed to something silly (imo).

Does your application work fine in panther ?
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 05, 2005, 19:52:27
unfortunately, i have not had a chance to try my game with DevIL on panther. i have tried it with ImageIO on panther and it worked fine. but my game works fine on Linux/Windows with DevIL, so i think there is a problem specific to Mac OS X.

i installed DevIL library from http://prdownloads.sourceforge.net/openil/DevIL_Binary_1.6.7.tgz. and i also have -Djava.library.path set to where all of jar and library from lwjgl locate. is this setup right?
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 05, 2005, 23:06:09
use the IL file provided in the lwjgl distribution - or at least make sure its locatable and called the same
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 06, 2005, 06:59:03
thanks for the reply.

maybe i'm missing something. i uninstalled DevIL that i got from DevIL site.
i located IL provided by lwjgl in my -Djava.library.path. then i get this error when i run my game:

org.lwjgl.LWJGLException: Could not load devil library.
       at org.lwjgl.devil.IL.nCreate(Native Method)
       at org.lwjgl.devil.IL.create(IL.java:593)
       at Engine.initializeGraphic(Unknown Source)
       at Engine.initialize(Unknown Source)
       at GLTalk.run(Unknown Source)
       at GLTalk.main(Unknown Source)

do i need to rename IL to something like IL.dylib? thing i noticed is that ld command for IL shows following:

ld: warning can't open dynamic library: /Library/Frameworks/IL.framework/Frameworks/lcms.framework/Versions/A/lcms (checking for undefined symbols may be affected) (No such file or directory, errno = 2)
ld: warning can't open dynamic library: /Library/Frameworks/IL.framework/Frameworks/libtiff.framework/Versions/A/libtiff (checking for undefined symbols may be affected) (No such file or directory, errno = 2)
ld: warning can't open dynamic library: /Library/Frameworks/IL.framework/Frameworks/libpng.framework/Versions/A/libpng (checking for undefined symbols may be affected) (No such file or directory, errno = 2)
ld: warning can't open dynamic library: /Library/Frameworks/IL.framework/Frameworks/libjpeg.framework/Versions/A/libjpeg (checking for undefined symbols may be affected) (No such file or directory, errno = 2)
ld: warning can't open dynamic library: /Library/Frameworks/IL.framework/Frameworks/libmng.framework/Versions/A/libmng (checking for undefined symbols may be affected) (No such file or directory, errno = 2)

i checked /Library/Frameworks directory, but i don't have any of those installed. it would be helpful if there is documentation for how to install/use DevIL on Mac OS X... or maybe i'm the only one idiot :(
Title: DevIL on Mac OS X Tiger
Post by: cbarrett1974 on May 06, 2005, 21:43:44
I am getting the exact same problem. I'm new to OS X, so don't know much about how it does dynamic libraries. It does seem strange to me that the DevIL library is just called "IL" - how does OS X search for this?

I've tried it in the path as well as java.library.path with the same error previously reported.  I upgraded to Tiger before my first DevIL experiment, so I cannot say if this is a Tiger problem or not (which sounds far too much like "Windows XP Service Pack 2" to me!!).
Title: DevIL on Mac OS X Tiger
Post by: cbarrett1974 on May 07, 2005, 14:07:39
OK, I just got it working!  
I previously installed the DevIL binaries (DevIL-1.6.7.tgz), and have now just installed the framework package (DevIL_1.6.7-pkg.tgz), which asked for a reboot, after which everything is working fine.
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 07, 2005, 15:44:37
thanks for the information. i'll try that.

but now i wonder. devil site says
"The framework version will not be supported, it was just causing problem, now is deployed as a dynamic library stored in /usr/local".

should we really be using Framework one? or is he talking about something else?
Title: DevIL on Mac OS X Tiger
Post by: tomjnsn on May 17, 2005, 16:50:08
I tried pulling down the source for lwjgl and rebuilding on OS X, to see if I could get it to link to the dynlib's for IL, but I can't even get it to compile, either through XCode or Project Builder or just using make on the command line.  

Whoever has successfully built lwjgl on OS X, and DevIL, would they mind posting steps they went through to get it working?
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 17, 2005, 18:22:50
Is this a 10.4 issue or ? - coz I load devil+lwjgl fine on 10.3 ?
Title: DevIL on Mac OS X Tiger
Post by: tomjnsn on May 17, 2005, 18:51:27
No, this is on 10.3, although I'm not sure what I'm doing wrong.  I pulled down the source, unzip the mac_xcode.xcode project and open it in XCode, but it throws a bunch of errors about not finding some specific files when I try and build it.  I did use javah to build the header files it was wanting, but it seems like it was complaining about some vars not being defined.  

Sorry I'm not at my mac right now so I can't tell you the errors.  Could just be that my environment isn't setup properly (I don't use XCode, so it is just the generic install of it).

My whole aim is to try and get lwjgl working with the dynlibs that DevIL is now putting out as their OS X binaries.  If someone else has got that I'd be happy with that.  I'm pretty sure I'm doing something wrong on my end, since I don't normally use XCode or Project Builder.
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 17, 2005, 19:33:23
dont use xcode at all
just build using the supplied make files
but you dont need to build to use devil under osx
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 18, 2005, 05:42:07
Matzon,
yea it works fine if you install devil framework. but i want devil to be working without installing devil framework.
on linux/windows, i can use devil just by providing devil dynamic library and doesn't have to make people install devil. i can distribute devil dynamic library with my game. i just want that to be happing on mac os x as well, so people don't have to care about anything but game itself.

it seems like we might need to compile devil itself to make it look for libIL.dylib and other libraries at run time. How was "IL" file, which comes with lwjgl, compiled?
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 18, 2005, 05:47:01
It was gotten from the package provided by the site. I'll investigate the issue today.
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 18, 2005, 16:00:32
As far as I can determine, the issue is exactly the same as with Linux. IL is loaded fine, however the support files (libtiff, libjpeg etc.) cannot be found, unless the ILframework is installed.

I am unsure about how to fix this, but I am taking any and all help for a general solution. For now, I am not seeing it as a blocker for any releases.
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 21, 2005, 04:01:36
hey guys.

i think i made some progress. i found that IL.java has following code at line number 586:


"IL", "IL"}, IL.class.getClassLoader());


i changed the second "IL" to "libIL.dylib" and created lwjgl_devil.jar. then it seems like now it's looking for libIL.dylib instead of IL, but i get following error:

Quote
Initial mode: 1024 x 768 x 32 @70Hz
Removed 0 duplicate displaymodes
getPathFromClassLoader: searching for: IL
getPathFromClassLoader: searching for: lwjgl
Found 2 devil paths
Testing 'libIL.dylib'
Found devil at 'libIL.dylib'
org.lwjgl.LWJGLException: Missing driver symbols
       at org.lwjgl.devil.ILU.initNativeStubs(Native Method)
       at org.lwjgl.devil.IL.create(IL.java:596)

i enabled some of debug messages so it might help someone. now the question i have is what "Missing driver symbols" means. does this trick make any of you guys feel like now devil would work with dylibs?

by the way, nice job on lwjgl-0.97 :)
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 21, 2005, 09:07:15
how did you get the dylib ?

Unlike any of the other platforms, Mac only loads IL and not ILU and ILUT because IL is one big library that loads all methods...

So you might need to remove the initialization of libILU.dylib and libILUT.dylib from the IL.create method, unless you they're embedded in libIL.dylib ?
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 21, 2005, 18:16:50
http://prdownloads.sourceforge.net/openil/DevIL_Binary_1.6.7.tgz
i got libIL.dylib, libILU.dylib, libILUT.dylib and all other stuff from the link above. that's the one seems to be recommended on DevIL site.

Quote
Unlike any of the other platforms, Mac only loads IL and not ILU and ILUT because IL is one big library that loads all methods...

oh i see. i'll try to look at that... thanks
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 21, 2005, 19:58:53
finally i got it to be working. as Matzon notified, it was exactly why i did not work.
i commented out where it checks if platform is mac os x and now it works fine with dylibs.
indeed i don't have devil framework installed.

http://unixforge.org/~numberr/data/lwjgl_macosx_mod_20050521.zip
there is not much change to java source code,
only IL.java, ILU.java and ILUT.java with little of changes.
so the conclusion is that there is not much difference between Linux and Mac OS X except for Linux uses *.so and Mac OS X uses *.dylib.

could we expect this to be included in future release?
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 21, 2005, 20:55:09
YES! - thanks for working out the kinks, I'll look into it this monday (when I am near a mac again). Great work!
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 22, 2005, 11:27:46
I have comitted a version to cvs that uses .dylib instead.
However I am crashing on calling ilutInit in native code. I really don't have a clue as to what is going on.

If I comment the call to ilutInit in ILUT.create out, BasicTest runs fine... *ponder*. It would be of great help if you could help me debug this problem. It might involve compiling devil from cvs and adding debug code to it.

looking at the ilutInit file (http://cvs.sourceforge.net/viewcvs.py/openil/DevIL/src-ILUT/src/ilut_main.c?rev=1.7&view=markup)
I can only guess at the issue being something with opengl. Because ilInit has been called at that point in time.

I will look at this as soon as I get some time, but will probably take a day or two.
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 22, 2005, 20:41:10
there is yet another problem needs to be solved...

first, i'd like to make sure how i confirmed that devil worked with dylibs.

1)
http://prdownloads.sourceforge.net/openil/DevIL_Binary_1.6.7.tgz
get this file and run "Devil Libraries.mpkg" inside the file.
this installs all of libIL.dylib, libILU.dylib, libILUT.dylib, libpng and all that to /usr/local/lib.

2)
create lwjgl-devil.jar from cvs.
i confirmed that what Matzon committed to cvs worked fine on my machine, at least.

3)
run lwjgl application that uses devil.

the problem i found is that, lwjgl can load libIL.dylib from java.library.path so you actually don't have to install "Devil Libraries.mpkg", however, libraries like libpng and libjpeg are needed by libIL.dylib and in that case, libIL.dylib does not look for java.library.path but /use/local/lib.
i thought it could be solved if we compile libIL.dylib staticly with libpng and all that, but i haven't tried it yet.

i'll look for solution.
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 22, 2005, 23:07:12
ah, i think i got libIL.dylib, libILU.dylib and libILUT.dylib working without libpng and all other dylibs that DevIL uses at run time.
i just compiled libIL.dylib, libILU.dylib and libILUT.dylib with libpng.a instead of libpng.dylib and so on,
so now it does not need to look for libpng.dylib.
i dropped mng support in order to compile libIL.dylib,
but i think it's not that big deal for video game...

so forget about my previous post and refer steps below:

1)
get LWJGL-0.97 and setup them as you usualy do, such as copying *.jar and *jnilib to your java.library.path.

2)
http://unixforge.org/~numberr/data/DevILforLWJGL.zip
get this file, uncompress it and copy libIL.dylib, libILU.dylib and libILUT.dylib to your java.library.path (it does not have to be /usr/local/lib anymore!).
overwrite ones come with LWJGL.

3)
compile lwjgl-devil.jar from cvs, and place it to your java.library.path.

4)
run LWJGL application.

it should work.
i guess distributing my libIL.dylib, libILU.dylib and libILUT.dylib does not violate GPL or licenses that libpng and other libraries use, does it?
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 23, 2005, 05:45:50
Very good question, I will contact the author of devil, and see if he has an idea. Since the dylibs are linked to GPL code, they may infact themselves have "become" GPL, which means that lwjgl cannot link to them, not even dynamically like we do with DevIL ordinarily and OpenAL.

Do you still have to comment out ilutInit ?
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 24, 2005, 21:52:16
I tried to add a --enable-static option to building devil, but that only results in a static devil library, and not what we want, a dynamic devil library, with statically linked support libraries :(

I then manually forced 'ld' to only locate the static libraries, by renaming the dynmic support libraries in /usr/lib (linux) - and it actually worked! (though libjpeg didn't want to play along, so had to disable that in my compile). But since renaming /usr/lib files is an invitation for errors, I would like to locate a switch to autoconf that makes it compile the support libraries statically - anyone out there?
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 25, 2005, 02:45:53
what i did to create a dynamic devil library that statically linked with support libraries was, edit the final gcc line.

for example, ./autogen.sh & ./configure & make creates normal libIL.dylib that dynamically linked with support libraries. this is not what we want. so i took the last gcc line used to create libIL.dylib, and edit where it passes /use/local/lib/libpng.dylib to /usr/local/lib/libpng.a. this way, you can create a dynamic devil library that statically linked with support libraries. i piped output of make by doing "make > log.txt".

yea, this is simply not smart.
i would be happy if someone can point out better way to do this.
Title: DevIL on Mac OS X Tiger
Post by: Matzon on May 25, 2005, 20:40:25
hmm, cant get that working in linux - nor can I under mac (I am having issues compiling devil - have to disable opengl).
Can you confirm that your trick works with latest lwjgl from cvs? - if so I will just repackage that.
Title: DevIL on Mac OS X Tiger
Post by: numberR on May 26, 2005, 03:59:01
yea, i compiled lwjgl_devil.jar and liblwjgl-devil.jnilib from cvs and it worked with my previously posted libIL.dylib.
have you deleted devil framework? (sitting in /Library/Frameworks)
it should not bother, but i'm just curious...
i'll make libIL.so for Linux after my exams, hopefully tomorrow night.

for mac os x, devil compilation fails by OpenGL errors, but adding "-framework OpenGL" to last gcc line seems to work, as devil forum says.
Title: DevIL on Mac OS X Tiger
Post by: numberR on July 05, 2005, 07:50:30
hmm, now we seem to stuck.

http://developer.apple.com/qa/qa2001/qa1269.html
does which OpenGL interface to use matter? or does ILUT work when you use it with C/C++?
these are the only things that i can think of right now...

if we cannot get this problem solved, we might need to go back to DevIL framework.
otherwise, one cannot use ILUT with lwjgl, which is not good :(
Title: DevIL on Mac OS X Tiger
Post by: numberR on September 17, 2005, 09:24:42
i kinda found why libILUT.dylib hates us so much.
i tried to use DevIL in C++, and i took gltest.c comes with DevIL.
i noticed gltest.c does not call neither of iluInit() or ilutInit() event it uses ILU and ILUT.
i compiled gltest.c and worked like charm.
i put iluInit() and gltest still worked fine.
but as soon as i put ilutInit(), gltest dumps error saying "Bus error", which is what we were getting when we use ILUT from Java.

so i conclude that this is DevIL issue on Mac OS X and not of LWJGL.
i don't know why, but it is ilutGLInit() in ilut_opengl.c that causes this problem.

temporary fix might be commenting out call to ilutInit() from ILUT.ilutInit() in org_lwjgl_devil_ILUT.c, when the system is Mac OS X.
in fact, i got BasicTest working with IL*.dylib if i commented out ilutInit() in ILUT.ilutInit().

what do you guys think?
wierd thing is that ilutInit is not event on DevIL documentation...
Title: DevIL on Mac OS X Tiger
Post by: numberR on September 17, 2005, 09:36:49
http://unixforge.org/~numberr/data/lwjgl_devil-20050917.zip

liblwjgl-devil.jnilib included in zip file above is one that i commented out call for ilutInit() in ILUT.ilutInit().
other *.dylib are compiled staticly with all image libraries and should work with installing them in wherever java.library.path looks up.

could someone comfirm it works?
i really want to solve this issue before LWJGL 1.0 to be released...