ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

奇怪的错误:在Windows上使用PHP7编译时出现无法解析的符号

2019-10-27 07:29:11  阅读:292  来源: 互联网

标签:shared-libraries static-libraries unresolved-external php


我有一个奇怪的问题:我有一个项目,其中使用了PHP7(php7ts.lib).

PHP7是使用VS 2015自行编译的:

--enable-mbstring=static --with-gd=static --with-iconv=static 
--enable-soap --enable-sockets --disable-ipv6 --with-dom 
--disable-bcmath --disable-cgi --disable-cli --enable-embed 
--with-bz2=static --enable-com-dotnet --enable-ctype 
--enable-mbregex=static --disable-mbregex-backtrack --enable-odbc --with-mp

同样,但参数数量减少了:

--disable-all --without-libxml --without-dom --enable-sockets 
--enable-embed --enable-com-dotnet --enable-ctype --enable-odbc
--enable-debug 

BZip2也可以自行编译. PHP7的编译也可以,我得到了.lib和.dll文件.然后,我正在编译项目,并且出现了这个奇怪的错误:

error LNK2019: unresolved external symbol __imp__emalloc@@4 referenced in function
unresolved external symbol __imp__efree@@4
unresolved external symbol __imp__zval_dtor_func@@4
unresolved external symbol __imp__convert_to_string@@4
fatal error LNK1120: 4 unresolved externals

问题是:使用我自己编译的VS2013和PHP 5.6,一切正常.奇怪的是,未解析的符号指向的内容似乎不是特定于库的.

我正在从这里使用部门:http://windows.php.net/downloads/php-sdk/deps-7.0-vc14-x86.7z

我知道我丢失了一些东西,但是从这些消息中我看不到我丢失了什么.

编辑:一些新的-可能有用的-见解

好的,我现在可以获得更多信息,也许这可以帮助我们找到解决方案.

首先,我将以32位架构的Debug模式进行构建.

在cpp文件中,有以下几行(例如__imp__efree @@ 4错误的示例:

#if PHP_VERSION_ID >= 70000
    #   define FREE_ZVAL(z) efree_rel(z)
#endif

当我转到efree_rel(z)的定义时,我看到以下行(与Zend有关):

#define efree_rel(ptr)                          _efree((ptr) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)

转到_efree的定义,我看到以下内容:

ZEND_API void   ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);

这意味着该功能来自PHP7 / Zend.该行位于文件zend_alloc.h中.因此,据我所知,我应该看看此文件是在lib还是dll文件中导出的.所以放弃出口给了我(对于lib):

Dump of file php7ts_debug.lib
File Type: LIBRARY
     Exports
       ordinal    name
                  _efree@@20

对于dll:

Dump of file php7ts_debug.dll
File Type: DLL
  Section contains the following exports for php7ts_debug.dll
    00000000 characteristics
    56EAF08F time date stamp Thu Mar 17 18:59:43 2016
        0.00 version
           1 ordinal base
        1531 number of functions
        1531 number of names
    ordinal hint RVA      name
        192   18 0028FFE0 _efree@@20 = @ILT+24528(_efree@@20)

我敢肯定,我正在对当前的lib进行操作,因为重命名该lib会给我一个错误,即该lib丢失了.

但是问题还没有解决

解决方法:

您需要将项目更新为VS2015项目.
所有未解决的函数都具有ZEND_FASTCALL调用约定(zend_portability.h):

#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
# define ZEND_FASTCALL __attribute__((fastcall))
#elif defined(_MSC_VER) && defined(_M_IX86) && _MSC_VER == 1700
# define ZEND_FASTCALL __fastcall
#elif defined(_MSC_VER) && _MSC_VER >= 1800 && !defined(__clang__)
# define ZEND_FASTCALL __vectorcall
#else
# define ZEND_FASTCALL
#endif

静态库php7ts.lib是使用VS2015和__vectorcall调用约定(https://msdn.microsoft.com/en-us/library/dn375768.aspx)构建的:

Function names are suffixed with two “at” signs (@@) followed by the number of bytes (in decimal) in the parameter list

标签:shared-libraries,static-libraries,unresolved-external,php
来源: https://codeday.me/bug/20191027/1942811.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有