Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

linker error when using dev C++ for GPIB

Can someone help me with this! I'm having a problem buiding my simple gpib (readin/writing to VNA) program in dev c++. So even this following simplest of programs gives me a linker error:

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

/*
 *  Include the WINDOWS.H and DECL-32.H files. The standard Windows
 *  header file, WINDOWS.H, contains definitions used by DECL-32.H and
 *  DECL-32.H contains prototypes for the GPIB routines and constants.
 */
 
#include <windows.h>
#include "ni488.h"


int main() {
    int ud0;
    ud0=ibdev(0,16,0,13,1,0); //takes the addresses, 16 is the address of the device(VNA)
}




This is a C project, I have added gpib-32.obj to the project and also the ni488.h. I got both of these files form the languages\microsoft C directory in national instruments directory. I get this error:
  [Linker error] undefined reference to `ibdev@24'



What is going on! none of the sample programs work either. Is it because it's dev c++?

Thanks so much for helping!!
0 Kudos
Message 1 of 6
(6,974 Views)
When i digged the forum i got this

under the "Project" menu - "properties" - "linker" - "Command line", I added "...\GPIB.obj" to the additional options textbox.  This provides the missing link to the object file.

But you had mentioned that you have already done this.Let me digg further and let  u know
Message 2 of 6
(6,950 Views)

Hi Dorna,

If you include the file as #include "ni488.h", you need to make sure the ni488.h file is included in the project. If it is not please include the file as #include <ni488.h>.

Thank you,

Simran K
National Instruments
Applications Engineer
Message 3 of 6
(6,930 Views)

Thanks a lot! I was missing that line actually, I had the gpib-32.obj added to my project but I hadn't added that command ..\gpib-32.obj, this is what worked for me (in Dev C++), in addition to what I had above:

 

The project has to be win32 console.

 In project tab --> project options --> parameters --> under the "linker" text box add: "..\gpib-32.obj"

 

 

0 Kudos
Message 4 of 6
(6,873 Views)

Hi, I got the same problem with Qt.

 

When I'm tring to call the "ibdev" function I got  "undefined reference to `ibdev@24' "

 

My pro file:

QT       += core gui

TARGET      = dx2
TEMPLATE    = app

# configuracin National Instruments NI4882 
# Windows Qt LGPL (compilador mingw)
INCLUDEPATH += "C:/Program Files/National Instruments/Shared/ExternalCompilerSupport/C/include"
win32-msvc:LIBS += "C:/Program Files/National Instruments/Shared/ExternalCompilerSupport/C/lib32/msvc" gpib-32.obj

SOURCES += main.cpp\
        dx2.cpp

HEADERS  += dx2.h

FORMS    += dx2.ui

 

And my Qt C++ code is

 

#include "dx2.h"
#include "ui_dx2.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <windows.h>
#include <conio.h>
#include <QFile>

#include "ni4882.h"

#define _CRT_SECURE_NO_DEPRECATE
#define ARRAYSIZE_IN			100   // Size of read buffer
#define GPIB0					0     // Board handle
#define BDINDEX					0     // Board Index
#define PRIMARY_ADDR_OF_DMM		1     // Primary address of device
#define NO_SECONDARY_ADDR		0     // Secondary address of device
#define TIMEOUT					11    // Timeout value = 1 seconds
#define EOTMODE					1     // Enable the END message
#define EOSMODE					0     // Disable the EOS mode
#define DEFAULT_BUFFER			2048
#define MAX_ACL_BYTES			768
#define BUFFERSIZE				256

char ErrorMnemonic[29][5] = { "EDVR", "ECIC", "ENOL", "EADR", "EARG",
                              "ESAC", "EABO", "ENEB", "EDMA", "",
                              "EOIP", "ECAP", "EFSO", "",     "EBUS",
                              "ESTB", "ESRQ", "",     "",      "",
                              "ETAB", "ELCK", "EARM", "EHDL",  "",
                              "",     "EWIP", "ERST", "EPWR" };

int Dev;
dx2::dx2(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::dx2)
{
    ui->setupUi(this);
    // read configuration
    PGM_CONFIG pgmConfig;
    pgmConfig.gpibAddress = ui->addressNum->value();
    pgmConfig.devHandle = ibdev(BDINDEX, pgmConfig.gpibAddress, NO_SECONDARY_ADDR, TIMEOUT, EOTMODE, EOSMODE);
    qDebug("GPIB address is = %d\n",pgmConfig.gpibAddress);
  
}

 

My setup:

Win XP SP3

Qt 4.7.3

NI4882

 

0 Kudos
Message 5 of 6
(5,296 Views)
0 Kudos
Message 6 of 6
(5,293 Views)