Library Problem

This is a discussion on Library Problem within the C Programming forums, part of the General Programming Boards category; Hello, I'm trying to use a source code to run on Vista or 98 but my compiler Dev-C++ gives several ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    3

    Library Problem

    Hello,
    I'm trying to use a source code to run on Vista or 98 but my compiler Dev-C++ gives several problem messages about the libraries and other errors. I suppose the errors occur because the compiler doesn't see the libraries. Below is the source code and errors that occurs in it. What do you suggest to do to get rid of them, is there a way to add these libraries to Dev-C++?

    Code:
    #include <dos.h>
    #include <stdio.h> 
    #include <conio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <bios.h>
    #include "My_TPU.h"
    
    int LPT1, Base_Address;
    unsigned char Data_Byte, High_Nibble, Low_Nibble;
    
    unsigned char Read_Switches(void)
    {
             unsigned char High_Niblle, Low_Niblle;
             outport(Base_Address + 2,inport(Base_Address + 2) ||15);
             delay(50);
             Low_Nibble =  inport(Base_Address + 2);
             High_Nibble = inport(Base_Address + 1);
             Low_Nibble = Low_Nibble & 0x0F;
             High_Nibble = High_Nibble & 0x0F;
             Data_Byte = High_Nibble | Low_Nibble;
             return(Data_Byte);
             }
             void Display_Data(unsigned char Data_Byte)
             {
                  gotoxy(1,3); printf("LPT1 = %i    Data Byte = %i \n",LPT1,Data_Byte);
                  }
                  void main()
                  {
                       .clrscr();
                  Base_Address = 1024; LPT1 = peek(0, Base_Address + 8);
                  do
                  {
                               Data_Byte=Read_Switches();
                               Display_Data(Data_Byte);
                               }while(!kbhit());
                               }
    bios.h: No such file or directory.
    My_TPU.h: No such file or directory.
    In function `unsigned char Read_Switches()':
    15 `inport' undeclared (first use this function)
    (Each undeclared identifier is reported only once for each function it appears in.)
    `outport' undeclared (first use this function)
    16 `delay' undeclared (first use this function)
    `void Display_Data(unsigned char)':
    26 `gotoxy' undeclared (first use this function)
    26 At global scope:
    29 `main' must return `int'
    `int main(...)':
    30 expected primary-expression before '.' token
    31 `peek' undeclared (first use this function)

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    1. Learn how to indent properly
    2. conio.h is a no-no. Use pdcurses (google it)
    3. Listen to the warnings/errors. ie main must return int.
    4. bios.h is only for DOS and Windows 3.1. It's no longer, don't try and use it.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    3
    1-) I have the code printed on a paper, so I tried to write it exactly the same, also I'm not good at C, where do you see indentation problems?
    2-) conio.h doesn't give any problem as I see, am I wrong? The problems seem to be related to the libraries/headers bios.h and My_TPU.h
    3-) As I've got the code from a book, it shouldn't have any errors, neglecting my writing mistakes.
    4-) I'm trying to use an analog to digital converter to get digital data on the computer by feeding it with a voltage and getting the input from the printer port of the PC. I'm not sure if I should copy the libraries to the related directory of Dev-C++ or I should use a different compiler which includes these libraries. I'd appreciate if you know any.

    Thanks.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by evetevet View Post
    1-)where do you see indentation problems?
    Everywhere.

    Quote Originally Posted by evetevet View Post
    3-) As I've got the code from a book, it shouldn't have any errors, neglecting my writing mistakes.
    And as we all know, books never have any errors in them.
    BTW, how old is this book? It's obviously assuming you're using DOS.

    Most of the errors are saying it can't find those header files. Check if the book tells you which compiler it uses. You might need to install DOS in a virtual machine and compile it in there...
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    3
    Quote Originally Posted by cpjust View Post
    Everywhere.


    And as we all know, books never have any errors in them.
    BTW, how old is this book? It's obviously assuming you're using DOS.

    Most of the errors are saying it can't find those header files. Check if the book tells you which compiler it uses. You might need to install DOS in a virtual machine and compile it in there...
    I don't know C at all, so could you just tell me my mistakes? Did I put ' instead of ", what are they that I must change?

    Books have errors but I've built the circuit on the book, tried to write the code and boom! It gives 10-12 mistakes. I said I think they're because of the libaries that can't be seen by Dev-C++. If the writer is the biggest douche, it's possible, but I don't think that they let me(someone don't know much about C, in fact the writer must have got something from the parallel port by using this code) to write a book. If so, it'd be exactly what we end up with and there's no need to discuss.

    By the way, I've found some bios.h libraries from other compilers, copied them into Dev-C++'s include directory and neuronvisualcpp's library seems to have the least errors, but still the library gives a few. No track of My_TPU.h yet.

    The book is as old as to be digged out of the ruins of a dusty archieve. I'm using Windows95 but it seems old-fashioned for Dev-C++. Windows95 supports DOS, right? ******* compilers, older ones looks impossible to use and they don't include bios.h or My_TPU.h, I'm waiting for my savior one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. undefined Reference when linking a library
    By steve1_rm in forum C Programming
    Replies: 7
    Last Post: 03-12-2008, 05:34 PM
  2. Templates from DLL or static library problem
    By mikahell in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2008, 12:49 AM
  3. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  4. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  5. Problem With WinPcap library
    By DrMario in forum C Programming
    Replies: 0
    Last Post: 03-26-2005, 10:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21