Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Leopard SDK 10.4 strange phenomena libc



Hi all, i provide a simple example:

 ------------------------------------------------------
bundle.c
 ------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>

static int foo(const char *name)
{
	const char *n = name;
	
	if(n)
		system("ls -la /");
	
	return 0;
}

static int bar(void)
{
	return foo("Finder");
}

int init(void) {
	return bar();
}
 ------------------------------------------------------

$ gcc -mmacosx-version-min=10.4  -fPIC -c src/bundle.c -arch i686
-arch ppc -ansi -Wall -O2 -o build/bundle.o
$ nm build/bundle.o
00000000 T _init
         U _system

$ gcc -c src/bundle.c -arch i686 -arch ppc -ansi -Wall -O2 -o build/bundle.o
$ nm build/bundle.o
00000000 T _init
         U _system$UNIX2003

AFAIK... everything is going well

in fact, i was in the same case with a bigger project, but i got an
error from ld:

$ gcc -c src/obj.c -arch i686 -arch ppc -ansi -Wall -O2 -o build/obj.o
$ gcc -bundle build/obj.o -o build/obj.so -mmacosx-version-min=10.4
-arch i686 -arch ppc -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
-framework CoreFoundation

Undefined symbols for architecture i386:
  "_system$UNIX2003", referenced from:
      _method in obj.o
....

the selected dylib object was the good one, but my produced object was
rotten, a 10.5-libc-stub symbol was catched:

$ nm build/obj.o
00000000 T _init
         U _system$UNIX2003

first i thought it was a option problem, 'maybe?' something was
dropped , after many investigations, i discovered the only difference
between my simple build test and my code was the order of my 'include'
files,

----------------------------------------------------
#include <linkedlib.h>
#include <CoreFoundation/CoreFoundation.h>
----------------------------------------------------

then, i decided to make the following tests:

----------------------------------------------------
#include <CoreFoundation/CoreFoundation.h> /* stdio.h stdlib.h */
#include <linkedlib.h>
----------------------------------------------------

----------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <linkedlib.h>
#include <CoreFoundation/CoreFoundation.h>
----------------------------------------------------

and everything's back to normal, i also made a new test, i removed my
standard headers from my simple test file:

$ gcc -fPIC -c src/bundle.c -arch i686 -arch ppc -ansi -Wall -O2 -o
build/bundle.o
src/bundle.c: In function 'foo':
src/bundle.c:7: warning: implicit declaration of function 'system'
src/bundle.c: In function 'foo':
src/bundle.c:7: warning: implicit declaration of function 'system'
$ nm build/bundle.o
00000000 T _init
         U _system

Does this make any sense to you?

-mmw
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-kernel/email@hidden

This email sent to email@hidden



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.