Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8900461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:06:14+00:00 2026-06-15T01:06:14+00:00

I’m going over the Stanford CS106B online course, and created a folder /usr/local where

  • 0

I’m going over the Stanford CS106B online course, and created a folder /usr/local where I put the header files for the course. However, whenever I call the header files I run into problems. Take this, for instance. When I try to compile it, I get the error , but RandomChance(double n) is a function in the header file random.h. Help!

Undefined symbols for architecture x86_64:
“RandomChance(double)”, referenced from:
flipCoin() in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The program is below:

#include <iostream>
#include <string>
#include "/usr/local/random.h"

using namespace std;

string flipCoin();

string flipCoin() {
    if (RandomChance(0.50)) {
        return "heads";
    } else {
        return "tails";
    }
}

int main (int argc, const char * argv[])
{

    cout << "Enter number of votes" << endl;
    cout << "Enter percentage spread between candidates" << endl;
    cout << "Enter voting error percentage" << endl;
    return 0;
}

This is random.h

/*
 * Function: Randomize
 * Usage: Randomize();
 * -------------------
 * This function sets the random seed so that the random sequence
 * is unpredictable.   If this function is not called, the other 
 * functions will return the same values on each run. During the
 * debugging phase, it is best not to call this function, so that 
 * program behavior is repeatable.
 */
void Randomize();

/*
 * Function: RandomInteger
 * Usage: n = RandomInteger(low, high);
 * ------------------------------------
 * This function returns a random integer in the range low to high,
 * inclusive.
 */
int RandomInteger(int low, int high);

/*
 * Function: RandomReal
 * Usage: d = RandomReal(low, high);
 * ---------------------------------
 * This function returns a random real number in the half-open
 * interval [low .. high), meaning that the result is always
 * greater than or equal to low but strictly less than high.
 */
double RandomReal(double low, double high);

/*
 * Function: RandomChance
 * Usage: if (RandomChance(p)) . . .
 * ---------------------------------
 * The RandomChance function returns true with the probability
 * indicated by p, which should be a floating-point number between
 * 0 (meaning never) and 1 (meaning always).  For example, calling
 * RandomChance(.30) returns true 30 percent of the time.
 */
bool RandomChance(double p);

#endif /*RANDOM_H_*/

UPDATE: So it worked, and then I added another library by doing #include simpio.h and the whole thing went haywire. It showed 38 errors, including the following.

Ld /Users/alexandermoreno/Library/Developer/Xcode/DerivedData/voting-ccwjagcijcytcigfgxvxyiaplsxm/Build/Products/Debug/voting normal i386
    cd "/Users/alexandermoreno/Documents/Paradigms/assignment 1/voting"
    setenv MACOSX_DEPLOYMENT_TARGET 10.7
    /Developer/usr/bin/clang++ -arch i386 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Users/alexandermoreno/Library/Developer/Xcode/DerivedData/voting-ccwjagcijcytcigfgxvxyiaplsxm/Build/Products/Debug -F/Users/alexandermoreno/Library/Developer/Xcode/DerivedData/voting-ccwjagcijcytcigfgxvxyiaplsxm/Build/Products/Debug -filelist /Users/alexandermoreno/Library/Developer/Xcode/DerivedData/voting-ccwjagcijcytcigfgxvxyiaplsxm/Build/Intermediates/voting.build/Debug/voting.build/Objects-normal/i386/voting.LinkFileList -mmacosx-version-min=10.7 -lcs106 -o /Users/alexandermoreno/Library/Developer/Xcode/DerivedData/voting-ccwjagcijcytcigfgxvxyiaplsxm/Build/Products/Debug/voting

Undefined symbols for architecture i386:
  "___CFConstantStringClassReference", referenced from:
      CFString in libcs106.a(mainwrapper.o)
      CFString in libcs106.a(mainwrapper.o)
      CFString in libcs106.a(mainwrapper.o)
      CFString in libcs106.a(mainwrapper.o)
      CFString in libcs106.a(mainwrapper.o)
      CFString in libcs106.a(mainwrapper.o)
      CFString in libcs106.a(mainwrapper.o)
      ...
  "_NSApp", referenced from:
      +[Glue showAbout:] in libcs106.a(mainwrapper.o)
      TerminateApp() in libcs106.a(mainwrapper.o)
      +[NSBundleWithoutSpuriousErrorLog aloadNibNamed:owner:] in libcs106.a(mainwrapper.o)
      _main in libcs106.a(mainwrapper.o)
      -[ConsoleTextView keyDown:] in libcs106.a(ConsoleTextView.o)
      +[Glue showAbout:] in libcs106.a(mainwrapper.o)
      TerminateApp() in libcs106.a(mainwrapper.o)
      +[NSBundleWithoutSpuriousErrorLog aloadNibNamed:owner:] in libcs106.a(mainwrapper.o)
      _main in libcs106.a(mainwrapper.o)
      -[ConsoleTextView keyDown:] in libcs106.a(ConsoleTextView.o)
  "_objc_msgSendSuper", referenced from:
      +[NSBundleWithoutSpuriousErrorLog aloadNibNamed:owner:] in libcs106.a(mainwrapper.o)
      -[ConsoleTextView initWithFrame:] in libcs106.a(ConsoleTextView.o)
      -[ConsoleTextView setFont:] in libcs106.a(ConsoleTextView.o)
      -[ConsoleTextView dealloc] in libcs106.a(ConsoleTextView.o)
      -[ConsoleTextView keyDown:] in libcs106.a(ConsoleTextView.o)
      -[ConsoleTextView rangeForUserTextChange] in libcs106.a(ConsoleTextView.o)
  "_CFBundleGetInfoDictionary", referenced from:
      _main in libcs106.a(mainwrapper.o)
  "_CFBundleCopyBundleURL", referenced from:
      _main in libcs106.a(mainwrapper.o)
  "_objc_msgSend", referenced from:
      +[Glue applicationDidFinishLaunching:] in libcs106.a(mainwrapper.o)
      +[Glue showAbout:] in libcs106.a(mainwrapper.o)
      CocoaConsoleResize(int, int, int, int) in libcs106.a(mainwrapper.o)
      TerminateApp() in libcs106.a(mainwrapper.o)
      SetConsoleSize(int, int, int, bool) in libcs106.a(mainwrapper.o)
      patched_read(void*, char*, int) in libcs106.a(mainwrapper.o)
      CreateMenuWithItems(NSString*, menuitem*, int) in libcs106.a(mainwrapper.o)
      ...
  "_CFURLCreateCopyDeletingLastPathComponent", referenced from:
      _main in libcs106.a(mainwrapper.o)
  "_CFURLGetFileSystemRepresentation", referenced from:
      _main in libcs106.a(mainwrapper.o)
  "_CFBundleGetMainBundle", referenced from:
      _main in libcs106.a(mainwrapper.o)
  "Main()", referenced from:
      +[Glue studentMain] in libcs106.a(mainwrapper.o)
  "_CFRelease", referenced from:
      _main in libcs106.a(mainwrapper.o)
  "_NSFileHandleDataAvailableNotification", referenced from:
      -[ConsoleTextView registerForNotifications] in libcs106.a(ConsoleTextView.o)
  "_NSForegroundColorAttributeName", referenced from:
      -[ConsoleTextView setFont:] in libcs106.a(ConsoleTextView.o)
  "_NSFontAttributeName", referenced from:
      -[ConsoleTextView setFont:] in libcs106.a(ConsoleTextView.o)
      +[ConsoleTextView contentSizeForPointSize:numRows:numCols:] in libcs106.a(ConsoleTextView.o)
  "_NSBeep", referenced from:
      -[ConsoleTextView keyDown:] in libcs106.a(ConsoleTextView.o)
  "_objc_msgSend_fpret", referenced from:
      +[ConsoleTextView contentSizeForPointSize:numRows:numCols:] in libcs106.a(ConsoleTextView.o)
  "_objc_msgSend_stret", referenced from:
      -[ConsoleTextView setPointSize:numRows:numCols:center:] in libcs106.a(ConsoleTextView.o)
      +[ConsoleTextView contentSizeForPointSize:numRows:numCols:] in libcs106.a(ConsoleTextView.o)
      +[ConsoleTextView createConsoleInWindow] in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSThread", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(mainwrapper.o)
  ".objc_class_name_NSAutoreleasePool", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(mainwrapper.o)
  ".objc_class_name_NSDictionary", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(mainwrapper.o)
  ".objc_class_name_NSString", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(mainwrapper.o)
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSMenu", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(mainwrapper.o)
  ".objc_class_name_NSMenuItem", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(mainwrapper.o)
  ".objc_class_name_NSBundle", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(mainwrapper.o)
      .objc_class_name_NSBundleWithoutSpuriousErrorLog in libcs106.a(mainwrapper.o)
     (maybe you meant: .objc_class_name_NSBundleWithoutSpuriousErrorLog)
  ".objc_class_name_NSApplication", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(mainwrapper.o)
  ".objc_class_name_NSObject", referenced from:
      .objc_class_name_Glue in libcs106.a(mainwrapper.o)
  ".objc_class_name_NSAttributedString", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSMutableDictionary", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSFont", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSScroller", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSScreen", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSWindow", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSScrollView", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSColor", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSNotificationCenter", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSFileHandle", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSData", referenced from:
      pointer-to-literal-objc-class-name in libcs106.a(ConsoleTextView.o)
  ".objc_class_name_NSTextView", referenced from:
      .objc_class_name_ConsoleTextView in libcs106.a(ConsoleTextView.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

and this is the #simpio.h file

#ifndef SIMPIO_H_
#define SIMPIO_H_
/*
 * File: simpio.h
 * Version: 1.0CPP
 * Last modified on Wed Sep 18 13:34:29 PDT 2002 by jzelenski
 * ----------------------------------------------------------
 * This interface provides access to a simple package of
 * functions that simplify the reading of console input.
 */

#include "genlib.h"

/*
 * Function: GetInteger
 * Usage: n = GetInteger();
 * ------------------------
 * GetInteger reads a line of text from standard input and scans
 * it as an integer.  The integer value is returned.  If an
 * integer cannot be scanned or if more characters follow the
 * number, the user is given a chance to retry.
 */

int GetInteger();


/*
 * Function: GetLong
 * Usage: n = GetLong();
 * ---------------------
 * GetLong reads a line of text from standard input and scans
 * it into a long integer.  The long is returned.  If the 
 * number cannot be scanned or if extra characters follow it,
 * the user is given a chance to retry.
 */

long GetLong();

/*
 * Function: GetReal
 * Usage: x = GetReal();
 * ---------------------
 * GetReal reads a line of text from standard input and scans
 * it as a double.  If the number cannot be scanned or if extra
 * characters follow after the number ends, the user is given
 * a chance to reenter the value.
 */

double GetReal();


/*
 * Function: GetLine
 * Usage: s = GetLine();
 * ---------------------
 * GetLine reads a line of text from standard input and returns
 * the line as a string.  The newline character that terminates
 * the input is not stored as part of the string that is returned.
 */

string GetLine();

#endif /*SIMPIO_H_*/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:06:15+00:00Added an answer on June 15, 2026 at 1:06 am

    Ok, so I saw that this got marked as a popular question. For anyone doing this, I would simply recommend looking up a later version of cs106b rather than the psets from SEE or iTunes, and downloading those and just waiting for the solutions to come out if you need them. A lot of the time, it will already be set up to work with the latest version of XCode. If not, it will be a bit of a mess setting up potentially. They also have some documentation describing what to do in the case of linker errors on most CS106b sites.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.