mingw libtool gcc无法解析其他库中的引用

时间:2018-09-21 08:35:24

标签: gcc mingw libtool

不是我的代码(AGAR GUI),但是在Linux中可以正常编译。

现在我正在尝试在mingw64(Win)中构建它,在构建其中一个库(libag_gui.la)时出现此错误:

.libs/**drv_sdl2.o**:drv_sdl2.c:(.rdata$.refptr.agCondEndRender[.refptr.agCondEndRender]+0x0): undefined reference to `agCondEndRender'

agCondEndRender存在于另一个名为ag_core的库中,该库包含一个文件 time_renderer.c(.o,,.lo)的定义位置。

该库的构建方式如下:

../mk/libtool/libtool --quiet --mode=link                   gcc -o **libag_core.la**                    -no-undefined -Wl,--no-undefined -XCClinker -static-libgcc                 -rpath /c/msys64/mingw64/lib                      -version-info 5:0:0
   time_win32.lo time_posix.lo **time_renderer.lo** net.lo net_dummy.lo user_win32.lo variable.lo config.lo core.lo error.lo event.lo object.lo prop.lo timeout.lo class.lo cpuinfo.lo data_source.lo load_string.lo load_version.lo vsnprintf.lo vasprintf.lo asprintf.lo dir.lo md5.lo sha1.lo rmd160.lo file.lo string.lo dso.lo tree.lo time.lo time_dummy.lo db.lo tbl.lo getopt.lo exec.lo text.lo user.lo user_dummy.lo                   -lpthread     -lwinmm

该库(ag_core)用于构建问题库,如下所示:

../mk/libtool/libtool --quiet --mode=link                   gcc -o **libag_gui.la**                     -no-undefined -Wl,--no-undefined -XCClinker -static-libgcc                 -rpath /c/msys64/mingw64/lib                      -version-info 5:0:0
   drv_sdl2_common.lo **drv_sdl2.lo** drv_gl_common.lo drv_wgl.lo drv.lo drv_sw.lo drv_mw.lo gui.lo widget.lo window.lo iconmgr.lo geometry.lo colors.lo cursors.lo ttf.lo text.lo keymap.lo keymap_latin1.lo keymap_compose.lo keysyms.lo editable.lo box.lo label.lo button.lo checkbox.lo textbox.lo radio.lo fixed_plotter.lo tlist.lo scrollbar.lo spinbutton.lo titlebar.lo toolbar.lo fspinbutton.lo combo.lo ucombo.lo units.lo nlunits.lo hsvpal.lo mspinbutton.lo mfspinbutton.lo statusbar.lo menu.lo menu_view.lo treetbl.lo separator.lo notebook.lo pixmap.lo file_dlg.lo objsel.lo fixed.lo numerical.lo table.lo glview.lo mpane.lo pane.lo console.lo graph.lo socket.lo icon.lo progress_bar.lo slider.lo text_cache.lo load_surface.lo load_color.lo load_xcf.lo file_selector.lo scrollview.lo font_selector.lo time_sdl.lo debugger.lo surface.lo widget_legacy.lo global_keys.lo input_device.lo mouse.lo keyboard.lo packedpixel.lo load_bmp.lo load_jpg.lo load_png.lo dir_dlg.lo anim.lo stylesheet.lo              **-L../core -lag_core**  -L/mingw64/lib -lSDL2 -LC:/msys64/mingw64/lib -lfreetype  -L/c/msys64/mingw64/lib -lopengl32 -lgdi32   -L/c/msys64/mingw64/lib -ljpeg -L/mingw64/lib -lpng16
-lm

(编辑:添加了lib ag_core的objdump)

objdump -t libag_core.a | grep agCond 
[ 40](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000008 agCondBeginRender 
[ 41](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000008 agCondEndRender 
[ 42](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000008 agCondRenderLock

objdump -t libag_core-5.dll | grep agCond
[4031](sec  6)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000001710 agCondEndRender
[4117](sec  6)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000001718 agCondRenderLock
[4330](sec  6)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000000001720 agCondBeginRender

我不确定该输出的含义,但是libag_core.a似乎不正确!为什么所有值都为0x0 ... 08?

这是time_renderer.c的前几行(似乎没有任何#ifdefs

/*  Public domain   */
/*
 * Rendering-aware time backend. This is useful for applications performing
 * offline rendering, where the outcome of the rendering may be influenced by
 * different threads, each using AG_Delay() calls or Agar timers.
 *
 * Using this backend, the start of a rendering cycle causes AG_Delay() to
 * block until the rendering cycle is complete.
 */

#include <sys/types.h>
#include <time.h>
#include <string.h>
#include <unistd.h>

#include <agar/core/core.h>

AG_Cond agCondBeginRender;
AG_Cond agCondEndRender;
AG_Mutex agCondRenderLock;

static struct timespec t0;

关于我应该看什么的任何线索吗?

1 个答案:

答案 0 :(得分:1)

原来是libtool。除非另行说明,否则A​​GAR GUI附带使用它自己的版本。它包含在AGAR子文件夹mk / libtool中。

将--with-libtool = / usr / bin / libtool(以使用其他一些libtool)添加到./configure命令行中,如下所示:

./configure --host=x86_64-w64-mingw32       --prefix=$MINGWROOT       --enable-debug       --with-{freetype,sdl,png,jpeg,gl}=$MI
NGWROOT  --with-libtool=/usr/bin/libtool     --without-{fontconfig,sndfile,gettext,iconv}

您可能需要像这样将--tag CC添加到mk / build.lib.mk中:

LIBTOOLOPTS?=   --tag CC    --quiet

似乎AGAR捆绑的libtool有点旧了!