2011-09-05 141 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; 
}