CSC 101 Frequently Asked Questions (FAQ)




This file contains a compendium of frequently asked questions from CSC 101, asked during various discussion sections. The questions are in chronological order of being asked, starting with the most recently asked.

  1. Question: What does the the following compiler error message mean?
    sorry, not implemented: initialization of ...
        (automatic aggregate, compile with +a1) (2043)
    

    Answer: The central UNIX CC compiler requires that you use the "+a1" argument to compile any C++ program that contains aggregate array initialization. Put the "+a1" argument immediately after the CC command, as in

    CC +a1 some-array-program.cpp -o some-array-program
    

  2. Question: Why do I get the following compiler message
    /usr/ccs/bin/ld: Unsatisfied symbols:
       sqrt (code)
       pow (code)
    
    when I try to compile a program that uses functions such as sqrt and pow from the math library, even if I have #include <math.h> in my program?

    Answer: The CC compiler on the Cal Poly central UNIX system requires an extra argument in order to use the math library. Specifically, you must put the argument "-lm" at the end of the compile command. That's a dash, followed by the lowercase letter ell, followed by the lowercase letter em. Here is an example of the complete compile command, updated from the dissected command given in the Week 2 Lab Notes:



  3. Question: Why does the following compile command
    cc program1.cpp
    
    give the following weird error message?
    /usr/ccs/bin/ld: program1.cpp: Not a valid object file (invalid system id)
    

    Answer: Because UNIX is case sensitive, and the command to run the C++ compiler must be CC (that's two capital C's) not cc, which is what the command above is. BTW, cc (that's two lower case c's) is the compiler for the C programming language (as opposed to C++). So, when you type cc it's trying to compile a C++ program with the plain C compiler, and it's really confused.

  4. Question: Do my CSC 101 program files have to be named a certain way?

    Answer: Yes, in order to keep your programs nicely organized, and to understand the instructions for the turnin command. The following are the program file naming conventions you must use:

    1. Store your program files in a protected directory named "csc101", immediately under your UNIX home directory.

    2. Name the C++ source file for each programming assignment "programN.cpp" for N = 1 through 8, corresponding to the 8 programming assignments. Sometimes assignments will be in two or more parts, in which case you name your program files "programNL.cpp" for N = 1 through 8, and L = "a", "b", "c", ... .

    3. Name the executable object file for each programming assignment "programN", i.e., the same root file name as the C++ source file, but without the ".cpp" extension; recall from week 2 lab notes that the "-o" argument to the compiler is used to name the object file something other than "a.out"
    Note that these are required conventions for CSC 101, but not UNIX requirements. Except for the required ".cpp" extension, the UNIX C++ compiler does not care what you name your files.

  5. Question: Why can't I see the .emacs file when I use the UNIX ls command?

    Answer: You need to use the "-a" argument to ls in order to see files that start with a period, such as ".emacs".

  6. Question: How do I get that handy "tab thing" to work in the UNIX shell, so that I don't have to type out long file names?

    Answer: You need to use the UNIX shell called the "t-shell" (tcsh). To change to this shell permanently for the rest of the quarter, type the UNIX command chsh, with no arguments. The chsh command will prompt you with several choices for your shell. Type in the selection "/bin/tcsh" at the prompt. The next time you login, you will then be using the t-shell, and the tab character can be used for filename completion.





index | lectures | handouts | examples | textbook | doc | grades