2011-09-05 93 views
1

我不想编译动态库,所以this question没有用。如何编译Windows的静态Taglib库?

我下载标签库和使用编译它:

cmake -DENABLE_STATIC=ON -DENABLE_STATIC_RUNTIME=ON -DWITH_MP4=ON -G "Visual Studio 10" 

这产生了Visual Studio的解决方案,我可以编译“标签”项目,该项目产生tag.lib中的taglib /释放。

问题是当我尝试使用该库在测试应用程序 - 没什么,只是一个简单的测试:

#include "stdafx.h" 
#include "fileref.h" 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    TagLib::FileRef d(""); 
    return 0; 
} 

我得到以下链接错误:

Error 1 error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall TagLib::FileRef::~FileRef(void)" ([email protected]@@[email protected]) C:\...\taglib_test\taglib_test\taglib_test.obj taglib_test 
Error 2 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall TagLib::FileRef::FileRef(class TagLib::FileName,bool,enum TagLib::AudioProperties::ReadStyle)" ([email protected]@@[email protected]@[email protected][email protected]@[email protected]@Z) C:\...\taglib_test\taglib_test\taglib_test.obj taglib_test 
Error 4 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall TagLib::FileName::FileName(char const *)" ([email protected]@@[email protected]@Z) C:\...\taglib_test\taglib_test\taglib_test.obj taglib_test 
Error 3 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall TagLib::FileName::~FileName(void)" ([email protected]@@[email protected]) C:\...\taglib_test\taglib_test\taglib_test.obj taglib_test 
Error 5 error LNK1120: 4 unresolved externals C:\...\taglib_test\Release\taglib_test.exe taglib_test 

有人能请给我一个关于这里发生了什么的想法?

以下是预处理器在标签项目定义:

WIN32 
_WINDOWS 
NDEBUG 
HAVE_CONFIG_H 
_CRT_SECURE_NO_DEPRECATE 
_CRT_NONSTDC_NO_DEPRECATE 
TAGLIB_STATIC 
CMAKE_INTDIR="Release" 

回答

5

对于那些谁都有过这样的问题:我 在测试项目定义TAGLIB_STATIC固定它:

#include "stdafx.h" 

//This should have been generated by the build system in taglib_config.h 
//but was not. 
#define TAGLIB_STATIC 
#include "fileref.h" 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    TagLib::FileRef d(""); 
    return 0; 
}