1

I am learning how to use SWIG, and I am writing a php wrapper for a C library. The extension successfully compiles, but when I try to call the function I get this error:

php: symbol lookup error: /usr/lib/php5/20090626+lfs/fact.so: undefined symbol: fact

hakre
  • 193,403
  • 52
  • 435
  • 836
user683831
  • 51
  • 3
  • What does the code look like? Why use SWIG rather than writing the extension yourself? See http://blog.simonholywell.com/post/1156691738/15-excellent-resources-for-php-extension-development (my blog) for more info. – Treffynnon Mar 30 '11 at 12:18
  • i'm trying to learn how to use SWIG because i have a complex C program i have to embed into my php script..And i don't think it is more efficient to write the extension myself – user683831 Mar 30 '11 at 14:56
  • Where is your code? That error could be caused by all manner of code problems. Alternatively you might consider contacting the maintainers of the SWIG package. – Treffynnon Mar 30 '11 at 14:59
  • @user683831 http://swig.org/mail.html – Treffynnon Mar 30 '11 at 15:01
  • Here is the link to see what my C code looks like :https://docs.google.com/?authuser=0#home – user683831 Mar 30 '11 at 15:04
  • @user683831 That is not your code but a link to the google docs login screen. I would suggest that you post this question to the mailing list that I pointed you to above. The creators of the package are far more likely to know the answer. You could, if you wanted to, direct them to this question so they can answer it here. – Treffynnon Mar 30 '11 at 15:09
  • I tried to paste my code in this thread but it seems it doesn't work...that's why i tried to give the link of my google docs – user683831 Mar 30 '11 at 15:17
  • is there a way to upload something in this website?? – user683831 Mar 30 '11 at 15:19
  • You can use http://www.pastie.org/ – Maxime Pacary Mar 30 '11 at 20:12

1 Answers1

0

Your problem is probably due to a mismatch in the name of the module (see %module, or passed on the command line) and the name of the .so file you are generating.

PHP, or any system that accepts loadable binary modules, is going to make certain assumptions about the name of the entry point into the library it is trying to load. PHP seems to be assuming that the file name (fact.so) is going to contain a function called "fact".

When you run SWIG, explicitly setting the module name to "fact" will probably solve your problem. If not, posting the generated SWIG source file could help us debug your problem.

lefticus
  • 3,346
  • 2
  • 24
  • 28