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

  • Home
  • SEARCH
  • 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 741195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:36:15+00:00 2026-05-14T08:36:15+00:00

I’ve created some mathematical functions that will be used in main() and by member

  • 0

I’ve created some mathematical functions that will be used in main() and by member functions in multiple host classes. I was thinking it would be easiest to make these math functions global in scope, but I’m not sure how to do this.

I’ve currently put all the functions in a file called Rdraws.cpp, with the prototypes in Rdraws.h. Even with all the #includes and externs, I’m getting a “symbol not found” compiler error at the first function call in main().

Here’s what I have:

// Rdraws.cpp
#include <cstdlib>
using namespace std;
#include <cmath>

#include "Rdraws.h"
#include "rng.h"

extern RNG rgen // this is the PRNG used in the simulation; global scope

void rmultinom( double p_trans[], int numTrials, int numTrans, int numEachTrans[] )
{ // function 1 def 
}

void rmultinom( const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]) 
{ // function 2 def
}

int rbinom( int nTrials, double pLeaving )
{ // function 3 def
}

// Rdraws.h

#ifndef RDRAWS
#define RDRAWS

void rmultinom( double[], int, int, int[] );
void rmultinom( const double[], const int, int, int[] );
int rbinom( int, double );

#endif

// main.cpp
...
#include "Rdraws.h"
...

extern void rmultinom(double p_trans[], int numTrials, int numTrans, int numEachTrans[]);
extern void rmultinom(const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]);
extern int rbinom( int n, double p );

RNG rgen; // global PRNG object created for simulation

int main() { ... }

I’m pretty new to programming. If there’s a dramatically smarter way to do this, I’d love to know.


Update

I’m a moron and didn’t realize I still hadn’t included Rdraws.cpp in my compiler. As a poster noted, I also forgot a semicolon.

I would still appreciate suggestions if the method outlined here could be improved upon.

  • 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-05-14T08:36:16+00:00Added an answer on May 14, 2026 at 8:36 am

    Which compiler are you using? You need to first compile all of the source files into object files and then link all of the object files together.

    Example:

    g++ -c -Wall -O2 main.cpp
    g++ -c -Wall -O2 Rdraws.cpp
    

    And then to get the executable…

    g++ -s main.o Rdraws.o
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
In order to apply a triggered animation to all ToolTip s in my app,
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.