In function .. undefined reference to ..

Hello All,
I am getting below error while trying to link DB2 libraries, any clues what must be going wrong here.. Many thanks for your help.
1
2
3
4
5
6
7
8
9
10
g++ -O -pthread -I. -I/home/myhome/ia-k_L/src/global/include -I/home/myhome/ia-k_L/src/gias/include -I/xenv/DB2-LUW-SDK/X/975sdk_L/include -o /home/myhome/ia-k_L/src/gias/bin/gias_rateAdjUpdate \
	/home/myhome/ia-k_L/src/gias/obj/gias_rateAdjUpdate.o /home/myhome/ia-k_L/src/global/obj/oliUtil.o /home/myhome/ia-k_L/src/gias/obj/tableEngine.o /home/myhome/ia-k_L/src/gias/obj/navBuilder.o /home/myhome/ia-k_L/src/gias/obj/portfolio.o /home/myhome/ia-k_L/src/gias/obj/product.o /home/myhome/ia-k_L/src/gias/obj/textConv.o /home/myhome/ia-k_L/src/gias/obj/gridHelper.o /home/myhome/ia-k_L/src/gias/obj/logFile.o /home/myhome/ia-k_L/src/gias/obj/Datagrid.o /home/myhome/ia-k_L/src/gias/obj/gias_CliApi.o /home/myhome/ia-k_L/src/global/obj/cgic.o /home/myhome/ia-k_L/src/global/obj/cgiSecurity.o -L/xenv/DB2-LUW-SDK/X/975sdk_L/lib64  -Wl,-rpath,/xenv/DB2-LUW-SDK/X/975sdk_L/lib64 -ldb2  
/home/myhome/ia-k_L/src/gias/obj/gridHelper.o: In function `DataGrid::gridBinarySearch_va(textConv*, char*, int, __va_list_tag*)':
/home/myhome/ia-k_L/src/gias/include/DataGrid.h:4900: undefined reference to `DataGrid::arrayBinarySearch_va(textConv*, char*, int, __va_list_tag*)'
/home/myhome/ia-k_L/src/gias/include/DataGrid.h:4903: undefined reference to `DataGrid::listBinarySearch_va(textConv*, char*, int, __va_list_tag*)'
/home/myhome/ia-k_L/src/gias/obj/gridHelper.o: In function `DataGrid::gridLinearSearch_va(textConv*, char*, int, __va_list_tag*)':
/home/myhome/ia-k_L/src/gias/include/DataGrid.h:4967: undefined reference to `DataGrid::arrayLinearSearch_va(textConv*, char*, int, __va_list_tag*)'
/home/myhome/ia-k_L/src/gias/include/DataGrid.h:4970: undefined reference to `DataGrid::listLinearSearch_va(textConv*, char*, int, __va_list_tag*)'
/home/myhome/ia-k_L/src/gias/obj/gridHelper.o: In function `DataGrid::gridBinarySearch_va(textConv*, char*, int, __va_list_tag*)':
/home/myhome/ia-k_L/src/gias/include/DataGrid.h:4900: undefined reference to `DataGrid::arrayBinarySearch_va(textConv*, char*, int, __va_list_tag*)'
Which object file contains the class function arrayBinarySearch_va? You aren't linking to it. Likewise the other functions.
Maschops,

The file "DataGrid.h" has the class "DataGrid" and arrayBinarySearch_va funtion is implemented inside Datagrid.cc. So the object file Datagrid.o contains the mentioned class function.

its something like below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(....code from DataGrid.h....)
#if !defined(_DATAGRID_H_)
#define _DATAGRID_H_
class DataGrid; //first declared here
class DataGrid{
private:
    DataGrid( const DataGrid &rhs );
public:
    inline DataGrid( const int _gridType, char *_runtimeSQL, int _database = DB2, int _dataFlag = USING_DATAARRAY, int _special = -1, int _special2 = -1)
    {..};
   inline ~DataGrid()
    {.....}
#if defined ( _DB2_DATAGRID_SUPPORT_ )
    int arrayBinarySearch_va( textConv *_cnv, char *_parms, int _numKeys, va_list varList);     
      inline int gridBinarySearch_va(textConv *_cnv, char *_parms, int _numKeys, va_list varList)
     {
       searchOffset = arrayBinarySearch_va( _cnv, _parms, _numKeys, varList);   //this is line# 4900 where it is complaining  
     }
#endif
};

(....code from Datagrid.cc....)
#include "DataGrid.h"

#if defined ( _DB2_DATAGRID_SUPPORT_ )
     inline int DataGrid::arrayBinarySearch_va( textConv *_cnv, char *_parms, int _numKeys, va_list varList){
    ..... some code....
     }
#endif 


Do you see something wrong here ? Many thanks in advance..
Note: I am not very well versed with C/C++ programming.
Last edited on
The errors stoped after I remove "inline" from method definition in "DataGrid.h"

Old:
inline int DataGrid::arrayBinarySearch_va( textConv *_cnv, char *_parms, int _numKeys, va_list varList)


New :
int DataGrid::arrayBinarySearch_va( textConv *_cnv, char *_parms, int _numKeys, va_list varList)


Do you think this could be the reason ??
Last edited on
mih wrote:
The errors stoped after I remove "inline" from method definition in "DataGrid.h"

Old:
inline int DataGrid::arrayBinarySearch_va( textConv *_cnv, char *_parms, int _numKeys, va_list varList)

New :
int DataGrid::arrayBinarySearch_va( textConv *_cnv, char *_parms, int _numKeys, va_list varList)

Do you think this could be the reason ??


That is a possibility
The following is taken from Using the GNU compiler website

Note that certain usages in a function definition can make it unsuitable for inline substitution. Among these usages are: use of varargs, use of alloca, use of variable sized data types (see Variable Length), use of computed goto (see Labels as Values), use of nonlocal goto, and nested functions (see Nested Functions). Using -Winline will warn when a function marked inline could not be substituted, and will give the reason for the failure.




Maschops, guestgulkan,

Many thanks for your help and information.
Topic archived. No new replies allowed.