编译和使用 Live555 库 - Windows 和 MinGW(未解决的引用)
Compile and use Live555 libs - Windows and MinGW (unresolved references)
我正在尝试使用 MinGW 在 Windows 上编译 Live555 库。
官方并没有具体说明如何去做(只针对VC和Borland)。
我编辑了 win32config 所以它说:
NODEBUG=1
TARGETOS = WINNT
UI_OPTS = $(guilflags) $(guilibsdll)
CONSOLE_UI_OPTS = $(conlflags) $(conlibsdll)
CPU=i386
TOOLS32 = C:\Tools\mingw491_32\bin
COMPILE_OPTS = $(INCLUDES) $(cdebug) $(cflags) $(cvarsdll) -I. -I"$(TOOLS32)\include"
C = c
C_COMPILER = "$(TOOLS32)\gcc.exe"
C_FLAGS = $(COMPILE_OPTS)
CPP = cpp
CPLUSPLUS_COMPILER = "$(TOOLS32)\g++.exe"
CPLUSPLUS_FLAGS = $(COMPILE_OPTS)
OBJ = o
LINK = $(CXX) -o
LIBRARY_LINK = $(LD) -o
LIBRARY_LINK_OPTS = $(LINK_OPTS) -r -Bstatic
LINK_OPTS = -L.
CONSOLE_LINK_OPTS = $(LINK_OPTS_0) $(CONSOLE_UI_OPTS)
SERVICE_LINK_OPTS = kernel32.lib advapi32.lib shell32.lib -subsystem:console,$(APPVER)
LIB_SUFFIX = lib
LIBS_FOR_CONSOLE_APPLICATION =
LIBS_FOR_GUI_APPLICATION =
MULTIMEDIA_LIBS = winmm.lib
EXE = .exe
PLATFORM = Windows
rc32 = "$(TOOLS32)\bin\rc"
.rc.res:
$(rc32) $<
然后我 运行 genWindowsMakefiles.cmd 文件,它在子文件夹中创建了 *.mak 文件。我将它们重命名为 Makefile,并在每个子文件夹中创建一个 运行 make:UsageEnvironment、groupsock、liveMedia、BasicUsageEnvironment。
这给了我 *.lib 文件,但是当我在我的项目中 link 它们时,我得到了很多未解决的引用,如下所示:
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicUsageEnvironment.cpp:(.text+0x502): undefined reference to `_imp__WSAGetLastError@0'
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicTaskScheduler.cpp:(.text+0xf89): undefined reference to `_imp__closesocket@4'
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicTaskScheduler.cpp:(.text+0x11ca): undefined reference to `_imp__select@20'
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicTaskScheduler.cpp:(.text+0x11e1): undefined reference to `_imp__WSAGetLastError@0'
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicTaskScheduler.cpp:(.text+0x147a): more undefined references to `__WSAFDIsSet@8' follow
和错误:
c:/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: c:/Tools/live555/libgroupsock.lib: warning: COMDAT symbol '.eh_frame$_ZNK10NetAddress4dataEv' does not match section name '.eh_frame'
c:/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: c:/Tools/live555/libliveMedia.lib: warning: COMDAT symbol '.eh_frame$_ZNK9HashTable7IsEmptyEv' does not match section name '.eh_frame'
c:/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: c:/Tools/live555/libBasicUsageEnvironment.lib: bad reloc address 0x1c in section `.text$_ZN13DelayIntervalC1Ell[__ZN13DelayIntervalC1Ell]'
知道我做错了什么吗?我该如何解决?
MinGW 更接近于 Unix 风格的 makefile,而不是试图适应 VC makefile,你应该尝试:
./genMakefiles mingw
make
我设法解决了这个问题。未定义的引用来自 winsock 库。它在编译 live555 时被链接,但我没有在我的项目中使用 live555 链接(我不知道我应该)。
在链接选项中添加 -lws2_32 解决了问题。
在摆弄编译时,我还遇到了对许多带有“_unwind_”关键字的函数的未定义引用——原因是构建 live555 时使用的编译器版本与项目不兼容。
我正在尝试使用 MinGW 在 Windows 上编译 Live555 库。 官方并没有具体说明如何去做(只针对VC和Borland)。 我编辑了 win32config 所以它说:
NODEBUG=1
TARGETOS = WINNT
UI_OPTS = $(guilflags) $(guilibsdll)
CONSOLE_UI_OPTS = $(conlflags) $(conlibsdll)
CPU=i386
TOOLS32 = C:\Tools\mingw491_32\bin
COMPILE_OPTS = $(INCLUDES) $(cdebug) $(cflags) $(cvarsdll) -I. -I"$(TOOLS32)\include"
C = c
C_COMPILER = "$(TOOLS32)\gcc.exe"
C_FLAGS = $(COMPILE_OPTS)
CPP = cpp
CPLUSPLUS_COMPILER = "$(TOOLS32)\g++.exe"
CPLUSPLUS_FLAGS = $(COMPILE_OPTS)
OBJ = o
LINK = $(CXX) -o
LIBRARY_LINK = $(LD) -o
LIBRARY_LINK_OPTS = $(LINK_OPTS) -r -Bstatic
LINK_OPTS = -L.
CONSOLE_LINK_OPTS = $(LINK_OPTS_0) $(CONSOLE_UI_OPTS)
SERVICE_LINK_OPTS = kernel32.lib advapi32.lib shell32.lib -subsystem:console,$(APPVER)
LIB_SUFFIX = lib
LIBS_FOR_CONSOLE_APPLICATION =
LIBS_FOR_GUI_APPLICATION =
MULTIMEDIA_LIBS = winmm.lib
EXE = .exe
PLATFORM = Windows
rc32 = "$(TOOLS32)\bin\rc"
.rc.res:
$(rc32) $<
然后我 运行 genWindowsMakefiles.cmd 文件,它在子文件夹中创建了 *.mak 文件。我将它们重命名为 Makefile,并在每个子文件夹中创建一个 运行 make:UsageEnvironment、groupsock、liveMedia、BasicUsageEnvironment。 这给了我 *.lib 文件,但是当我在我的项目中 link 它们时,我得到了很多未解决的引用,如下所示:
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicUsageEnvironment.cpp:(.text+0x502): undefined reference to `_imp__WSAGetLastError@0'
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicTaskScheduler.cpp:(.text+0xf89): undefined reference to `_imp__closesocket@4'
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicTaskScheduler.cpp:(.text+0x11ca): undefined reference to `_imp__select@20'
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicTaskScheduler.cpp:(.text+0x11e1): undefined reference to `_imp__WSAGetLastError@0'
c:/Tools/live555/libBasicUsageEnvironment.lib:BasicTaskScheduler.cpp:(.text+0x147a): more undefined references to `__WSAFDIsSet@8' follow
和错误:
c:/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: c:/Tools/live555/libgroupsock.lib: warning: COMDAT symbol '.eh_frame$_ZNK10NetAddress4dataEv' does not match section name '.eh_frame'
c:/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: c:/Tools/live555/libliveMedia.lib: warning: COMDAT symbol '.eh_frame$_ZNK9HashTable7IsEmptyEv' does not match section name '.eh_frame'
c:/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: c:/Tools/live555/libBasicUsageEnvironment.lib: bad reloc address 0x1c in section `.text$_ZN13DelayIntervalC1Ell[__ZN13DelayIntervalC1Ell]'
知道我做错了什么吗?我该如何解决?
MinGW 更接近于 Unix 风格的 makefile,而不是试图适应 VC makefile,你应该尝试:
./genMakefiles mingw
make
我设法解决了这个问题。未定义的引用来自 winsock 库。它在编译 live555 时被链接,但我没有在我的项目中使用 live555 链接(我不知道我应该)。 在链接选项中添加 -lws2_32 解决了问题。
在摆弄编译时,我还遇到了对许多带有“_unwind_”关键字的函数的未定义引用——原因是构建 live555 时使用的编译器版本与项目不兼容。