Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Porting Linux/*nix shell apps to Darwin problems

Porting Linux/*nix shell apps to Darwin problems
Thread Tools
Dedicated MacNNer
Join Date: May 2001
Location: Paris, France
Status: Offline
Reply With Quote
May 13, 2001, 07:55 AM
 
Hello,
me and two developpers want to port their work to Darwin. I'm the one who best known darwin altough i didn't even have it, so I'm doing it via ssh on a friend MacOSX computer (I'll have a G4 soon

However we have a problem with libstdc++, because the program is written in c++. On linux we use libnsl. This lib doesn't exist on darwin.
Here's the make error log:

Code:
% make cc -g -Wall -pedantic -D_REENTRANT -DDARWIN -shared -o libhl.so hlbaseobject.o h lconnection.o hlexception.o hlglobal.o hlobject.o hlsocket.o hlsysdep.o hltransa ction.o hltransfer.o -lstdc++ -lpthread /usr/bin/ld: Undefined symbols: _main ___builtin_delete ___builtin_new ___builtin_vec_delete ___builtin_vec_new ___cp_pop_exception ___cp_push_exception ___eh_rtime_match ___rtti_ptr ___rtti_si ___start_cp_handler ___throw ___uncatch_exception _terminate__Fv ___eh_alloc ___tfi ___rtti_user make: *** [libhl.so] Error 1
Since I can't find many c++ example programs for darwin around the web, and Apple Developper site isn't (or don't seems) very informative about our problems... I wonder if anyone know the solution :-)

It would be very cool indeed =)

Thanx you much,
kang

------------------
hotline://hl.chatonly.org
mp3://radio.chatonly.org
hotline://hl.chatonly.org
mp3://radio.chatonly.org
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
May 13, 2001, 11:10 AM
 
I don't know too much about C++ builds, but you might want to use cc++ instead of cc as the command...

As for building shared libraries -- which I think is the main problem -- here's a post from Torrey Lyons from the darwin-development list:

At 2:30 PM -0700 5/9/01, Pierce T. Wetter III wrote:
>cc -g -Wall -fPIC -I. -I.. -I/usr/local/include -I../jabberd/ -shared
>-o pthsock_client.so client.o -L/usr/local/lib -lpth
>
>
> I'm trying to build the Jabber (www.jabber.org) server for Mac OS X.
>
> The above line, which is supposed to be building a shared library
>gives me a whole bunch of link errors instead.
>
> Since one of them is _main, This is probably because I'm missing a
>command line option, that somehow replaces -shared, so its trying to
>build a command instead of a shared library.

The general recipe for building dynamic shared libraries on Darwin is:

1. Compile your object files with the -fno-common option. This isn't
strictly necessary as long as you initialize all your global
variables, but ported code rarely does.

2. Use "-dynamiclib -undefined suppress" to build the dynamic shared
library. Dynamic shared libraries on Darwin use the .dylib suffix
instead of .so.

So a complete build might look like:

cc -fno-common -o afile.o afile.c
cc -fno-common -o bfile.o bfile.c
cc -dynamiclib -undefined suppress -o ablibrary.dylib afile.o bfile.o

PIC options are not necessary because PowerPC code is always position
independent and the Darwin option to generate position independent
code, -dynamic, is on by default.

--Torrey
     
Dedicated MacNNer
Join Date: May 2001
Location: Paris, France
Status: Offline
Reply With Quote
May 13, 2001, 12:48 PM
 
cc++ command doesn't exist...
also I tried to use the other tips but I get the same error
for the dynlibs, i think the c++ lib is libstdc++.a, which don't seems to be dynamic :/
thanx anyway
hotline://hl.chatonly.org
mp3://radio.chatonly.org
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
May 13, 2001, 02:01 PM
 
Sorry, I meant c++, not cc++.

And yes, I don't think there's a dynamic version of libstdc++ around. Not sure if that will prevent you from building a shared library from your stuff or not.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
May 17, 2001, 02:56 PM
 
Originally posted by lindberg:
Not sure if that will prevent you from building a shared library from your stuff or not.
I'm pretty sure it won't.
     
   
Thread Tools
Forum Links
Forum 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 On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:34 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2