Need help with UNIX compiler commands

Ask a Question related to AIX, Design and Development.

  1. #1

    Default Need help with UNIX compiler commands

    Consider this simple C++ program:

    #include <iostream.h>
    int main(void) {

    cout << "Hello, world!" << endl;
    return 0; //This is optional
    }

    I can't get the UNIX compiler to recognize <iostream.h>

    I know the file is there because I copied it into the same subdirectory
    where the program I am trying to compile and run is.

    Still, when I use cc myfile.c I get an error message saying <iostream.h>
    cannot be found.

    The iostream.h file is in /usr/ibmcxx/include/iostream.h

    How do I make sure that directory is in my includes path?




    Les Coover Guest

  2. Similar Questions and Discussions

    1. please tell me what are the following unix commands:
      Hello, I am not a UNIX expert can you please tell me how to execute or achieve the following functions, what are the unix commands: How to...
    2. C Compiler (same message in btintra.unix)
      Hello, I am looking to compile and build a shared library in Solaris 8, but dont have a licensed C compiler. Could anyone help if BT has a...
    3. Help with UNIX commands
      I am researching some unix commands and I would like to know if someone knows where I can find them online. I just want to know what are they used...
    4. Using external Unix commands
      I cant use Telnet or Sockets because the modules are not loaded on. I want to automate telnets to a list of ips. It looks like this is running...
    5. Unix equivalent of Dos commands
      I am trying to send strings of data to a customer display connect to /dev/tty2a in Openserver 5.0.5. The use manual explains how to do this in...
  3. #2

    Default Re: Need help with UNIX compiler commands

    In article <xd37b.186$NW3.175@news1.central.cox.net>, Les Coover <lcc66604@cox.net.spam> wrote:
    > Consider this simple C++ program:
    >
    > #include <iostream.h>
    > int main(void) {
    >
    > cout << "Hello, world!" << endl;
    > return 0; //This is optional
    > }
    >
    > I can't get the UNIX compiler to recognize <iostream.h>
    1. The C++ standard now uses #include <iostream> rather than the .h form.

    It will still work for backward compatibility for at least a while or
    indefinitely but you should be using the modern form for anything new.

    2. You're trying to use the C compiler to compile a C++ program. You want
    to use the C++ compiler instead. :)

    3. The file is test.c or whatever -- you may want to rename it to test.C

    4. Then do:

    $ xlC test.C -o <outputfilename>

    That will work without any errors.

    -Dan
    Dan Foster Guest

  4. #3

    Default Re: Need help with UNIX compiler commands

    Tried

    $xlC test.C -o test.O

    once with <iostream> and then again with <iostream.h>

    Same result both times:

    Preprocessor directive #include is not recognized.

    One other thing -- on the C programs I use

    $cc test.c
    $./a.out

    to compile and run programs. Is there a similar command like ./a.out to
    run a C++ compiled program?


    "Dan Foster" <dsf@globalcrossing.net> wrote in message
    news:slrnblpgkc.9i3.dsf@gaia.roc2.gblx.net...
    > In article <xd37b.186$NW3.175@news1.central.cox.net>, Les Coover
    <lcc66604@cox.net.spam> wrote:
    > > Consider this simple C++ program:
    > >
    > > #include <iostream.h>
    > > int main(void) {
    > >
    > > cout << "Hello, world!" << endl;
    > > return 0; //This is optional
    > > }
    > >
    > > I can't get the UNIX compiler to recognize <iostream.h>
    >
    > 1. The C++ standard now uses #include <iostream> rather than the .h form.
    >
    > It will still work for backward compatibility for at least a while or
    > indefinitely but you should be using the modern form for anything new.
    >
    > 2. You're trying to use the C compiler to compile a C++ program. You want
    > to use the C++ compiler instead. :)
    >
    > 3. The file is test.c or whatever -- you may want to rename it to test.C
    >
    > 4. Then do:
    >
    > $ xlC test.C -o <outputfilename>
    >
    > That will work without any errors.
    >
    > -Dan

    Les Coover Guest

  5. #4

    Default Re: Need help with UNIX compiler commands

    In article <PX37b.258$NW3.66@news1.central.cox.net>, Les Coover <lcc66604@cox.net.spam> wrote:
    > Tried
    >
    > $xlC test.C -o test.O
    >
    > once with <iostream> and then again with <iostream.h>
    >
    > Same result both times:
    >
    > Preprocessor directive #include is not recognized.
    Now that *is* interesting! I had tried it myself before I posted with the
    original reply, and not a single error message... and also worked correctly
    when I ran the generated binary.

    What version/level are your compiler filesets at? Ie:

    $ lslpp -l|grep xlC
    $ lslpp -l|grep vacpp

    Looks like I had tested it on a machine with xlC 4.0/4.3; I thought I had
    run the test on the Visual Age (vacpp) 6.0 machine but apparently not.

    My test failed with vacpp 5.0 only if I used <iostream> instead of
    <iostream.h>.

    With 6.0, it complains if you use <iostream.h> instead of <iostream> as I
    seem to recall.

    It would have to be something *really* odd for it to not parse #include
    correctly... just really odd.
    > One other thing -- on the C programs I use
    >
    > $cc test.c
    > $./a.out
    >
    > to compile and run programs. Is there a similar command like ./a.out to
    > run a C++ compiled program?
    Looks like it defaults to a file named a.out for C++ compilers if no -o
    parameter is given, as well. (I used 'xlC test.C' and checked to see what
    file was created.)

    -Dan
    Dan Foster Guest

  6. #5

    Default Re: Need help with UNIX compiler commands

    -a Displays additional ("all") information when combined with
    other flags. (Not valid with -f, only valid with -B when
    combined with -h)
    -B Permits PTF ID input. (Not valid with -L)
    -c Colon-separated output. (Not valid with -La)
    -d Dependents (filesets for which this is a requisite).
    -f Files that belong to this fileset.
    -h History information.
    -I Limits listings to base level filesets (no updates displayed).
    -i Product Identification information (requested per fileset).
    -J Use list as the output format. (Valid with -l and -L)
    -L Lists fileset names, latest level, states, and descriptions.
    (Consolidates usr, root and share part information.)
    -l Lists fileset names, latest level, states, and descriptions.
    (Separates usr, root and share part information.)
    -O Data comes from [r] root and/or [s] share and/or [u] usr.
    (Not valid with -L)
    -p Requisites of installed filesets.
    -q Quiet (no column headers).
    -w List fileset that owns this file.

    One of the following mutually exclusive flags: d,f,h,i,L,l,p,w
    must be specified.

    One of the system administrators sent me this message:

    the iostream.h file is in /usr/ibmcxx/include/iostream.h. make sure that
    that directory is in your includes path.

    I copied the file into the same subdirectory where the file is that I want
    to compile. Is there something else
    I need to do to make sure it is in the includes path?


    "Dan Foster" <dsf@globalcrossing.net> wrote in message
    news:slrnblpjn0.9i3.dsf@gaia.roc2.gblx.net...
    > In article <PX37b.258$NW3.66@news1.central.cox.net>, Les Coover
    <lcc66604@cox.net.spam> wrote:
    > > Tried
    > >
    > > $xlC test.C -o test.O
    > >
    > > once with <iostream> and then again with <iostream.h>
    > >
    > > Same result both times:
    > >
    > > Preprocessor directive #include is not recognized.
    >
    > Now that *is* interesting! I had tried it myself before I posted with the
    > original reply, and not a single error message... and also worked
    correctly
    > when I ran the generated binary.
    >
    > What version/level are your compiler filesets at? Ie:
    >
    > $ lslpp -l|grep xlC
    > $ lslpp -l|grep vacpp
    >
    > Looks like I had tested it on a machine with xlC 4.0/4.3; I thought I had
    > run the test on the Visual Age (vacpp) 6.0 machine but apparently not.
    >
    > My test failed with vacpp 5.0 only if I used <iostream> instead of
    > <iostream.h>.
    >
    > With 6.0, it complains if you use <iostream.h> instead of <iostream> as I
    > seem to recall.
    >
    > It would have to be something *really* odd for it to not parse #include
    > correctly... just really odd.
    >
    > > One other thing -- on the C programs I use
    > >
    > > $cc test.c
    > > $./a.out
    > >
    > > to compile and run programs. Is there a similar command like ./a.out
    to
    > > run a C++ compiled program?
    >
    > Looks like it defaults to a file named a.out for C++ compilers if no -o
    > parameter is given, as well. (I used 'xlC test.C' and checked to see what
    > file was created.)
    >
    > -Dan

    Les Coover Guest

  7. #6

    Default Re: Need help with UNIX compiler commands

    Dan, got it to work using

    $xlC test.C
    $./a.out

    The problem--a syntax error in my source code. I sincerely appreciate your
    help.

    Les


    "Les Coover" <lcc66604@cox.net.spam> wrote in message
    news:hn67b.519$NW3.230@news1.central.cox.net...
    > -a Displays additional ("all") information when combined with
    > other flags. (Not valid with -f, only valid with -B when
    > combined with -h)
    > -B Permits PTF ID input. (Not valid with -L)
    > -c Colon-separated output. (Not valid with -La)
    > -d Dependents (filesets for which this is a requisite).
    > -f Files that belong to this fileset.
    > -h History information.
    > -I Limits listings to base level filesets (no updates displayed).
    > -i Product Identification information (requested per fileset).
    > -J Use list as the output format. (Valid with -l and -L)
    > -L Lists fileset names, latest level, states, and descriptions.
    > (Consolidates usr, root and share part information.)
    > -l Lists fileset names, latest level, states, and descriptions.
    > (Separates usr, root and share part information.)
    > -O Data comes from [r] root and/or [s] share and/or [u] usr.
    > (Not valid with -L)
    > -p Requisites of installed filesets.
    > -q Quiet (no column headers).
    > -w List fileset that owns this file.
    >
    > One of the following mutually exclusive flags: d,f,h,i,L,l,p,w
    > must be specified.
    >
    > One of the system administrators sent me this message:
    >
    > the iostream.h file is in /usr/ibmcxx/include/iostream.h. make sure that
    > that directory is in your includes path.
    >
    > I copied the file into the same subdirectory where the file is that I want
    > to compile. Is there something else
    > I need to do to make sure it is in the includes path?
    >
    >
    > "Dan Foster" <dsf@globalcrossing.net> wrote in message
    > news:slrnblpjn0.9i3.dsf@gaia.roc2.gblx.net...
    > > In article <PX37b.258$NW3.66@news1.central.cox.net>, Les Coover
    > <lcc66604@cox.net.spam> wrote:
    > > > Tried
    > > >
    > > > $xlC test.C -o test.O
    > > >
    > > > once with <iostream> and then again with <iostream.h>
    > > >
    > > > Same result both times:
    > > >
    > > > Preprocessor directive #include is not recognized.
    > >
    > > Now that *is* interesting! I had tried it myself before I posted with
    the
    > > original reply, and not a single error message... and also worked
    > correctly
    > > when I ran the generated binary.
    > >
    > > What version/level are your compiler filesets at? Ie:
    > >
    > > $ lslpp -l|grep xlC
    > > $ lslpp -l|grep vacpp
    > >
    > > Looks like I had tested it on a machine with xlC 4.0/4.3; I thought I
    had
    > > run the test on the Visual Age (vacpp) 6.0 machine but apparently not.
    > >
    > > My test failed with vacpp 5.0 only if I used <iostream> instead of
    > > <iostream.h>.
    > >
    > > With 6.0, it complains if you use <iostream.h> instead of <iostream> as
    I
    > > seem to recall.
    > >
    > > It would have to be something *really* odd for it to not parse #include
    > > correctly... just really odd.
    > >
    > > > One other thing -- on the C programs I use
    > > >
    > > > $cc test.c
    > > > $./a.out
    > > >
    > > > to compile and run programs. Is there a similar command like ./a.out
    > to
    > > > run a C++ compiled program?
    > >
    > > Looks like it defaults to a file named a.out for C++ compilers if no -o
    > > parameter is given, as well. (I used 'xlC test.C' and checked to see
    what
    > > file was created.)
    > >
    > > -Dan
    >
    >

    Les Coover Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139