2015-05-20 52 views
3

我正在嘗試使用quickfix庫連接到使用FIX協議的代理。編譯quickfix程序

g++ fix.cpp -fexceptions -finline-functions -lquickfix -lpthread -lxml2 

我收到了一堆錯誤:我只是用他們所提供的文件和使用他們的示例代碼,現在

#include "quickfix/FileStore.h" 
#include "quickfix/FileLog.h" 
#include "quickfix/SocketAcceptor.h" 
#include "quickfix/Session.h" 
#include "quickfix/SessionSettings.h" 
#include "quickfix/Application.h" 

int main(int argc, char** argv) 
{ 
    try 
    { 
    if(argc < 2) return 1; 
    std::string fileName = argv[1]; 

    FIX::SessionSettings settings(fileName); 

    MyApplication application; 
    FIX::FileStoreFactory storeFactory(settings); 
    FIX::FileLogFactory logFactory(settings); 
    FIX::SocketAcceptor acceptor 
     (application, storeFactory, settings, logFactory /*optional*/); 
    acceptor.start(); 
    // while(condition == true) { do something; } 
    acceptor.stop(); 
    return 0; 
    } 
    catch(FIX::ConfigError& e) 
    { 
    std::cout << e.what(); 
    return 1; 
    } 
} 

然而,當我試圖用編譯生成的庫

In file included from /usr/local/include/quickfix/Session.h:34:0, 
       from fix.cpp:6: 
/usr/local/include/quickfix/DataDictionaryProvider.h:54:72: error: ‘ptr::shared_ptr’ has not been declared 
    void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>); 
                     ^
/usr/local/include/quickfix/DataDictionaryProvider.h:54:82: error: expected ‘,’ or ‘...’ before ‘<’ token 
    void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>); 
                       ^
/usr/local/include/quickfix/DataDictionaryProvider.h:55:70: error: ‘ptr::shared_ptr’ has not been declared 
    void addApplicationDataDictionary(const ApplVerID& applVerID, ptr::shared_ptr<DataDictionary>); 
                    ^
/usr/local/include/quickfix/DataDictionaryProvider.h:55:80: error: expected ‘,’ or ‘...’ before ‘<’ token 
    void addApplicationDataDictionary(const ApplVerID& applVerID, ptr::shared_ptr<DataDictionary>); 
                       ^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:25: error: ‘shared_ptr’ is not a member of ‘ptr’ 
    std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries; 
         ^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:25: error: ‘shared_ptr’ is not a member of ‘ptr’ 
/usr/local/include/quickfix/DataDictionaryProvider.h:63:55: error: template argument 2 is invalid 
    std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries; 
                ^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:55: error: template argument 4 is invalid 
/usr/local/include/quickfix/DataDictionaryProvider.h:63:57: error: expected unqualified-id before ‘>’ token 
    std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries; 
                 ^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:25: error: ‘shared_ptr’ is not a member of ‘ptr’ 
    std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries; 
         ^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:25: error: ‘shared_ptr’ is not a member of ‘ptr’ 
/usr/local/include/quickfix/DataDictionaryProvider.h:64:55: error: template argument 2 is invalid 
    std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries; 
                ^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:55: error: template argument 4 is invalid 
/usr/local/include/quickfix/DataDictionaryProvider.h:64:57: error: expected unqualified-id before ‘>’ token 
    std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries; 
                 ^
/usr/local/include/quickfix/DataDictionaryProvider.h: In member function ‘void FIX::DataDictionaryProvider::addTransportDataDictionary(const FIX::BeginString&, const string&)’: 
/usr/local/include/quickfix/DataDictionaryProvider.h:58:45: error: ‘shared_ptr’ is not a member of ‘ptr’ 
    { addTransportDataDictionary(beginString, ptr::shared_ptr<DataDictionary>(new DataDictionary(path))); } 
              ^
/usr/local/include/quickfix/DataDictionaryProvider.h:58:75: error: expected primary-expression before ‘>’ token 
    { addTransportDataDictionary(beginString, ptr::shared_ptr<DataDictionary>(new DataDictionary(path))); } 
                     ^
/usr/local/include/quickfix/DataDictionaryProvider.h: In member function ‘void FIX::DataDictionaryProvider::addApplicationDataDictionary(const FIX::ApplVerID&, const string&)’: 
/usr/local/include/quickfix/DataDictionaryProvider.h:60:45: error: ‘shared_ptr’ is not a member of ‘ptr’ 
    { addApplicationDataDictionary(applVerID, ptr::shared_ptr<DataDictionary>(new DataDictionary(path))); } 
              ^
/usr/local/include/quickfix/DataDictionaryProvider.h:60:75: error: expected primary-expression before ‘>’ token 
    { addApplicationDataDictionary(applVerID, ptr::shared_ptr<DataDictionary>(new DataDictionary(path))); } 
                     ^
fix.cpp: In function ‘int main(int, char**)’: 
fix.cpp:19:5: error: ‘MyApplication’ was not declared in this scope 
    MyApplication application; 
    ^
fix.cpp:19:19: error: expected ‘;’ before ‘application’ 
    MyApplication application; 
       ^
fix.cpp:23:8: error: ‘application’ was not declared in this scope 
     (application, storeFactory, settings, logFactory /*optional*/); 
     ^
[email protected]:/home/luis/tradingbot/bot4#  In file included from /usr/local/include/quickfix/Session.h:34:0, 
In: command not found 
[email protected]:/home/luis/tradingbot/bot4#      from fix.cpp:6: 
from: can't read /var/mail/fix.cpp:6: 
[email protected]:/home/luis/tradingbot/bot4#  /usr/local/include/quickfix/DataDictionaryProvider.h:54:72: error: ‘ptr::shared_ptr’ has not been declared 
bash: /usr/local/include/quickfix/DataDictionaryProvider.h:54:72:: No such file or directory 
[email protected]:/home/luis/tradingbot/bot4#  void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>); 
bash: syntax error near unexpected token `(' 
[email protected]:/home/luis/tradingbot/bot4#                   ^
^: command not found 
[email protected]:/home/luis/tradingbot/bot4#  /usr/local/include/quickfix/DataDictionaryProvider.h:54:82: error: expected ‘,’ or ‘...’ before ‘<’ token 
bash: ’: No such file or directory 
[email protected]:/home/luis/tradingbot/bot4#  void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>); 
bash: syntax error near unexpected token `(' 
[email protected]:/home/luis/tradingbot/bot4#                      ^
^: command not found 
[email protected]:/home/luis/tradingbot/bot4#  /usr/local/include/quickfix/DataDictionaryProvider.h:55:70: error: ‘ptr::shared_ptr’ has not been declared 
bash: /usr/local/include/quickfix/DataDictionaryProvider.h:55:70:: No such file or directory 

我在做什麼錯?

+1

嘗試添加'-std = C++ 11'或'-std = C++ 14'開關。可能是因爲'shared_ptr' – Alejandro

+0

大部分錯誤都使用了C++ 11 :)但是,我仍然得到''MyApplication'沒有在此範圍內聲明。 o.O –

+0

我在您提供的代碼中看不到您的「MyApplication」的定義。它在不同的文件中?如果是這樣,不要忘記包含標題。 – Alejandro

回答

0

您需要提供MyApplication類的實現並使用適當的C++ 11標誌進行編譯。

MyApplication對象通常需要從FIX::Application類,這是一個純虛類,並且將要求您實施了一系列的方法,如onLogon(...)toApp(...)

如果你只想讓你的代碼編譯推導作爲第一步,您可以嘗試使用FIX::NullApplication類(在quickfix/Application.h中定義)作爲您的啓動應用程序對象。