PDA

View Full Version : Linking to dylib in xCode


Jones
2006.06.24, 03:56 PM
I know I've already asked this in a past thread, somewhat directly linked to the topic. But nobody seems to be posting there. I don't want to be a nuisance, but I kinda need this problem solved, and google is not helping.

I'm trying to use DevIL in the simple template project seen on OneSadCookie's webpage, unfortunatly, I'm not sure where DevIL installed the libraries or how to link to them in xCode. It says they've been installed in the ./include and ./lib directories. I assume it means /usr/include & /usr/lib, but the files aren't there. So instead, I extracted them from the package and dragged them into my xCode project. (The libs and the include headers.)

Upon build I was notified by three warnings that the libraries had not been found... well, they're right there! I then cleaned my build, and tried again. No warnings! :blink:

I have yet to try some DevIL commands, but in the meantime, is there a way to link to them so as not to always have to copy them into my project directory? It's not too much of a bother, It justs seems more code-savvy and efficient.

Thanks!

Jones
2006.06.24, 04:43 PM
Well, now I get the errors again, as soon as I try to use an actual command from those libraries. They say they should be in /sw/lib and /sw/include, but the /sw directory itself does not exist. Perhaps I should try expanding all the packages to said directory? That would include everything, including DevIL and all corresponding neccessary packages in one place. I'll try that...

Jones
2006.06.24, 11:22 PM
Well, I tried extracting all neccessary files to a folder I made called /sw/. I put in all corresponding stuff (headers), and hit build. Unfortunatly, it was not properly following the alias's I made because they were not true unix links. I have a book about unix lying around here somewhere. Maybe I'll try again with some official unix links, not just Mac OS X aliases.

Or better yet, I'll just rename the files it wants.

For those who didn't follow that because I made in unclear what I was describing: ;)

The dylibs are named, for example cool.3.2.4.dylib. The headers demand just:

cool.3.dylib So, what the developers did for a couple of them, is make Unix links or "pointers" to them, I tried with Aliases, but Mac OS X using the un-friendly shortcuts it does, it did not work.

Damn this is frustrating.

Well it compiles, but does not run due to SIGBUS errors. Which is funny, since the same code compiled fine before I added DevIL to the project, and told it to load an image. Here's the source:



#include <stdlib.h>
#include <cstring>
#include <iostream>

#include <GLUT/glut.h>

#include "IL/ilut.h"

GLuint myTexture[1];

void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);


glutSwapBuffers();
}


void reshape(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, width, 0.0, height);
}


int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("GLUT & OpenGL program");
init();

ilutRenderer(ILUT_OPENGL);
myTexture[0] = ilutGLLoadImage("colors.bmp");

glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}

Cochrane
2006.06.25, 04:04 AM
You should find the libraries installed under /usr/local/lib. If anything talks about /sw, that is usually a sign that those libraries originate from the Fink project (http://www.finkproject.org/), it might be a better idea to just install Fink and use this to install the libraries (although it does work the other way, too).

Some notes about why your code doesn't run: Before doing anything with DevIL, you'll have to call ilInit() and iluInit() (in that order). After you're finished with DevIL, you should call ilShutDown(). I'm also not quite sure if ilutGLLoadImage is really what you want. Looking at my old code, I see that I didn't use it, but I've forgotten why.

Jones
2006.06.25, 09:49 PM
You should find the libraries installed under /usr/local/lib. If anything talks about /sw, that is usually a sign that those libraries originate from the Fink project (http://www.finkproject.org/), it might be a better idea to just install Fink and use this to install the libraries (although it does work the other way, too).

Some notes about why your code doesn't run: Before doing anything with DevIL, you'll have to call ilInit() and iluInit() (in that order). After you're finished with DevIL, you should call ilShutDown(). I'm also not quite sure if ilutGLLoadImage is really what you want. Looking at my old code, I see that I didn't use it, but I've forgotten why.

I was sure for iLUT i'd just need the ilutRenderer, but with those two new commands the code works fine. Doesn't display the image, but I'm still figuring that part out.

Thanks! :D

Jones
2006.06.26, 05:14 PM
Figured I'd add this, as an intresting sidenote:

It doesn't need the include folders with headers to be in the project directory to compile successfully, but of course, does need the libraries.

And is it not strange that the Carbon target type offers no way to add additional gcc tags? :shock:

OneSadCookie
2006.06.26, 06:08 PM
eh? All the targets provide the same ability to set compiler and linker flags...