0

I am working on a large piece of code. When I compile the code base using jam command, I get a lot of errors saying undefined reference to 'some_function' in a newly added header file in the code base. This header file includes all other relevant header files. Do I need to make changes to the jam file before I can compile the code base?

bundlemgr_distrib_im.c:

#include "bundlemgr_distrib_config.h"
.
.
function{
.
.
retcode = bmd_cfg_init_active(bmd_im_evh);
.
.
}

bundlemgr_distrib_config.h:

cerrno bmd_cfg_init_active(event_mgr_p evh); //declaration

bundlemgr_distrib_config.c

#include "bundlemgr_distrib_config.h"
.
.
cerrno bmd_cfg_init_active(event_mgr_p evh)
{
//definition
}

Build log:

...failed Link bundle/bundlemgr/test/obj-x86/bm_ut_distrib_attr ...
...skipped <installed!rp>bm_ut_distrib_attr for lack of <bundle!bundlemgr!test!obj-x86>bm_ut_distrib_attr...
.
.
bugfix/./bundle/bundlemgr/distrib/src/bundlemgr_distrib_im.c:269: undefined reference to `bmd_cfg_init_active'

Another error:

bundlemgr_distrib_acc_private.h (newly added file)

#include "bundlemgr_distrib_db_api.h"
#include "bundlemgr_distrib_db_private.h"
.
.
function{
.
.
rc = bmd_db_bdl_change_ifh(entry, ifhandle);
.
.
}

bundlemgr_distrib_db_private.h

cerrno bmd_db_bdl_change_ifh(bmd_db_bdl_h_type  entry,
                          ifhtype            ifhandle); //declaration

bundlemgr_distrib_db_api.c

#include "bundlemgr_distrib_db_private.h"
.
.
cerrno  
bmd_db_bdl_change_ifh (bmd_db_bdl_type *entry,                                                                                                                                                                                          
                    ifhtype          ifhandle)
{
//definition
}

Build log:

...failed Link bundle/bundlemgr/test/obj-x86/bm_ut_distrib_attr ...
...skipped <installed!rp>bm_ut_distrib_attr for lack of <bundle!bundlemgr!test!obj-x86>bm_ut_distrib_attr...
Link bundle/bundlemgr/test/obj-x86/bm_ut_distrib_mbr_info
bundle/bundlemgr/test/obj-x86/bundlemgr_distrib_test_errdis_owner.o: In function `bmd_acc_bdl_set_ifhandle':
/nobackup/pzambad/ci-521-bugfix/./bundle/bundlemgr/distrib/src/bundlemgr_distrib_acc_private.h:3618: undefined reference to `bmd_db_bdl_change_ifh'
Piyush
  • 1
  • 2
  • Plyush, are the errors generated by the compiler, or the linker? – Mahonri Moriancumer May 15 '14 at 19:31
  • These are link errors.. – Piyush May 15 '14 at 19:32
  • @Plyush, Being linker errors, they are not associated with a header file. Rather, the errors are indicating that there is insufficient code to resolve the symbols listed. Perhaps there is a library that needs to be used to resolve the symbols, (or perhaps multiple .c files must be compiled and linked together to resolve the symbols)? You might consider posting a few of the linker errors with you question; that might help identify the missing element. – Mahonri Moriancumer May 15 '14 at 19:36
  • @Mahonri: Added some code. – Piyush May 15 '14 at 20:51

1 Answers1

0

You need to tell the linker where to find the library files that go with those headers. There will often be a /lib directory containing the required libraries. With the Gnu toolchain use -l for including a specific library or -L for adding a library path.

Chris Ryding
  • 1,508
  • 11
  • 16