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.
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.