0

I'm a beginner in C++. I've a project called myProject and an header file given to me, called myLIB.h with a method

int connect(char *);

I moved the header in my Project and included in my main file like this

#include "myLIB.h"

My problem is when I start to type connect, Eclipse IDE suggests me the method in myLIB.h

int fd = connect(devName);

but, when I try to build and compile, I get the following error:

 Undefined reference to connect( char *)

I can't understand where the problem is. The .h is included, Eclipse sees the methods but at building time, I get always this error.

user2896152
  • 762
  • 1
  • 9
  • 32
  • I believe this is a **link error**. The compiler finds the prototype `int connect(char*)` in the header. Thus, it "knows" that there is an implementation though it's not in the "seen" source code. The corresponding library (with implementation) is probably separately or pre-compiled and must be linked to the executable. If the linker is not able to find any object file or library with an implementation of `connect` it reports "Undefined reference". – Scheff's Cat Jul 18 '17 at 10:10
  • There is a more detailed explanation of compiler and linker in [SO: How does the compilation/linking process work?](https://stackoverflow.com/a/6264256/7478597). – Scheff's Cat Jul 18 '17 at 10:16

0 Answers0