Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > os x linking issue with extension
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 19th March 05:56
lastobelus
External User
 
Posts: 1
Default os x linking issue with extension



(I'm not sure if extension development belongs on this list, but I
couldn't find a better one. If there is a more appropriate list, could
someone please point me to it?)

I am working on an extension that is os x specific & relies on Carbon &
ApplicationServices (it is a port of appscript, to allow writing
applescript applications in php).

I used ext_skel to create an extension, and ran phpize. In the
config.m4, I put:

PHP_ADD_FRAMEWORK(Carbon)
PHP_ADD_INCLUDE("/Developer/Headers/FlatCarbon")

but when I attempt to use carbon api I get an undefined symbol error
from the dynamic linker.

looking at the configure script generated by phpize, it seemed to me
that the PHP_ADD_FRAMEWORK macro is not actually being used to affect
the build. I attempted to change this by manually editing the configure
script to add $PHP_FRAMEWORKS to the arguments passed to linktool
mode=link, and added PHP_VAR_SUBST="$PHP_FRAMEWORKS". Using make
--debug, I verified that linktool mode=link was now being called with
the -framework param, but I still get the same undefined symbol error.

I don't know much about how the dynamic linker works. What do I need to
do to have extension .so link to carbon?

I am using the 5.0.3 release source package of php, os x 10.3.8, gcc 3.3


Michael Johnston

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
  Reply With Quote


  sponsored links


2 19th March 05:56
phpdev
External User
 
Posts: 1
Default os x linking issue with extension



Although this list should be able to answer the question for you,
another list which might be of assistance/interest to you is pecl-dev.

http://pecl.php.net/support.php

-Jeremy


--
---------------------------
Jeremy Johnstone
http://www.jeremyjohnstone.com
jsjohnst@php.net

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
  Reply With Quote
3 19th March 12:13
jhannus
External User
 
Posts: 1
Default os x linking issue with extension


Can you post a link to your config.m4?

PHP_ADD_FRAMEWORK(Framework) should do the trick. Try having a look at
the config.m4 for the OpenDirectory extension. It links to the
DirectoryService framework. http://pecl.php.net/get/opendirectory-0.2.6.tgz

Curious, what specific part of Carbon are you wrapping. Sounds interesting.

-Justin


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
  Reply With Quote
4 20th March 04:35
lastobelus
External User
 
Posts: 1
Default os x linking issue with extension


Hi,

The config is:

PHP_ARG_WITH(carbonae, for carbonae support,
[ --with-carbonae Include Carbon Apple Events support])

if test "$PHP_CARBONAE" != "no"; then
if test "`(uname) 2>/dev/null`" != "Darwin"; then
AC_MSG_ERROR([--with-carbonae can only be used on Mac OS X
systems.])
fi


PHP_ADD_FRAMEWORK(Carbon)
PHP_ADD_FRAMEWORK(CoreFoundation)
PHP_ADD_FRAMEWORK(CoreServices)
PHP_ADD_FRAMEWORK(ApplicationServices)
PHP_NEW_EXTENSION(carbonae, carbonae.c, $ext_shared)
fi

This extension so far just has a simple function that makes a CFString
to verify that carbon is getting loaded. The extension builds and
loads, but when calling the function I get a symbol not found error
from the dynamic linker.

I want to wrap the Apple Event API, as the first part of porting
appscript
(http://freespace.virgin.net/hamish.sanderson/appscript.html), which is
a python module that allows you to script applications as you would
with applescript. Combined with PHPOSA, php would then become a
scripting language for os x, that can be used to control applications.
I am doing this because as a web developer I am quite familiar with php
as a language, and I am. utterly. sick. of applescript. as a
"language". (but I have to use it quite a lot for automating
QuarkXPress workflow)

Cheers,
Michael Johnston


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
  Reply With Quote
5 20th March 11:12
jhannus
External User
 
Posts: 1
Default os x linking issue with extension


FYI: I've posted this topic to the php.pecl.dev list. You should reply
there, it may be more constructive.
--

Try compiling a your extension as a shared object and loading that into
PHP with the dl() function. This way you can narrow down where the
problem is coming from with the linker without the added confusion of
the PHP build system. Once you figure that out you can go back to the
config.m4 and add whatever you need. An example of these command lines
(on OSX) would be:

$ gcc -fPIC -Wall -g -DCOMPILE_DL_CARBONAE -Iphpsrc \
-Iphpsrc/main -Iphpsrc/regex -Iphpsrc/Zend \
-Iphpsrc/TSRM -c -o carbonae.o carbonae.c

$ cc -bundle -flat_namespace -undefined suppress \
-framework Carbon -o carbonae.so carbonae.o

Just add the needed frameworks with the -framework switch and make sure
that COMPILE_DL_CARBONAE in your extension, if defined, will enable a
line something like:

#if COMPILE_DL_CARBONAE
ZEND_GET_MODULE(carbonae)
#endif

This is done for you with ext_skel or Pecl::Gen, assuming the name of
your extension is "carbonae".

-Justin


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666