0

I have a static library, libmylib.a, which contains lots of pre-compiled objects. All the header scripts for these object are stored in /path/to/includes/. I am compiling my main script, BACnetSearch.cpp using g++ with the line below:

g++ BACnetSearch.cpp -I/path/to/includes/ -L/path/to/libraries/ -lmylib

All functions used from the library work except one, which gives the undefined reference to 'function_name'. I have checked the function has been instantiated in the appropriate header file, exists within an object in the library, and I have included it at the top of my script. The library is BACnet, so assuming the release has no bugs, where do I start looking to fix this.

Any other info you need just ask I will try to add. Thanks :)

EDIT: Error message received:

/tmp/ccDIISDz.o: In function `main':
BACnetSearch.cpp:(.text+0x67e): undefined reference to `bvlc_receive'
collect2: error: ld returned 1 exit status

EDIT 2: Auto-marked as answered elsewhere, then linked to a generic question with too many possible problems. Only possibility is that when the library is compiled, the order scripts are compiled in causes this error based from scripts dependencies on each other.

S_Zizzle
  • 95
  • 1
  • 12

1 Answers1

0

You can always start by checking that the function has been implemented. It is a common mistake to defined a prototype like so:

int isLarger();

And never implement the function, and in that case you get isLarger is not defined errors....

Looking at their site perhaps you should compile the code with a make file and like so:

make BACDL_DEFINE=-DBACDL_MSTP=1 clean all
Yunfei Chen
  • 630
  • 1
  • 8
  • 20
  • I have checked the source code the gets built into the library, and the function does exist in the library. – S_Zizzle Jul 01 '20 at 17:59
  • The make command you added just cleans the make files, it doesn't build anything (signified by the clean all at the end). BACDL_DEFINE=-DBACDL_MSTP=1 just tells the BACnet make files to use the Master-Slave Token Pass (MSTP), which is not what I want. Thank you for taking the time :). – S_Zizzle Jul 02 '20 at 23:43