php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48911 embed sapi misses SAPI_API
Submitted: 2009-07-14 07:16 UTC Modified: 2009-07-30 16:10 UTC
From: thomas at koch dot ro Assigned:
Status: Closed Package: Compile Failure
PHP Version: 5.3.0 OS: Debian Lenny
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thomas at koch dot ro
New email:
PHP Version: OS:

 

 [2009-07-14 07:16 UTC] thomas at koch dot ro
Description:
------------
I try the most simple program that uses the embed sapi. Due to missing SAPI_API macros the symbols 

int php_embed_init(int argc, char **argv PTSRMLS_DC);
void php_embed_shutdown(TSRMLS_D);
extern sapi_module_struct php_embed_module;

get visibility hidden in the resulting libphp5.so.

Fix: put SAPI_API before these symbols in sapi/embed/php_embed.c.

(Also in php_embed.h ?)

Thanks to ScottMac for the hint on IRC!


Reproduce code:
---------------
#include <sapi/embed/php_embed.h>

int main(int argc, char *argv[]) 
{ 
    PHP_EMBED_START_BLOCK(argc,argv) 
    PHP_EMBED_END_BLOCK() 
    return 0; 
}

Expected result:
----------------
should compile without problems

Actual result:
--------------
gcc  -c -I/usr/local/include/php/ -I/usr/local/include/php/main -
I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM -Wall -g -o 
worker.o worker.c
gcc  -L/usr/local/lib -lphp5 -o worker worker.o
worker.o: In function `main':
/var/checkouts/gearman-php-worker/worker.c:5: undefined reference to 
`php_embed_init'
/var/checkouts/gearman-php-worker/worker.c:6: undefined reference to 
`php_embed_shutdown'
collect2: ld returned 1 exit status
make: *** [all] Error


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-28 21:07 UTC] svn@php.net
Automatic comment from SVN on behalf of jani
Revision: http://svn.php.net/viewvc/?view=revision&revision=286468
Log: - Fixed bug #48911 (embed sapi misses SAPI_API)
 [2009-07-28 21:07 UTC] jani@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2009-07-30 16:10 UTC] garretts@php.net
This patch breaks building php5embed on Windows.

On Windows, php5embed is built as a static library, and doesn?t need these functions to be marked as SAPI_API.

Can I suggest we instead use "EMBED_SAPI_API"? 

-----

#ifndef PHP_WIN32
    #define EMBED_SAPI_API SAPI_API
#else
    #define EMBED_SAPI_API 
#endif 

BEGIN_EXTERN_C() 
EMBED_SAPI_API int php_embed_init(int argc, char **argv PTSRMLS_DC);
EMBED_SAPI_API void php_embed_shutdown(TSRMLS_D);
extern EMBED_SAPI_API sapi_module_struct php_embed_module;
END_EXTERN_C()

 [2009-07-30 20:20 UTC] svn@php.net
Automatic comment from SVN on behalf of garretts
Revision: http://svn.php.net/viewvc/?view=revision&revision=286569
Log: - Updated fix for bug #48911 (embed sapi misses SAPI_API)
#- Windows didn't need SAPI_API
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 03 08:01:28 2025 UTC