Undefined references when trying to use Borland headers on Linux-Collection of common programming errors

Compiler Error Output:

"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/josh/Projects/Maze/Charon'
"/usr/bin/gmake"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/charon
gmake[2]: Entering directory `/home/josh/Projects/Maze/Charon'
mkdir -p build/Debug/GNU-Linux-x86/sys
rm -f build/Debug/GNU-Linux-x86/sys/charon.o.d
g++    -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/sys/charon.o.d -o build/Debug/GNU-Linux-x86/sys/charon.o sys/charon.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/charon build/Debug/GNU-Linux-x86/sys/charon.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/sys/chin.o build/Debug/GNU-Linux-x86/sys/chout.o  
build/Debug/GNU-Linux-x86/sys/chin.o: In function `chio::chin_::check()':

This right here is what I am struggling with. I painstakingly setup the library I use for these functions so I don’t know what I fubar’d

/home/josh/Projects/Maze/Charon/sys/chin.cpp:28: undefined reference to `kbhit'
/home/josh/Projects/Maze/Charon/sys/chin.cpp:33: undefined reference to `stdscr'
/home/josh/Projects/Maze/Charon/sys/chin.cpp:33: undefined reference to `wgetch'
/home/josh/Projects/Maze/Charon/sys/chin.cpp:35: undefined reference to `kbhit'
collect2: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Linux-x86/charon] Error 1
gmake[2]: Leaving directory `/home/josh/Projects/Maze/Charon'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/home/josh/Projects/Maze/Charon'
gmake: *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 1s)

Here is the cpp file chin.cpp

/* 
 * File:   chin.cpp
 * Author: josh
 * 
 * Created on 08 April 2012, 10:00
 */
#include 
#include 
#include 
#include 
#include "../headers/charon.h"

using namespace std;
using namespace charon;
using namespace chio;
namespace chio
{
  chin_::chin_(){}
  chin_::chin_(charon_ &handle) {
    engine = &handle;
    //key_presses = new deque();
  }
  chin_::~chin_() {
  }

  bool chin_::check()
  {
    if(kbhit())
    {
      while(true)
      {
        char ch;
        ch = getch();
        key_presses.push_back(ch);
        if(!kbhit())
          return true;
      }
    }
    return false;
  }

  void chin_::update()
  {
    while(stream_in)
    {
      check();
    }
  }
}

So at the top of that file you can see that I include borland/conio.h When I was searching for a particular function I used all the time back in the day I found it was in conio.h which has something to do with borland, a compiler if I remember correctly. I had to install dev-c++ bloodshed on windows, grab the include directory I then renamed it to borland and popped it into my linux box’s include directory.

I had one compile error originally about a dependency within a header, either conio itself or one it used, and all I did was change it so that it pointed to the correct place.

Now I don’t know what the heck is going on because I expected the compiler to simply find all of those. It finds the header file so the only thing I can think of is maybe the header isn’t able to find hpp files, but then why isn’t it saying that instead of specifying the functions within said hypothetical hpp files. So since I am into hypothetical situations here, I clearly need some help.

  1. You have two problems.

    1. You can’t just take the Borland headers and just drop them in and expect them to work. Headers are usually dependent on libraries. These are platform-specific (and sometimes compiler-specific), which won’t work when used on a different OS. Not to mention, the headers often include a bunch of other headers, which include other headers, etc. Some or all of these may be compiler or platform specific.

    2. CONIO.H was a nonstandard Windows-only header and is not used any more. There is probably another, correct way to do this.

  2. You have a linker error because it is not linking against the library that contains the implementation for those functions. You use -l to specify libraries to link with, and LIBRARY_PATH specifies path to find libraries

Originally posted 2013-11-27 11:53:36.