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


Michael Johnston wrote:
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

On 5-Apr-05, at 3:35 AM, Justin Hannus wrote:

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


Michael Johnston wrote:

(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


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



Reply via email to