Home > Back-end >  QT add external libraries, how to use
QT add external libraries, how to use

Time:09-27

# # ifndef GALIL_H
# define GALIL_H

#include
#include
The class GalilPrivate;

# ifdef _MSC_VER//MSVC Compiler
# ifdef MAKEDLL
# define DLL_IMPORT_EXPORT __declspec (dllexport)
# the else
//# define DLL_IMPORT_EXPORT __declspec (dllimport)
# define DLL_IMPORT_EXPORT
# endif
# else//not Windows (e.g. Linux) Expand to the empty space
# define DLL_IMPORT_EXPORT
# endif

DLL_IMPORT_EXPORT void SetDynamicLink (void);

The class DLL_IMPORT_EXPORT Galil//An instance of the Galil class (Galil object) represents a CONNECTION to a controller (not necessarily the controller itself). The Multiple Galil objects can connect to a single Ethernet controller.
{GalilPrivate * d;
Public:
The static STD: : string libraryVersion ();//returns the version string of the Galil class library for the display (e.g., "0.0.4.3 Jan 2, 2008 16:04:50 libGalil. So"), Can be called WITHOUT an instance of the Galil. Note that this has nothing to do with the version of the controller (which Can be found with the connection () below).
The static STD: : vector Addresses ();//returns the list of available addresses to connect to (e.g. "2"). Each item in the list may be fed to the constructor Galil ()

The Galil (STD: : string address="");//constructor opens the connection with the controller i.e 192.168.1.2 instead, COM1,/dev/ttyS0 GALILPCI1/dev/galilpci0 (default constructor with no arguments will "bringing up a dialog)
~ the Galil ();//destructor closes the connection with the controller
STD: : string connection ();//returns a string like "DMC4080 Rev 1.0, 123, 10.0.0.70, IHA"

Int timeout_ms;//the default=500 milliseconds. This is the timeout for everything but the BP, BV, RS, ^ R ^ S, and the program/array/firmware download
STD: : string command (const STD: : string& The command="TIME" MG, const STD: : string& Terminator="\ r", const STD: : string& Ack=":", bool trim=true);//send a command (e.g. "MG _RPX") to the controller and the get the response
Double commandValue (const STD: : string& The command="MG TIME");//convenience method that converts the response from string to numerical value
STD: : string message (int timeout_ms=500).//Ms. Get the MGs from controller program
Int interrupt (int timeout_ms=500);//Ms. EI, UI (DMC - 18 xx only). Returns the status byte (e.g. 0 xf0 for UI0)
};

# endif

Above is added outside the class, there is also a. Lib library,,,

# include "mainwindow. H"
# include "ui_mainwindow. H"
# include "Galil. H"


The Galil g (" 192.168.2.12 ");

MainWindow: : MainWindow (QWidget * parent) :
QMainWindow (parent),
UI (new UI: : MainWindow)
{
The UI - & gt; SetupUi (this);


G.com mandValue (" MG TIME ");
//UI - & gt; MyButton - & gt; SetText (" 1234 ");
}

MainWindow: : ~ MainWindow ()
{
delete ui;
}

Void MainWindow: : on_pushButton_clicked ()
{
G.com mandValue (" MG TIME ");
}

The error message is as follows, but such use is no problem in the VS, don't know how to use

Mainwindow. Obj: 1: error: LNK2019: cannot resolve the external symbol of "public: __thiscall Galil: : Galil (class STD: : basic_string & lt; Char, struct STD: : char_traits & lt; char> Class, STD: : allocator) "(?????? 0 galil @ @ QAE @ V? $basic_string @ DU? $char_traits @ D @ STD @ @ V? $allocator @ @ 2 D @ @ STD @ @ @ Z), the symbol in the function "void __cdecl ` dynamic, initializer for a 'g' '(void)" (?????? __Eg @ @ YAXXZ) referenced
Mainwindow. Obj: 1: error: LNK2019: cannot resolve the external symbol of "public: __thiscall Galil: : ~ the Galil (void)" (?????? 1 the galil @ @ QAE @ XZ), the symbol in the function "void __cdecl ` dynamic atexit destructor for a 'g' '(void)" (?????? __Fg @ @ YAXXZ) referenced
Mainwindow. Obj: 1: error: LNK2019: cannot resolve the external symbol of "public: double __thiscall Galil: : commandValue (class STD: : basic_string & lt; Char, struct STD: : char_traits & lt; char> Class, STD: : allocator Const & amp;) "(? CommandValue @ the Galil @ @ QAENABV? $basic_string @ DU? $char_traits @ D @ STD @ @ V? $allocator @ @ 2 D @ @ STD @ @ @ Z), the symbol in the function of "private: void __thiscall MainWindow: : on_pushButton_clicked (void)" (? On_pushButton_clicked @ MainWindow @ @ AAEXXZ) referenced

CodePudding user response:

In QtCreator to increase the lib in the project configuration file
  • Related