user3651606
user3651606

Reputation: 107

Program running on qnx momentics giving error undefined references

I am trying to run a socket programming on qnx momentics on IDE 4.7 , the code was written by someone else , it is getting compiled on his pc i was just asked to build it and run on our target. I am getting this error., The code has both and , but it is throwing error "undefined reference to 'accept'" ,"undefined reference to 'bind'","undefined reference to 'listen'", my pc is windows 7, could anyone tell me how to resolve this?

Upvotes: 1

Views: 3270

Answers (2)

kingvittu
kingvittu

Reputation: 103

Link the libraries manually. For examples if you are using a Makefile project then add the below line

LIBS += -L<Path to QNX SDP>\target\qnx7\aarch64le\lib -lsocket

and then rebuild the project

Upvotes: 1

Shrikant Havale
Shrikant Havale

Reputation: 1290

Normally when you include just a header file, all the methods and variables are accessible and resolved. But when you actually try to build the project, it starts looking for that method definitions and if not found, throw an error.

Example: HAM in QNX, I wanted to use these lines,

ham_entity_t *ehdl;
ham_condition_t *chdl;
ham_action_t *ahdl;

ham_connect(0);

and I just included,

#include "ha/ham.h"

So far so good, but when I tried to build using QNX IDE, it gave me the error undefined reference

Then, I followed this steps.

  1. Right click project, go in properties.
  2. Go to QNC C/C++ project on right side navigation.
  3. Go to Linker Tab
  4. Select Extra Libraries from categories.
  5. Click add and type "ham" and rebuild the project.

Now in your case, only in last step you have to type "socket" and rebuild the project.

Hope this helps.

Upvotes: 2

Related Questions