image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
LinkBack Thread Tools
  #1  
Old January 13th, 2002, 07:35 PM
couzteau's Avatar
Registered User
 
Join Date: Nov 2001
Location: germany
Posts: 102
Thanks: 0
Thanked 0 Times in 0 Posts
couzteau is on a distinguished road
Question how to build a shared object in OSX

how to build a shared object in OSX

hello,

this question comes in two flavors:

1. how do i normally implement something like shared objects with
project buider mac os x 10.1? is that a library or a framework or ...???

2. how do i create a shared object on the command line using cc? i'm
working on a project that has been developed on linux/solaris and has
some quite sophisticated makefiles. can modify and keep them? i'
currently stuck because good ol'"cc -shared libacl.so ..." doesn't
work. the compiler is complaining because main is not defined.

thanks

jochen
Reply With Quote
  #2  
Old January 14th, 2002, 10:36 AM
Registered User
 
Join Date: Jan 2002
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
nether is on a distinguished road
Porting Tips ...

Head over to http://gnu-darwin.sourceforge.net/porting.html ... they provide tips for porting programs over to darwin. One of the tips is how to create dummy libraries for those you are missing ...

It doesn't cover shared libraries, but there's enough there to get you started and point you in the right direction.

You can probably also ask on their mailing list how you might go about doing shared libaries.

Good Luck,
__nether
Reply With Quote
  #3  
Old January 14th, 2002, 10:42 AM
Registered User
 
Join Date: Jan 2002
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
nether is on a distinguished road
Part two :)

Hey missed some of the answers.

Answer 1: It depends on your application ... What do you want to do with it? Should it be portable? If so, it should be a unix style shared library. If it's just for OS X, then a framework will be better.

Answer 2: See my post above. In addition:
When you compile a large program (and libraries in your case), you need to first compile the object files, then link then. When you do a straight cc, you are telling the compiler to both compile and link then. What you want to do is in CFLAGS, add a -c (and also probably -no-cpp-precompile). You might also need to do -flat_namespace and quite possibly -traditional_cpp.

Take a look at the release notes of Project Builder.

__nether
Reply With Quote
  #4  
Old January 14th, 2002, 12:08 PM
couzteau's Avatar
Registered User
 
Join Date: Nov 2001
Location: germany
Posts: 102
Thanks: 0
Thanked 0 Times in 0 Posts
couzteau is on a distinguished road
with the following line: does it

thanks for your reply and the link to sourceforge. i solved my problem
Reply With Quote
  #5  
Old January 14th, 2002, 12:13 PM
couzteau's Avatar
Registered User
 
Join Date: Nov 2001
Location: germany
Posts: 102
Thanks: 0
Thanked 0 Times in 0 Posts
couzteau is on a distinguished road
Thumbs up thanks

i looked it up in a makefile. you have to compile the sources with the flag -dynamic and then rename the object files in mylib.so

many thanx
couzteau
Reply With Quote
  #6  
Old January 22nd, 2002, 05:41 AM
couzteau's Avatar
Registered User
 
Join Date: Nov 2001
Location: germany
Posts: 102
Thanks: 0
Thanked 0 Times in 0 Posts
couzteau is on a distinguished road
replace the compiler option
-shared
to build a shared lib
with
-dynamiclib.

the object files that are used to build the shared object have to be compiled with
-fno_commons
as gcc flag to avoid namespaceproblems.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to build MING for OSX - Anyone did the module? snipper Mac OS X System & Mac Software 1 December 18th, 2005 03:12 PM
how to build a shared object in OSX couzteau Software Programming & Web Scripting 1 January 13th, 2002 04:27 PM
Will the current build update osx Server? Dotman Apple News, Rumors & Discussion 2 September 25th, 2001 08:06 PM


All times are GMT -5. The time now is 07:17 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.