Linking error with Modbus TCP/IP

M

Thread Starter

Michael

First off my email address is [email protected] if you would like me to send the whole project. I am compiling this in a 64 but environment, but i get the same error on my 32bit laptop When compiling my project under debug mode. I get a error C2664: <pre>
'int MbusTcpMasterProtocol::eek:penProtocol(const TCHAR *const )' : cannot convert parameter 1 from 'char *' to 'const TCHAR *const '
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast</pre>
but when i compile it under release mode i get

error LNK2019: unresolved external symbol _getBusProtocolErrorText referenced in function "void __cdecl openProtocol(void)" ([email protected]@YAXXZ)

1>seniorgui.obj : error LNK2019: unresolved external symbol "public: int __thiscall MbusTcpMasterProtocol::eek:penProtocol(unsigned short const * const)" ([email protected]@@[email protected]) referenced in function "void __cdecl openProtocol(void)" ([email protected]@YAXXZ)

1>seniorgui.obj : error LNK2019: unresolved external symbol "public: virtual int __thiscall MbusTcpMasterProtocol::isOpen(void)" ([email protected]@@UAEHXZ) referenced in function "void __cdecl isOpen(void)" ([email protected]@YAXXZ)

1>seniorgui.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall MbusTcpMasterProtocol::closeProtocol(void)" ([email protected]@@UAEXXZ) referenced in function "void __cdecl closeProtocol(void)" ([email protected]@YAXXZ)

1>seniorgui.obj : error LNK2019: unresolved external symbol "public: __thiscall MbusTcpMasterProtocol::MbusTcpMasterProtocol(void)" ([email protected]@[email protected]) referenced in function "void __cdecl `dynamic initializer for 'mbusProtocol''(void)" ([email protected]@YAXXZ)

1>seniorgui.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall MbusTcpMasterProtocol::~MbusTcpMasterProtocol(void)" ([email protected]@[email protected]) referenced in function "void __cdecl `dynamic atexit destructor for 'mbusProtocol''(void)" ([email protected]@YAXXZ)

style error.

the file my code is located in is this<pre>
// Platform header
#include <stdio.h>
#include <stdlib.h>
#include "seniorgui.h"
#include "iconArea.h"
// Include FieldTalk package header
#include "MbusTcpMasterProtocol.hpp"

#include <QtGui>
#include <QDesktopServices>
#include <iostream>
#include <fstream>

//#include <tchar.h>

#include <QUrl>
using namespace std;



/*****************************************************************************
* Gobal data
*****************************************************************************/

#if defined (_UNICODE)
TCHAR *hostName = L"127.0.0.1";
#else
char *hostName = "127.0.0.1";
#endif
MbusTcpMasterProtocol mbusProtocol;


seniorGui::seniorGui(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{

previewArea = new iconArea();
centralWidget = new QWidget;
setCentralWidget(centralWidget);

QTimer *countdown = new QTimer;

QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(previewArea, 0, 0, 0, 0);
centralWidget->setLayout(mainLayout);

createActions();
createMenus();
createToolBars();
createStatusBar();

setWindowTitle(tr("ModBus TCP/IP Senior Gui"));
resize(minimumSizeHint());

}

void seniorGui::closeEvent(QCloseEvent *event)
{

}

void seniorGui::about()
{
QMessageBox::about(this, tr("About Application"),
tr("This is a <b>Application</b> that will use"
"ModBus TCP/IP to connect and control several devices"));
}

void seniorGui::createActions()
{
connectAct = new QAction(QIcon("connect.png"), tr("&Connect"), this);
connectAct->setStatusTip(tr("Connect to IP Address"));
connect(connectAct, SIGNAL(clicked()), this, SLOT(openProtocol()));

helpAct = new QAction(QIcon("help.gif"), tr("&help"), this);
helpAct->setStatusTip(tr("Let's Help you out"));
//connect(helpAct, SIGNAL(clicked()), this, SLOT(helpFile()));

qtAct = new QAction(QIcon("qt.png"), tr("&Qt"), this);
qtAct->setStatusTip(tr("Learn more about Qt"));
connect(qtAct, SIGNAL(clicked()), this, SLOT(qtHelp()));

disconnectAct = new QAction(QIcon("Disconnect.png"), tr("&Disconnect"), this);
disconnectAct->setStatusTip(tr("Disconnecting from Module"));
connect(disconnectAct, SIGNAL(clicked()), this, SLOT(closeProtocol()));

checkAct = new QAction(QIcon("check.png"), tr("&Check"), this);
disconnectAct->setStatusTip(tr("Disconnecting from Module"));
connect(checkAct, SIGNAL(clicked()), this, SLOT(isOpen()));

timer1Act = new QAction(QIcon("timer.png"), tr("&Timer 1"), this);
timer1Act->setStatusTip(tr("Getting Data from Button1"));
connect(checkAct, SIGNAL(clicked()), this, SLOT(timer()));

timer2Act = new QAction(QIcon("timer.png"), tr("&Timer 2"), this);
timer2Act->setStatusTip(tr("Getting Data from Button3"));
connect(checkAct, SIGNAL(clicked()), this, SLOT(timer()));

timer3Act = new QAction(QIcon("timer.png"), tr("&Timer 3"), this);
timer3Act->setStatusTip(tr("Getting Data from Button3"));
connect(checkAct, SIGNAL(clicked()), this, SLOT(timer()));

timer4Act = new QAction(QIcon("timer.png"), tr("&Timer 4"), this);
timer4Act->setStatusTip(tr("Getting Data from Button4"));
connect(checkAct, SIGNAL(clicked()), this, SLOT(timer()));

timer5Act = new QAction(QIcon("timer.png"), tr("&Timer 5"), this);
timer5Act->setStatusTip(tr("Getting Data from Button5"));
connect(checkAct, SIGNAL(clicked()), this, SLOT(timer()));

timer6Act = new QAction(QIcon("timer.png"), tr("&Timer 6"), this);
timer6Act->setStatusTip(tr("Getting Data from Button6"));
connect(checkAct, SIGNAL(clicked()), this, SLOT(timer()));

}

void seniorGui::createToolBars()
{
fileToolBar = addToolBar(tr("Connect"));
fileToolBar->addAction(connectAct);
fileToolBar->addAction(disconnectAct);
fileToolBar->addAction(checkAct);


fileToolBar = addToolBar(tr("Help"));
fileToolBar->addAction(helpAct);
fileToolBar->addAction(qtAct);


}
void seniorGui::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(connectAct);
fileMenu->addAction(disconnectAct);
fileMenu->addAction(checkAct);


fileMenu = menuBar()->addMenu(tr("Read Data"));
fileMenu->addAction(timer1Act);
fileMenu->addAction(timer2Act);
fileMenu->addAction(timer3Act);
fileMenu->addAction(timer4Act);
fileMenu->addAction(timer5Act);
fileMenu->addAction(timer6Act);


fileMenu = menuBar()->addMenu(tr("&Help"));
fileMenu->addAction(helpAct);
fileMenu->addAction(qtAct);
}






void openProtocol()
{
int result;

result = mbusProtocol.openProtocol(hostName);
if (result != FTALK_SUCCESS)
{
fprintf(stderr, "Error opening protocol: %s!\n",
getBusProtocolErrorText(result));
exit(EXIT_FAILURE);
}
}



void isOpen()
{
int result;

result = mbusProtocol.isOpen();
if (result != FTALK_SUCCESS)
{

exit(EXIT_FAILURE);
}

}

/**
* Closes protocol
*/
void closeProtocol()
{
mbusProtocol.closeProtocol();
}


void seniorGui::timer()
{
count = 60000;
while (count > 0)
{
//mbusProtocol.readCoils();
// read data from device
count--;
}
if(count <=0)
{
ofstream *dataFile = new ofstream;
dataFile->open("data.txt");
dataFile->close();
//export data to text file
}


}

void seniorGui::createStatusBar()
{
statusBar()->showMessage(tr("Ready"));
}</pre>
I believe i am linking my project properly. I have struggled with this for about a week now so any help that can be provided would be much appreciated.
 
Top