在构建我的FIX8 Wrapper时未定义对`FIX8 :: TEX :: ctx()的引用

时间:2014-04-08 08:33:57

标签: c++ quickfix fix-protocol

我正在使用FIX8 API,我已下载已安装&甚至跑那里测试应用程序。 现在我正在尝试围绕它构建我自己的包装器&用它。 汇编很好&我得到一个.o文件,但它在链接中失败了。

未定义对`FIX8 :: TEX :: ctx()的引用

Detailed error: 
make  all-am
make[1]: Entering directory `/home/ganesh/fix8/fix8-1.0.0/test/gfix8test'
depbase=`echo gfix8.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
    g++ -DHAVE_CONFIG_H -I. -I./fix8 -I.    -g -O2 -MT gfix8.o -MD -MP -MF $depbase.Tpo -c -o  gfix8.o gfix8.cpp &&\
    mv -f $depbase.Tpo $depbase.Po
g++  -g -O2 -L/usr/local/lib/lib -lPocoNetd -L../../runtime/.libs -lfix8   -o gfix8test gfix8.o  gfix8_test.o
gfix8.o: In function `gfix::gfixthread(void*)':
/home/ganesh/fix8/fix8-1.0.0/test/gfix8test/gfix8.cpp:40: undefined reference to `FIX8::TEX::ctx()'
collect2: ld returned 1 exit status
make[1]: *** [gfix8test] Error 1
make[1]: Leaving directory `/home/ganesh/fix8/fix8-1.0.0/test/gfix8test'
make: *** [all] Error 2``

我的代码文件如下:

#include "gfix8.h"

bool gfix::init()
{
    try
    {
            switch(m_gFixType)
            {
            case server:
            break;
            case client:
            case clientreliable:
            break;
            }
    }
    catch (FIX8::f8Exception& e)
    {
            cerr << "exception: " << e.what() << endl;
            return false;
    }
    catch (exception& e)
    {
            cerr << "exception: " << e.what() << endl;
            return false;
    }
    return true;
}
void* gfix::gfixthread(void* ptr)
{
    gfix* pthis = (gfix*)ptr;
    try
    {
            while(true)
            {
                    switch(pthis->m_gFixType)
                    {
                            case server:
                            {
                                    FIX8::ServerSession<gfix_session>::Server_ptr ms(newFIX8::ServerSession<gfix_session>(FIX8::TEX::ctx(),pthis->m_sCfgFile, pthis->m_sSessName));
                                    XmlElement::XmlSet eset;
                                    while (true)
                                    {
                                            if (!(ms)->poll())
                                            continue;
                                            FIX8::SessionInstance<gfix_session>::Instance_ptr  inst(new FIX8::SessionInstance<gfix_session>(*(ms)));
                                            inst->session_ptr()->control() |= FIX8::Session::print;
                                            ostringstream sostr;
                                            FIX8::GlobalLogger::log(sostr.str());
                                            const FIX8::ProcessModel pm((ms)->get_process_model(ms->_ses));
                                            inst->start(pm == FIX8::pm_pipeline, pthis->m_nNextSend, pthis->m_nNextRecv);
                                            cout << (pm == FIX8::pm_pipeline ? "Pipelined" : "Threaded") << " mode." << endl;
                                            if (inst->session_ptr()->get_connection()->is_secure())
                                                cout << "Session is secure (SSL)" << endl;
                                            if (pm != FIX8::pm_pipeline)
                                            while (!inst->session_ptr()->is_shutdown())
                                            FIX8::hypersleep<FIX8::h_milliseconds>(100);
                                            inst->stop();
#if defined CODECTIMING
                                            FIX8::Message::report_codec_timings("server");
#endif
                                    }
                            }
                            break;
                            case client:
                            case clientreliable:
                            break;
                    }
            }
    }
    catch (FIX8::f8Exception& e) {cerr << "exception: " << e.what() << endl;}
    catch (exception& e) {cerr << "exception: " << e.what() << endl;}
}

void gfix::start()
{
    pthread_t gfixthread_;
    int threadid_ = pthread_create(&gfixthread_,NULL,&gfix::gfixthread,this);
    cout << "Thread started.."<<endl;
}

而.h文件是

#ifndef FIX8_HFTEST_HPP_
#define FIX8_HFTEST_HPP_

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include <f8includes.hpp>
#include <usage.hpp>
#include "Perf_types.hpp"
#include "Perf_router.hpp"
#include "Perf_classes.hpp"

using namespace std;

class gfix;
class gfix_session;

class gfix_router : public FIX8::TEX::Perf_Router
{
    gfix_session& m_session;
public:
    gfix_router(gfix_session& session) : m_session(session) {}
};

class gfix_session : public FIX8::Session
{
    //gfix& m_gfix;
    gfix_router m_router;
public:
    gfix_session(const FIX8::F8MetaCntx& ctx, /*const FIX8::SessionID& sid=NULL,*/   FIX8::Persister *persist=0,
            FIX8::Logger *logger=0, FIX8::Logger *plogger=0/*,gfix& gfix_*/) : Session(ctx/*, sid*/, persist, logger, plogger), m_router(*this)/*,m_gfix(gfix_)*/ {}

    bool handle_application(const unsigned seqnum, const FIX8::Message *&msg)
    {

    }
};

class gfix
{
    //FIX8::ServerSession<gfix_session>::Server_ptr m_gfixSession;
    //gFixType m_gFixType;
    unsigned m_nNextSend, m_nNextRecv;
    std::string m_sCfgFile;
    std::string m_sSessName;
public:
    enum gFixType{server,client,clientreliable};
    gFixType m_gFixType;
    gfix(gFixType fixtype,std::string cfgfile,std::string sessName):m_nNextSend(0),m_nNextRecv(0),m_gFixType(fixtype),m_sCfgFile(cfgfile),m_sSessName(sessName)
    {}

    bool init();
    static void* gfixthread(void* ptr);
    void start();
};
#endif

FIX :: TEX :: ctx()驻留在fix8 / message.hpp文件中,该文件也包含在我的项目中,我尝试了extern但没有成功。 我想我错过了一些基本的东西。 请建议..

另外,我是stackoverflow的新手,因此如果我不清楚,请原谅我。

0 个答案:

没有答案