swig无法创建php libnetcdf扩展

时间:2012-02-19 20:20:43

标签: php swig netcdf

我需要将libnetcdf与PHP接口。 (谷歌代码上的php-netcdf已损坏)

这是netcdf.i:

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

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

我做了:

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

但是当在php中加载扩展时,我得到:

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

这是我第一次尝试这样的东西。我错过了什么吗?

ADDED -lnetcdf flag。

现在,我得到了:未定义的符号:zend_error_noreturn。修复netcdf_wrap.c中的zend_error替换zend_error_noreturn

2 个答案:

答案 0 :(得分:1)

您的直接问题是由于没有链接到libnetcdf引起的。您需要gcc的-l标志才能这样做:

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

答案 1 :(得分:0)

Google代码中的php-netcdf没有被破坏,它只是未完成而且不再维护。然而,其中一个贡献者,Santi Oliveras,似乎设法使用它。试着联系他,也许他有一些新的代码或其他东西。或者随意接受这个项目。

P.S。我是作者。