Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Fwd: Link order for shared libraries (os x 10.2, gcc 3.1)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Link order for shared libraries (os x 10.2, gcc 3.1)



Oops, I sent "From:" the wrong address. So this did not yet appear on the list.

--
Tk!

Begin forwarded message:

From: <nobody@example,com>
Date: Fri May 16, 2003 11:38:09 PM US/Mountain
To: email@hidden
Subject: Re: Link order for shared libraries (os x 10.2, gcc 3.1)

Dav,
On MacOS X v10.2, I got your test program to compile without warning or error as follows:
[tknowlto@knowltontpismo:/tmp]$ cat main.cc
#include <glu.h>
#include <stdio.h>

int
main()
{
printf("one\n");
gluNewQuadric();
printf("two\n");

}

[tknowlto@knowltontpismo:/tmp]$ g++ main.cc -I /System/Library/Frameworks/OpenGL.framework/Headers -framework OpenGL
[tknowlto@knowltontpismo:/tmp]$

The changes may or may not be interesting to you or relevant to your work: I refer to glu without a GL/ path, since it looks to me like /usr/include (nor the Apple X11 distribution I've got installed) has no GL/ there. I tell the compiler to find the glu.h header by adding /System/Library/Frameworks/OpenGL.framework/Headers to the search path. I tell the compiler to link with the OpenGL framework.

Note also that the way I'm doing it is likely less interesting to folks who may be doing this on a "pure" Darwin system. You appear to be running MacOS (as you state in the subject line) but some other X11 distribution than I've downloaded from Apple. In particular, your X11 appears to provide the OpenGL you're looking for. On my 10.2 system, I get OpenGL support from the "native" OpenGL framework, not X11.

Assuming you'd prefer to write portable code that works on more than MacOS, I think your original source was "more correct" since I think folks who write OpenGL code tend to expect glHeader.h to be found at <GL/glHeader.h> however, without manually adding symlinks to my MacOS installation, I don't see how to preserve that illusion. Sorry.

My conclusion: the OpenGL distribution you're linking against is suspect.

Good luck,
--
Tommy Knowlton

On Thursday, May 15, 2003, at 11:00 PM, email@hidden wrote:

Date: Thu May 15, 2003 12:07:18 PM US/Mountain
Subject: Re: Link order for shared libraries (os x 10.2, gcc 3.1)


Hi,

It appears that no one knows the answer to this question (posted a
couple of days ago.) Could someone at least try compiling it on their
mac and see if they have the same problem?

Thanks,
Dave

Can someone please help me with a problem I have discovered with
linking shared libraries under os x 10.2 (gcc 3.1). With this simple
program:

#include <GL/glu.h>
#include <stdio.h>

int
main()
{
printf("one\n");
gluNewQuadric();
printf("two\n");

}

In the two compilations below, the first works and the second "Bus
error"s. The only difference is the changing the order of the -lglu
and -lgl. (The "weak library" warning does not seem to make a
difference as I have tried with MACOSX_DEP... set to 10.2.)

g++ main.cc -L/usr/X11R6/lib -lglu -lgl -I/usr/X11R6/include
ld: warning dynamic shared library: /usr/X11R6/lib/libgl.dylib not made
a weak library in output with MACOSX_DEPLOYMENT_TARGET environment
variable set to: 10.1
a.out
one
two
g++ main.cc -L/usr/X11R6/lib -lgl -lglu -I/usr/X11R6/include
a.out
one
Bus error

Can anyone tell me what I am doing wrong? Also, how does one figure
out the correct order to link the dylibs in? Any feedback will be
greatly appreciated.

Thanks,
Dav

PS. An email to me in addition to the list response would be
appreciated.

---------------------------------------------------------------------- -
- J. Davison de St. Germain email@hidden (801) 581-4078 -
- Chief Software Engineer http://www.cs.utah.edu/~dav -
- SCI Institute, SE C-SAFE University of Utah -
---------------------------------------------------------------------- -
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.