无法在 PHP 上编译共享扩展

Can't compile shared extension on PHP

我有一个扩展名为 PHP 的文件,我已经维护了一段时间,它的所有内容都在一个目录中。然后我将一些文件移动到一个新目录 wb/ 中,并适当地添加了源,但是编译扩展会抛出这个错误:

   Creating library Release_TS\php5ts.lib and object Release_TS\php5ts.exp
wb_winsys.obj : error LNK2019: unresolved external symbol _wbError referenced in
 function _wbInit
wb_bitmap.obj : error LNK2001: unresolved external symbol _wbError
wb_control.obj : error LNK2001: unresolved external symbol _wbError
wb_control_toolbar.obj : error LNK2001: unresolved external symbol _wbError
wb_generic.obj : error LNK2001: unresolved external symbol _wbError
wb_winsys.obj : error LNK2019: unresolved external symbol _wbMalloc referenced i
n function _wbInit
wb_control_toolbar.obj : error LNK2001: unresolved external symbol _wbMalloc
wb_font.obj : error LNK2001: unresolved external symbol _wbMalloc
wb_generic.obj : error LNK2001: unresolved external symbol _wbMalloc
wb_window.obj : error LNK2001: unresolved external symbol _wbMalloc
wb_bitmap.obj : error LNK2001: unresolved external symbol _wbMalloc
wb_control.obj : error LNK2001: unresolved external symbol _wbMalloc
wb_control_calendar.obj : error LNK2001: unresolved external symbol _wbMalloc
wb_control_menu.obj : error LNK2001: unresolved external symbol _wbMalloc
wb_window.obj : error LNK2019: unresolved external symbol _wbFree referenced in
function _wbSetTimer
wb_winsys.obj : error LNK2001: unresolved external symbol _wbFree
wb_bitmap.obj : error LNK2001: unresolved external symbol _wbFree
wb_control.obj : error LNK2001: unresolved external symbol _wbFree
wb_font.obj : error LNK2001: unresolved external symbol _wbFree
wb_generic.obj : error LNK2001: unresolved external symbol _wbFree
wb_bitmap.obj : error LNK2019: unresolved external symbol _WideChar2Utf8 referen
ced in function _ReadBitmap
wb_winsys.obj : error LNK2001: unresolved external symbol _WideChar2Utf8
wb_control.obj : error LNK2019: unresolved external symbol _wbCallUserFunction r
eferenced in function _wbRefreshControl
wb_window.obj : error LNK2001: unresolved external symbol _wbCallUserFunction
Release_TS\php5ts.dll : fatal error LNK1120: 5 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
\VC\BIN\cl.exe"' : return code '0x2'
Stop.

C:\Users\Administrator\Desktop\phc-win>

这让我相信它没有正确链接。

配置如下:

// $Id$
// vim:ft=javascript

ARG_WITH("winbinder", "Include windows GUI support", "no");

if (PHP_WINBINDER == "yes") {
    CHECK_HEADER_ADD_INCLUDE("wb/wb.h", "CFLAGS_INTL")

    EXTENSION("winbinder", "phpwb_bitmap.c phpwb_control.c phpwb_control_listview.c\
    phpwb_control_menu.c phpwb_control_toolbar.c phpwb_control_treeview.c\
    phpwb_draw.c phpwb_export.c phpwb_font.c phpwb_generic.c phpwb_lowlevel.c\
    phpwb_sysdlg.c phpwb_wb_lib.c phpwb_window.c phpwb_winsys.c", "-Iext\wibinder\wb");

    ADD_SOURCES("ext\winbinder\wb", "wb_bitmap.c wb_control.c\
    wb_control_calendar.c wb_control_html.c wb_control_hyperlink.c\
    wb_control_listview.c wb_control_menu.c wb_control_tab.c wb_control_toolbar.c\
    wb_control_treeview.c wb_draw.c wb_font.c wb_generic.c wb_lowlevel.c\
    wb_sysdlg.c wb_window.c wb_winsys.c")

    AC_DEFINE('HAVE_WINBINDER', 1, 'Include windows GUI support', false);
}

如果需要,可以在 https://github.com/stefan-loewe/WinBinder 找到代码,但这应该只是我的配置问题。任何帮助将不胜感激!

正如@Jack 在评论中所说,答案是在命令行中包含 -lwb。这使链接器正常工作,一切都很好!

TL;DR: 不要忘记配置链接器