title: C++: Library import errors (‘stdin_fileno’ was not declared in this scope)
body: <p>Right so I've run this code using GCC 4.8.4 as the compiler on another computer running Ubuntu 14.04 and it runs fine but it doesn't seem to compile here.</p>
  
  <p>Here's the code (a pretty standardised piece of code available online). I've stripped pretty much everything away and it still fails on compile :/</p>
  
  <pre><code>#include "company/detectors.hpp"
  #include &lt;thread&gt;
  #include &lt;stdio.h&gt;
  #include &lt;termios.h&gt;
  #include &lt;fcntl.h&gt;
  #include "opencv2/opencv.hpp"
  
  int kbhit(void)
  {
      struct termios oldt, newt;
      int ch;
      int oldf;
      tcgetattr(stdin_fileno, &amp;oldt);
      newt = oldt;
      newt.c_lflag &amp;= ~(icanon | echo);
      tcsetattr(stdin_fileno, tcsanow, &amp;newt);
      oldf = fcntl(stdin_fileno, f_getfl, 0);
      fcntl(stdin_fileno, f_setfl, oldf | o_nonblock);
      ch = getchar();
      tcsetattr(stdin_fileno, tcsanow, &amp;oldt);
      fcntl(stdin_fileno, f_setfl, oldf);
      if (ch != eof) {
          ungetc(ch, stdin);
          return 1;
      }
      return 0;
  } 
  int main() {}
  </code></pre>
  
  <p>Here's the type of error I'm receiving:</p>
  
  <pre><code>optimisation.cpp: In function ‘int kbhit()’:
  optimisation.cpp:14:12: error: ‘stdin_fileno’ was not declared in this scope
    tcgetattr(stdin_fileno, &amp;oldt);
              ^
  optimisation.cpp:16:20: error: ‘icanon’ was not declared in this scope
    newt.c_lflag &amp;= ~(icanon | echo);
                      ^
  optimisation.cpp:16:29: error: ‘echo’ was not declared in this scope
    newt.c_lflag &amp;= ~(icanon | echo);
                               ^
  optimisation.cpp:17:26: error: ‘tcsanow’ was not declared in this scope
    tcsetattr(stdin_fileno, tcsanow, &amp;newt);
                            ^
  optimisation.cpp:18:29: error: ‘f_getfl’ was not declared in this scope
    oldf = fcntl(stdin_fileno, f_getfl, 0);
                               ^
  optimisation.cpp:19:22: error: ‘f_setfl’ was not declared in this scope
    fcntl(stdin_fileno, f_setfl, oldf | o_nonblock);
                        ^
  optimisation.cpp:19:38: error: ‘o_nonblock’ was not declared in this scope
    fcntl(stdin_fileno, f_setfl, oldf | o_nonblock);
                                        ^
  optimisation.cpp:23:12: error: ‘eof’ was not declared in this scope
    if (ch != eof) {
              ^
  make: *** [bin/optimisation.o] Error 1
  </code></pre>
  
  <p>What I don't seem to understand is how this fails to compile on this computer while it compiles absolutely fine with the same makefile on another PC (with nearly identical packages installed etc.). I'm probably making a fundamental error here but I'd love to know what I'm doing wrong...</p>
  
  <p>Here's my Makefile:</p>
  
  <pre><code>CC=g++
  OBJ= bin/
  TARGET=optimisation
  
  CFLAGS= `pkg-config --cflags opencv` -O2 -Wall -std=c++11 $(BOOST)
  LINKFLAGS = `pkg-config --libs opencv`
  CUDA = -I/usr/local/cuda/include -L/usr/local/cuda/lib
  BOOST = -lboost_system -lboost_filesystem -lboost_regex
  COMPDIR= -L/usr/local/lib/ -I/usr/local/include/
  COMPLIB = -lcompany
  NCURSES = -lncurses
  
  OBJECTS= optimisation.o
  
  all:$(TARGET)
  
  $(TARGET): $(addprefix $(OBJ),$(OBJECTS)) 
      $(CC) -o $(OBJ)$(TARGET) $(addprefix $(OBJ),$(OBJECTS)) $(COMPDIR) $(COMPLIB) $(BOOST) $(NCURSES) $(LINKFLAGS) $(SQL) $(CAFFE) -lglog -lgflags -lcpr -lcurl
  
  $(OBJ)%.o: $(SRC)%.cpp | MKDIR
      $(CC) $&lt; -g -o $@ -c $(CFLAGS) -w $(CUDA)
  
  clean:
      rm -rf $(OBJ)*.o 
  
  MKDIR:
      mkdir -p $(OBJ)
  
  print-%: ; @echo $*=$($*)
  </code></pre>
  
  <p>As per a post online, I've tried to use <code>-std=gnu+11</code> instead of <code>-std=c++11</code> and have also tried to <code>#include &lt;unist.h&gt;</code> but to no avail...</p>
  
  <p>On top of this, no opencv functions/objects (which is definitely installed correctly as I can use it via python) are recognised.</p>
  
  <p>So please let me know what fundamental thing I'm doing wrong! I'm a bit new at this so I'd appreciate any advice/hints &amp; tips!</p>
  
  <p>Thanks!</p>