2

我正在尝试使用 msvc 在 Windows 中创建一个基于 Gstreamer-Qt 的小型程序并使用 waf 构建它。即使我已经链接了所有所需的库,我也会收到此链接器错误。

GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_object_get_type referenced in function "public: virtual __cdecl GSTEngine::~GSTEngine(void)" (??1GSTEngine@@UEAA@XZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_element_set_state referenced in function "public: virtual __cdecl GSTEngine::~GSTEngine(void)" (??1GSTEngine@@UEAA@XZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol g_type_check_instance_cast referenced in function "public: virtual __cdecl GSTEngine::~GSTEngine(void)" (??1GSTEngine@@UEAA@XZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_element_get_type referenced in function "public: virtual __cdecl GSTEngine::~GSTEngine(void)" (??1GSTEngine@@UEAA@XZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_object_unref referenced in function "public: virtual __cdecl GSTEngine::~GSTEngine(void)" (??1GSTEngine@@UEAA@XZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_element_link referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol g_object_set referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_element_add_pad referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_ghost_pad_new referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_element_get_static_pad referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_bin_add_many referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_bin_get_type referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_bin_new referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_bus_add_watch referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_pipeline_get_bus referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_pipeline_get_type referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol g_timeout_add referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_element_factory_make referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_init referenced in function "public: virtual void __cdecl GSTEngine::init(void)" (?init@GSTEngine@@UEAAXXZ)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_element_query_position referenced in function "bool __cdecl show_position(struct _GstElement *)" (?show_position@@YA_NPEAU_GstElement@@@Z)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol g_error_free referenced in function "int __cdecl bus_state_changed(struct _GstBus *,struct _GstMessage *,void *)" (?bus_state_changed@@YAHPEAU_GstBus@@PEAU_GstMessage@@PEAX@Z)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_message_parse_error referenced in function "int __cdecl bus_state_changed(struct _GstBus *,struct _GstMessage *,void *)" (?bus_state_changed@@YAHPEAU_GstBus@@PEAU_GstMessage@@P
EAX@Z)
GSTEngine.cpp.4.o : error LNK2019: unresolved external symbol gst_element_seek_simple referenced in function "public: virtual void __cdecl GSTEngine::jump(int,bool)" (?jump@GSTEngine@@UEAAXH_N@Z)
id3.cpp.3.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class TagLib::AudioProperties * __cdecl TagLib::FileRef::audioProperties(void)const " (__imp_?audioProperties@FileRef@TagLib@@QEBAPEAVAudioProperties@2@XZ)
 referenced in function "struct MetaData __cdecl ID3::getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V
?$allocator@D@2@@std@@@Z)
id3.cpp.3.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl TagLib::String::~String(void)" (__imp_??1String@TagLib@@UEAA@XZ) referenced in function "struct MetaData __cdecl ID3::getMetaDataOfFile(cla
ss std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
id3.cpp.3.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl TagLib::String::to8Bit(bool)const " (__imp_?to8Bit@String@T
agLib@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_N@Z) referenced in function "struct MetaData __cdecl ID3::getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)"
(?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
id3.cpp.3.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl TagLib::FileRef::~FileRef(void)" (__imp_??1FileRef@TagLib@@UEAA@XZ) referenced in function "struct MetaData __cdecl ID3::getMetaDataOfFile(
class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
id3.cpp.3.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class TagLib::Tag * __cdecl TagLib::FileRef::tag(void)const " (__imp_?tag@FileRef@TagLib@@QEBAPEAVTag@2@XZ) referenced in function "struct MetaData __cdecl
 ID3::getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
id3.cpp.3.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __cdecl TagLib::FileRef::isNull(void)const " (__imp_?isNull@FileRef@TagLib@@QEBA_NXZ) referenced in function "struct MetaData __cdecl ID3::getMetaData
OfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
id3.cpp.3.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl TagLib::FileRef::FileRef(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" (__imp_??0FileRef@TagLib@@QEAA@VFileName@1@_NW4ReadS
tyle@AudioProperties@1@@Z) referenced in function "struct MetaData __cdecl ID3::getMetaDataOfFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_strin
g@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
id3.cpp.3.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl TagLib::FileName::FileName(char const *)" (__imp_??0FileName@TagLib@@QEAA@PEBD@Z) referenced in function "struct MetaData __cdecl ID3::getMetaDataO
fFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getMetaDataOfFile@ID3@@YA?AUMetaData@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
C:\cygwin\project\build\test\Playback\app.exe : fatal error LNK1120: 31 unresolved externals

我的 waf wscript(针对阅读进行了优化)

top = '.'
out = 'build'

def options(opt): 
    opt.load('compiler_cxx qt4 compiler_c')

def configure(conf):
    conf.load('compiler_cxx qt4 compiler_c boost')
    conf.check_cfg(atleast_pkgconfig_version='0.0.0') 
    conf.check_cfg(package='gstreamer-0.10', uselib_store='GSTREAMER', args='--cflags --libs', mandatory=True)
    conf.check_cfg(package='taglib', uselib_store='TAGLIB', args='--cflags --libs', mandatory=True) 
    conf.check_boost(lib='filesystem system unit_test_framework prg_exec_monitor test_exec_monitor program_options')
    conf.env.append_value('CXXFLAGS', ['-DWAF=1']) # test

def build(bld):
    cxxflags = bld.env.commonCxxFlags
    uselibcommon = 'QTMAIN QTCORE QTGUI QTOPENGL QTSVG QWIDGET QTSQL QTUITOOLS QTSCRIPT TAGLIB GSTREAMER'


    libpath = bld.env.LIBPATH_TAGLIB + bld.env.LIBPATH_GSTREAMER
    lib = bld.env.LIB_GSTREAMER + bld.env.LIB_TAGLIB
    include = [bld.options.boost_includes] + bld.env.INCLUDES_GSTREAMER + bld.env.INCLUDES_TAGLIB + bld.env.INCLUDES_QTGUI

    bld(features = 'cxx',   includes = include, source = 'Util.cpp' , target = 'Util.o', uselib = uselibcommon, lib = lib, libpath = libpath, cxxflags=cxxflags)

    bld(features = 'cxx',   includes = include, source = 'MetaData.cpp' , target = 'MetaData.o', uselib = uselibcommon, lib = lib, libpath = libpath, cxxflags=cxxflags)

    use = ['MetaData.o', 'Util.o' ]
    bld(features = 'cxx',   includes = include , source = 'id3.cpp' , target = 'id3.o', use = use, uselib = uselibcommon, lib = lib, libpath = libpath, cxxflags=cxxflags, linkflags=bld.env.commonLinkFlags)

    flags = cxxflags + ['-DWAF']
    use = ['MetaData.o', 'Util.o' , 'id3.o']
    bld(features = 'qt4 cxx',  includes = include , source = 'GSTEngine.cpp' , target = 'GSTEngine.o', use = use, uselib = uselibcommon, lib = lib, libpath = libpath, cxxflags=flags, linkflags=bld.env.commonLinkFlags)


    use = ['GSTEngine.o','MetaData.o', 'Util.o' , 'id3.o', ]
    bld(features = 'qt4 cxx c', uselib = uselibcommon, includes = include , source   = 'MainWindow.cpp' , target = 'MainWindow.o', lib = lib, libpath = libpath, use = use, linkflags=bld.env.commonLinkFlags, cxxflags=cxxflags )


    #when doing multiple entry in use space before coma
    use = ['GSTEngine.o','MetaData.o', 'Util.o' , 'id3.o','MainWindow.o', 'BOOST']

    if bld.env.COMPILER_CXX == 'msvc':
        libfile = bld.options.debug and ['qtmaind'] or ['qtmain'] 
        lib = lib + libfile
        libpath = libpath + ['C:\Qt\4.8.1_x64\lib']
        linkflags=bld.env.commonLinkFlags + ['/DEBUG']
    else:
        #lib = lib + []
        libpath = libpath + ["/usr/lib"]
        linkflags=bld.env.commonLinkFlags

    bld(features = 'qt4 cxx cxxprogram', includes = include, source = 'main.cpp MasterDetail.qrc', target   = 'app', uselib = uselibcommon , cxxflags=cxxflags, use = use,  lib = lib, libpath = libpath, subsystem='windows', linkflags=linkflags)

如果你打印lib

   ['gstreamer-0.10', 'gobject-2.0', 'gmodule-2.0', 'xml2', 'gthread-2.0', 'glib-2.0', 'intl', 'tag', 'qtmain']

如果你打印libpath

['C:/taglib-1.7.2/taglib/Release', 'C:/OSSBuild/GStreamer/v0.10.7/sdk/lib', 'C:/OSSBuild/GStreamer/v0.10.7/lib', 'C:/gtk/lib', 'C:\\Qt\x04.8.1_x64\\lib']

如果你打印include

 ['C:\\Users\\sobingt\\Desktop\\boost_1_49_0', 'C:/OSSBuild/GStreamer/v0.10.7/sdk/include/gstreamer-0.10', 'C:/OSSBuild/GStreamer/v0.10.7/sdk/include/libxml2', 'C:/OSSBuild/GStreamer/v0.10.7/sdk/include', 'C:/gtk/include/glib-2.0', 'C:/gtk/lib
    /glib-2.0/include', 'C:/taglib-1.7.2', 'C:/taglib-1.7.2/include', 'C:/Qt/4.8.1_x64/include', 'C:/Qt/4.8.1_x64/include/QtGui', 'C:/Qt/4.8.1_x64/include/QtCore']

如果我必须为 gstreamer 添加任何其他库,你能告诉我我错过了什么吗

4

1 回答 1

1

似乎是 Gstreamer 和 TagLib 32 位问题。我正在研究 64 位 msvc、boost 和 QT,并且正在使用 32 位 Gstreamer 和 Taglib。我现在正在用 64 位编译 Gstreamer 和 Taglib。当我使用 64 位的 32 位 msvc、boost 和 QT 插入时程序工作

谢谢大家

于 2012-06-04T06:39:49.607 回答