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

9
  • What does the code look like? Why use SWIG rather than writing the extension yourself? See blog.simonholywell.com/post/1156691738/… (my blog) for more info. Commented Mar 30, 2011 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 Commented Mar 30, 2011 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. Commented Mar 30, 2011 at 14:59
  • @user683831 swig.org/mail.html Commented Mar 30, 2011 at 15:01
  • Here is the link to see what my C code looks like :docs.google.com/?authuser=0#home Commented Mar 30, 2011 at 15:04

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.