Log in

View Full Version : Linking issues with shared, but not static (Ut Video, MinGW-w64)


qyot27
27th July 2012, 04:55
In trying to figure out the mechanics for getting Ut Video to build as a shared library (the branch I've been using for it on github (https://github.com/qyot27/libutvideo)), I've run into a MinGW-specific problem.

When building as static everything links correctly, no complaining. And building as shared seems to work without any issues on Linux, OS X, or Cygwin. But on MinGW, I'm getting undefined references.
$ ./configure --prefix=../libutvideo-shared --enable-shared && make
debug: no
gprof: no
PIC: no
shared: yes
optlevel: 2

You can run 'make' now.
CXX utv_core/Codec.o
CXX utv_core/Convert.o
CXX utv_core/DummyCodec.o
CXX utv_core/Format.o
CXX utv_core/FrameBuffer.o
CXX utv_core/GlobalConfig.o
CXX utv_core/HuffmanCode.o
CXX utv_core/Predict.o
CXX utv_core/Thread.o
CXX utv_core/TunedFunc.o
CXX utv_core/UL00Codec.o
CXX utv_core/ULRACodec.o
CXX utv_core/ULRGCodec.o
CXX utv_core/ULY0Codec.o
CXX utv_core/ULY2Codec.o
CXX utv_core/utv_core.o
CXX libutvideo-11.1.0.dll
Creating library file: libutvideo-11.1.0.dll.a
utv_core/Format.o:Format.cpp:(.text+0xb1): undefined reference to `MEDIASUBTYPE_RGB24'
utv_core/Format.o:Format.cpp:(.text+0xc3): undefined reference to `MEDIASUBTYPE_RGB24'
utv_core/Format.o:Format.cpp:(.text+0xcb): undefined reference to `MEDIASUBTYPE_RGB24'
utv_core/Format.o:Format.cpp:(.text+0xd3): undefined reference to `MEDIASUBTYPE_RGB24'
utv_core/Format.o:Format.cpp:(.text+0xf1): undefined reference to `MEDIASUBTYPE_RGB32'
utv_core/Format.o:Format.cpp:(.text+0x103): undefined reference to `MEDIASUBTYPE_RGB32'
utv_core/Format.o:Format.cpp:(.text+0x10b): undefined reference to `MEDIASUBTYPE_RGB32'
utv_core/Format.o:Format.cpp:(.text+0x113): undefined reference to `MEDIASUBTYPE_RGB32'
utv_core/Format.o:Format.cpp:(.text+0x131): undefined reference to `MEDIASUBTYPE_ARGB32'
utv_core/Format.o:Format.cpp:(.text+0x143): undefined reference to `MEDIASUBTYPE_ARGB32'
utv_core/Format.o:Format.cpp:(.text+0x14b): undefined reference to `MEDIASUBTYPE_ARGB32'
utv_core/Format.o:Format.cpp:(.text+0x153): undefined reference to `MEDIASUBTYPE_ARGB32'
utv_core/Format.o:Format.cpp:(.text+0x1a7): undefined reference to `MEDIASUBTYPE_YUY2'
utv_core/Format.o:Format.cpp:(.text+0x1b5): undefined reference to `MEDIASUBTYPE_YUY2'
utv_core/Format.o:Format.cpp:(.text+0x1bd): undefined reference to `MEDIASUBTYPE_YUY2'
utv_core/Format.o:Format.cpp:(.text+0x2ca): undefined reference to `MEDIASUBTYPE_YUY2'
utv_core/Format.o:Format.cpp:(.text+0x2d3): undefined reference to `MEDIASUBTYPE_YUY2'
utv_core/Format.o:Format.cpp:(.text+0x2fc): undefined reference to `MEDIASUBTYPE_RGB24'
utv_core/Format.o:Format.cpp:(.text+0x355): undefined reference to `MEDIASUBTYPE_RGB32'
utv_core/Format.o:Format.cpp:(.text+0x371): undefined reference to `MEDIASUBTYPE_ARGB32'
collect2: ld returned 1 exit status
make: *** [libutvideo-11.1.0.dll] Error 1
These definitions seem to be made in uuids.h. Format.cpp includes stdafx.h (which comes with Ut Video), and stdafx.h includes uuids.h.


The actual command used when linking fails:
$ make V=2
g++ -shared -o libutvideo-11.1.0.dll utv_core/Codec.o utv_core/Convert.o utv_core/DummyCodec.o \
utv_core/Format.o utv_core/FrameBuffer.o utv_core/GlobalConfig.o utv_core/HuffmanCode.o utv_core/Predict.o \
utv_core/Thread.o utv_core/TunedFunc.o utv_core/UL00Codec.o utv_core/ULRACodec.o utv_core/ULRGCodec.o \
utv_core/ULY0Codec.o utv_core/ULY2Codec.o utv_core/utv_core.o -Wl,--out-implib,libutvideo-11.1.0.dll.a \
-Wl,--enable-auto-image-base -lole32 -s

If Format.o is removed from the list of objects to link, the .dll build completes successfully. The resultant dll also works as expected when linked to FFmpeg, which makes it seem like MinGW should just ignore Format.cpp altogether (I don't know what that might cost it, though). This is only with shared. MinGW is fine with Format.o being linked in when building the library as static.

uuids.h is present, libuuid is present (and trying to put -luuid in the link options still results in the above failure), so I'm not sure why the shared build fails. It doesn't complain for the usual static build.

qyot27
14th August 2012, 14:08
Well, I managed to modify the Makefile so that if it knows it's using MinGW, it won't compile Format.cpp. It 'fixes' the issue, but I still don't know how necessary that file is.

MasterNobody
14th August 2012, 17:53
qyot27
You probably need to link with libstrmiids.a library (-lstrmiids).

qyot27
15th August 2012, 09:11
Yep, that was all it took. Thanks.

Pat357
28th August 2012, 18:26
Yep, that was all it took. Thanks.

What is this lib for ?
I'm having the same problem with building the opus-codec binaries using Ming32 : getting lots of "undefined references".
By quickly looking at the libstrmiids.a, it seems something for audio and video...

MasterNobody
28th August 2012, 19:10
What is this lib for ?
I'm having the same problem with building the opus-codec binaries using Ming32 : getting lots of "undefined references".
By quickly looking at the libstrmiids.a, it seems something for audio and video...
AFAIK it is the library for class identifiers (CLSIDs) and interface identifiers (IIDs) for DirectShow i.e. container of constants for linker (there is no any functions there).