Question

I need to interface libnetcdf with PHP. (the php-netcdf on google code is broken)

Here's netcdf.i :

%module netcdf
 %{
 /* Includes the header in the wrapper code */
 #include "netcdf.h"
 %}

 /* Parse the header file to generate wrappers */
 %include "netcdf.h"

I did :

gcc `php-config --includes` -fpic -c netcdf_wrap.c
gcc -shared netcdf_wrap.o -o netcdf.so

but when loading the extension in php, I get :

Unable to load dynamic library netcdf.so:
undefined symbol: ncerr in Unknown on line 0

It's the first time I try something like that. Am I missing something ?

ADDED -lnetcdf flag.

now, I got : undefined symbol: zend_error_noreturn. fixed replacing zend_error_noreturn by zend_error in netcdf_wrap.c

Was it helpful?

Solution

Your immediate problem is caused by not linking against libnetcdf. You need the -l flag for gcc to do so:

gcc -shared netcdf_wrap.o -o netcdf.so -lnetcdf
                                           ☝

OTHER TIPS

php-netcdf at Google Code isn't broken, it's just unfinished and not maintained any more. However, one of the contributors, Santi Oliveras, seems to have managed to use it. Try to contact him, maybe he has some new code or something. Or feel free to take the project over.

P.S. I'm the author.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top