• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Leopard SDK 10.4 strange phenomena libc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Leopard SDK 10.4 strange phenomena libc


  • Subject: Leopard SDK 10.4 strange phenomena libc
  • From: "mm w" <email@hidden>
  • Date: Wed, 31 Oct 2007 13:47:33 -0700

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Leopard SDK 10.4 strange phenomena libc
      • From: Terry Lambert <email@hidden>
  • Prev by Date: IOHIDSystem.h Question In Leopard
  • Next by Date: exception chaining and gdb watchpoints
  • Previous by thread: IOHIDSystem.h Question In Leopard
  • Next by thread: Re: Leopard SDK 10.4 strange phenomena libc
  • Index(es):
    • Date
    • Thread