Link to home
Start Free TrialLog in
Avatar of Davehudsn
Davehudsn

asked on

PThread compile problem on Knoppix with g++

I have a simulation program that I am trying to get working under knoppix using g++

I see that PThread.h is in the /usr/include directory, but it looks to me from the error messages that it is not finding the appropriate processes.

Here are the associated files:

script that does the compile/link:

  clear
  clear
  echo '------------------------------------------------------------------------
-------'
  echo '------ Psim3 C++ (POSIX threads) package for object oriented simulation
-------'
  # echo '------------------ (C) J. M. Garrido, 2004 -----------'
  echo '------------------------------------------------------------------------
-------'
  g++ -w -pthread $1 /usr/psim3/libpsim3.a -I/usr/psim3 -lm
  # the following are for bash and pdksh
  #if [ "$2" != "" ]  # change to parethesis for tcsh
  #then
  #  mv a.out $2
  #  echo "$2 created."
  #else
    echo "a.out created."
  #fi                 # change to endif fot tcsh
  echo '                  '


Here are the error messages:

-------------------------------------------------------------------------------
------ Psim3 C++ (POSIX threads) package for object oriented simulation -------
-------------------------------------------------------------------------------
/tmp/ccXpJn2d.o(.text+0x1d): In function `CPU::CPU[not-in-charge](char*)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccXpJn2d.o(.text+0x5d): In function `CPU::CPU[not-in-charge](char*)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccXpJn2d.o(.text+0x93): In function `CPU::CPU[in-charge](char*)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccXpJn2d.o(.text+0xd3): In function `CPU::CPU[in-charge](char*)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccXpJn2d.o(.text+0xf4): In function `CPU::Main_body()':
: undefined reference to `psched::get_simper()'
/tmp/ccXpJn2d.o(.text+0xfc): In function `CPU::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x113): In function `CPU::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x126): In function `CPU::Main_body()':
: undefined reference to `squeue::empty()'
/tmp/ccXpJn2d.o(.text+0x13e): In function `CPU::Main_body()':
: undefined reference to `squeue::out()'
/tmp/ccXpJn2d.o(.text+0x17b): In function `CPU::Main_body()':
: undefined reference to `process::delay(double)'
/tmp/ccXpJn2d.o(.text+0x1c7): In function `CPU::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x25f): In function `CPU::Main_body()':
: undefined reference to `process::reactivate()'
/tmp/ccXpJn2d.o(.text+0x269): In function `CPU::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x2aa): In function `CPU::Main_body()':
: undefined reference to `process::sleep()'
/tmp/ccXpJn2d.o(.text+0x2af): In function `CPU::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x2cb): In function `CPU::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x335): In function `CPU::Main_body()':
: undefined reference to `process::terminate()'
/tmp/ccXpJn2d.o(.text+0x363): In function `job::job[not-in-charge](char*, double, long)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccXpJn2d.o(.text+0x377): In function `job::job[not-in-charge](char*, double, long)':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x3b1): In function `job::job[not-in-charge](char*, double, long)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccXpJn2d.o(.text+0x3ed): In function `job::job[in-charge](char*, double, long)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccXpJn2d.o(.text+0x401): In function `job::job[in-charge](char*, double, long)':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x43b): In function `job::job[in-charge](char*, double, long)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccXpJn2d.o(.text+0x47b): In function `job::set_start()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x515): In function `job::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x5a2): In function `job::Main_body()':
: undefined reference to `squeue::full()'
/tmp/ccXpJn2d.o(.text+0x5ff): In function `job::Main_body()':
: undefined reference to `squeue::full()'
/tmp/ccXpJn2d.o(.text+0x64a): In function `job::Main_body()':
: undefined reference to `process::terminate()'
/tmp/ccXpJn2d.o(.text+0x65c): In function `job::Main_body()':
: undefined reference to `process::idle()'
/tmp/ccXpJn2d.o(.text+0x6ac): In function `job::Main_body()':
: undefined reference to `process::reactivate()'
/tmp/ccXpJn2d.o(.text+0x6b9): In function `job::Main_body()':
: undefined reference to `squeue::full()'
/tmp/ccXpJn2d.o(.text+0x6d5): In function `job::Main_body()':
: undefined reference to `squeue::into(process*)'
/tmp/ccXpJn2d.o(.text+0x716): In function `job::Main_body()':
: undefined reference to `process::sleep()'
/tmp/ccXpJn2d.o(.text+0x71b): In function `job::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x767): In function `job::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0x818): In function `job::Main_body()':
: undefined reference to `process::terminate()'
/tmp/ccXpJn2d.o(.text+0x847): In function `arrivals::arrivals[not-in-charge](char*, double, double)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccXpJn2d.o(.text+0x883): In function `arrivals::arrivals[not-in-charge](char*, double, double)':
: undefined reference to `erand::erand[in-charge](double, unsigned)'
/tmp/ccXpJn2d.o(.text+0x8e9): In function `arrivals::arrivals[not-in-charge](char*, double, double)':
: undefined reference to `erand::erand[in-charge](double, unsigned)'
/tmp/ccXpJn2d.o(.text+0x95a): In function `arrivals::arrivals[not-in-charge](char*, double, double)':
: undefined reference to `urand::urand[in-charge](long, long, unsigned)'
/tmp/ccXpJn2d.o(.text+0x9a3): In function `arrivals::arrivals[not-in-charge](char*, double, double)':
: undefined reference to `randint::seed(unsigned)'
/tmp/ccXpJn2d.o(.text+0xa14): In function `arrivals::arrivals[not-in-charge](char*, double, double)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccXpJn2d.o(.text+0xa55): In function `arrivals::arrivals[in-charge](char*, double, double)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccXpJn2d.o(.text+0xa91): In function `arrivals::arrivals[in-charge](char*, double, double)':
: undefined reference to `erand::erand[in-charge](double, unsigned)'
/tmp/ccXpJn2d.o(.text+0xaf7): In function `arrivals::arrivals[in-charge](char*, double, double)':
: undefined reference to `erand::erand[in-charge](double, unsigned)'
/tmp/ccXpJn2d.o(.text+0xb68): In function `arrivals::arrivals[in-charge](char*, double, double)':
: undefined reference to `urand::urand[in-charge](long, long, unsigned)'
/tmp/ccXpJn2d.o(.text+0xbb1): In function `arrivals::arrivals[in-charge](char*, double, double)':
: undefined reference to `randint::seed(unsigned)'
/tmp/ccXpJn2d.o(.text+0xc22): In function `arrivals::arrivals[in-charge](char*, double, double)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccXpJn2d.o(.text+0xc65): In function `arrivals::Main_body()':
: undefined reference to `psched::get_simper()'
/tmp/ccXpJn2d.o(.text+0xc6d): In function `arrivals::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0xc8d): In function `arrivals::Main_body()':
: undefined reference to `erand::fdraw()'
/tmp/ccXpJn2d.o(.text+0xca2): In function `arrivals::Main_body()':
: undefined reference to `process::delay(double)'
/tmp/ccXpJn2d.o(.text+0xca7): In function `arrivals::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0xce7): In function `arrivals::Main_body()':
: undefined reference to `process::terminate()'
/tmp/ccXpJn2d.o(.text+0xcfd): In function `arrivals::Main_body()':
: undefined reference to `erand::fdraw()'
/tmp/ccXpJn2d.o(.text+0xd14): In function `arrivals::Main_body()':
: undefined reference to `urand::draw()'
/tmp/ccXpJn2d.o(.text+0xd3f): In function `arrivals::Main_body()':
: undefined reference to `intstr(int, char*)'
/tmp/ccXpJn2d.o(.text+0xdc7): In function `arrivals::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccXpJn2d.o(.text+0xe29): In function `arrivals::Main_body()':
: undefined reference to `process::pstart()'
/tmp/ccXpJn2d.o(.text+0xe59): In function `batch::batch[not-in-charge](char*)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccXpJn2d.o(.text+0xeba): In function `batch::batch[not-in-charge](char*)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccXpJn2d.o(.text+0xeef): In function `batch::batch[in-charge](char*)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccXpJn2d.o(.text+0xf50): In function `batch::batch[in-charge](char*)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccXpJn2d.o(.text+0x1041): In function `batch::Main_body()':
: undefined reference to `process::pstart()'
/tmp/ccXpJn2d.o(.text+0x104e): In function `batch::Main_body()':
: undefined reference to `process::pstart()'
/tmp/ccXpJn2d.o(.text+0x1065): In function `batch::Main_body()':
: undefined reference to `simulation::start_sim(double)'
/tmp/ccXpJn2d.o(.text+0x132a): In function `main':
: undefined reference to `simulation::simulation[in-charge](char*)'
/tmp/ccXpJn2d.o(.text+0x138d): In function `main':
: undefined reference to `squeue::squeue[in-charge](char*, int)'
/tmp/ccXpJn2d.o(.text+0x152f): In function `main':
: undefined reference to `process::pstart()'
/tmp/ccXpJn2d.o(.text+0x153c): In function `main':
: undefined reference to `simulation::end_sim()'
/tmp/ccXpJn2d.o(.gnu.linkonce.r._ZTI3CPU+0x8): undefined reference to `typeinfo for process'
/tmp/ccXpJn2d.o(.gnu.linkonce.r._ZTI3job+0x8): undefined reference to `typeinfo for process'
/tmp/ccXpJn2d.o(.gnu.linkonce.r._ZTI8arrivals+0x8): undefined reference to `typeinfo for process'
/tmp/ccXpJn2d.o(.gnu.linkonce.r._ZTI5batch+0x8): undefined reference to `typeinfo for process'
collect2: ld returned 1 exit status
a.out created.
Avatar of _corey_
_corey_

The header is not what is lacking in this build.  The issue is that after compilation, g++ cannot link all the object files together into a single exectuble.  

The reason for this is missing object files or libraries.  The only thing I see you adding in that compilation is libpsim3.a .  Are you sure this is supposed to contain all the objects that you see are missing in that error list?

corey
Avatar of Davehudsn

ASKER

Hey Corey,

Maybe this will help - here is the CPP file - proc.h and queue.h are in the same directory as the this file (batch.cpp) when i do the compile:

#include "proc.h"
#include "queue.h"
#include <string>
//
class CPU;
class job;
class arrivals;
//
squeue *job_queue;                 // queue for waiting jobs
// System parameters
const int qsize = 1120;            // size of input queue
unsigned totmem = 40;              // total system memory
//
// Workload parameters
double mean_int_arr;               // mean inter-arrival period
double mean_ser;                   // mean service period
long mem_l;                        // lower bound for memory demand
long mem_u;                        // upper bound for memory demand
//
// Globals
double simperiod;                  // simulation period
double close_arrival;              // time to stop
//
double time_mem = 0;               // product time x memory
double acc_proc = 0;               // accumulated processor time
unsigned arrived = 0;              // number of arrived jobs
unsigned rejected = 0;             // number of rejected jobs
double idle_time = 0;              // acc processor idle time
double acc_sojourn_t = 0;          // accumulated job sojourn time
double acc_wait = 0;               // acc job wait time
unsigned completed_jobs = 0;       // number of completed jobs
//
//  Global object
CPU *proc;           // processor
arrivals * arr_obj;  // environment generating jobs
simulation * run;
//
//  Specifications of processes
//
class CPU: public process {
  // enum phasetype {RUN_JOB, COMPLETE_JOB, QUEUE_EMPTY, LEAVE_IDLE};
  // phasetype phase;
  job *curr_job;                 // job object
  double start;                  // time of start of job
  double job_time;               // cpu time for job
public:
  CPU(char *s);                  // constructor
  void Main_body(void);
};
//
class job: public process {
  // enum phasetype { ARRIVAL, FINISH_PROC };
  // phasetype phase;
  double arrival_time;
  double start;                 // start of service
  double jwait;                 // job wait time
  double service;               // job service service
  long jmem;                     // job memory size
  unsigned jobnum;              // job number
public:
  job(char *s, double ser, long mem);
  double  get_service(void);
  long  get_mem(void);
  void  set_start(void);
  void Main_body(void);
};
//
class arrivals: public process {
  // enum phasetype { INTER_ARRIVAL, NEW_ARRIVAL };
 // phasetype phase;
  erand *arr_period;          // random inter-arrival period
  erand *ser_period;          // random job service
  urand *jsize;               // random job size
  char *ss;                   // arrivals name
  long memreq;            // job memory requirements
public:
  arrivals(char *s, double arr_mean, double ser_mean);
  void Main_body(void);
};
//
//   implementation of processes
//
CPU::CPU(char *s): process (s) {
  // phase = RUN_JOB;
  cout << "Processor object created" << endl;
};
//
void CPU::Main_body(void) {
  double t_service;
  double simper = get_simper();
  long jmemreq;
  // switch(phase) {
  // cout << "Starting CPU Main_body " << endl;
  while (get_clock() < simper) {
  // case RUN_JOB:
     start =  get_clock();
     if ( !job_queue->empty()) {
        curr_job = ( job*) job_queue->out();
        curr_job->set_start();
        // phase = COMPLETE_JOB;
        t_service = curr_job->get_service();
        delay(t_service);
        cout << "CPU completed service of Job " << curr_job->t_name << endl;
        // case COMPLETE_JOB:
        completed_jobs++;
        job_time = get_clock() - start;
        acc_proc += job_time;
        jmemreq = curr_job->get_mem();
        time_mem += jmemreq * job_time;                    
        // cout << "Accumulated execution job time: " << acc_proc << endl;
        if ( curr_job == NULL )
          cout << "CPU with NULL Job " << endl;
        else
          curr_job->reactivate();   // delay(0);
     }
     else {
        // queue_empty();
        // void queue_empty() {
        // case QUEUE_EMPTY:
        cout << "CPU goes idle at " <<  get_clock() << endl;
        // phase = LEAVE_IDLE;
        sleep();
        // break;
        // case LEAVE_IDLE:
        idle_time += get_clock() - start;
        cout << "CPU is reactivated at " <<  get_clock() << endl;
        // phase = RUN_JOB;
        // break;
        // }
        // phase = QUEUE_EMPTY;    
        // break;
     }
     // phase = RUN_JOB;
     // break;
   } // endwhile
   cout << "terminating CPU " << endl;
   terminate();
};
//
// the constructor is called from 'arrivals'
job::job(char *s, double ser, long memreq): process (s) {
    arrival_time =  get_clock();
    service = ser;
    jmem = memreq;
    arrived++;
    // cout << t_name << " service time " << ser << " mem "
    //      << memreq << endl;
    // phase = ARRIVAL;
};
//
double  job :: get_service(void) {
   return ( service );
};
//
long  job :: get_mem(void) {
   return ( jmem );
};
//
void  job :: set_start(void) {
// this function sets the starting time of the job and displays
// the data (name, jobnum, clock time and service period)
   start =  get_clock();
   cout << t_name  << " starts service at "
        << start << " with service " << service << endl;
};
//
void job::Main_body(void) {
     // switch(phase) {
     // case ARRIVAL:
     jobnum = arrived;
     cout << t_name  << " requiring service "
          << service << " arrives at time " <<  get_clock()
          << endl;
     if ( jmem > totmem || job_queue->full() ) {
       // there  is not sufficient system memory for this job
       // or the input queue is already full, reject
       if(jmem > totmem)
         cout << t_name << " rejected for memory " << endl;
       if(job_queue->full())
         cout << t_name << " rejected queue full " << endl;
       rejected++;
       terminate();
     }
     else {
       if ( proc->idle() && proc != NULL ) {
             cout << t_name << " reactivating CPU" << endl;
             proc->reactivate();  // delay(0);
       }
       // job will wait in queue until processor executes it
       if(! job_queue->full()) {
          job_queue->into(this );
          cout << t_name << " joins queue and waiting" << endl;
          // phase = FINISH_PROC;
          sleep(); // suspend or deactivate
          // case FINISH_PROC:
          // Service completed, prepare to exit system
          acc_sojourn_t += ( ( get_clock()) - (arrival_time)) ;
          jwait = (start) - (arrival_time);
          // cout << t_name << " wait period " << jwait << endl;
          acc_wait += jwait;
          // display "Accumulated sojourn period: ", acc_sojourn_t;
          cout << t_name << " terminates at time "
               <<  get_clock() << endl;
          // resultis(0); delete (long *) this;
          // break;
          // }
       }
       else
          cout << "Job queue full" << endl;
       // break;
     }
     cout << "Terminating " << t_name << endl;
     terminate();
};
//
arrivals::arrivals(char *s, double arr_mean, double ser_mean):
        process (s) {
  // create objects for random variables
  arr_period = new erand (arr_mean, 7);
  ser_period = new erand (ser_mean, 3);
  jsize = new urand (mem_l, mem_u);
  // initialize pseudo_random stream
  // arr_period->seed(7);
  // ser_period->seed(7);
  jsize->seed(7);
  //
  // phase = INTER_ARRIVAL;
  ss = s;
  cout << "Arrivals created with " << arr_mean << " " << ser_mean << endl;
};
//
void arrivals::Main_body(void) {
  double ttr;
  int j = 0;
  char numj[12];
  char jobname[20] = "\0";
  job *mjob;
  double simper = get_simper();               // switch(phase) {
  // cout << "Starting arrivals Main_body " << "Close arrival: "
  //      << close_arrival << endl;
  while (get_clock() < simper) {
     // generate random value for inter-arrival period
     ttr = arr_period->fdraw();
     // cout << "Inter-arrival: " << ttr << endl;
     delay(ttr);
     if (  get_clock() > close_arrival) {
        cout << "Terminating arrivals " << endl;
        terminate();
        return;
     }
     else {
        // generate random value for job service
        ttr = ser_period->fdraw();
        // generate random value for job size
        memreq = jsize->draw();
        // create job object with appropriate parameters
        // cout << "Arrivals to create a new Job" << endl;
        strcpy(jobname, "Job");
        intstr(j, numj); // int to string numj
        strcat(jobname, numj);
        mjob = new job(jobname, ttr, memreq);
        j++;
        cout << "Arrivals generating " << jobname << " at " << get_clock() << endl;
        mjob->pstart();
     }
  }  // endwhile
};

//
class batch : public process {

public:
   batch(char *);
   void Main_body(void);
};
batch::batch(char *s) : process (s) {

  cout << "Process " << s << " created" << endl;
};
//
void batch::Main_body(void) {
   // cout << "In Main_body of: " << t_name << endl;
   proc = new CPU("Processor");

   arr_obj = new arrivals("Arrivals", mean_int_arr, mean_ser);
   // cout << "Starting thread objects" << endl;
   arr_obj->pstart();   // start arrivals object
   //
   proc->pstart();
   //
   run->start_sim(simperiod);
   //
   cout << endl << "Service factor: "
        << float(acc_proc) / float(acc_sojourn_t) << endl;
   cout << "Processor utilization: "
        << float(acc_proc) / float(simperiod) << endl;
   cout << "Total jobs arrived: " << arrived << endl;
   cout << "Total jobs rejected: " << rejected << endl;
   cout << "Throughput (jobs completed): " << completed_jobs << endl;
   cout << "Proportion Rejected: "
        << ( float(rejected) / float(arrived)) << endl;
   if ( completed_jobs > 0) {
        cout << "Average job wait period: "
             << float(acc_wait) / float(completed_jobs) << endl;
   }
   cout << "Average memory used: "
        << float(time_mem) / float(simperiod) << endl;

};

//
int main() {

   batch * application;

   simperiod = 37380.0;
   close_arrival = 37290.0;
   mean_int_arr = 7.5;
   mean_ser = 4.15;
   mem_l = 8;
   mem_u = 14;
   run = new simulation("Simple Batch OS");
   // create queue with default size qsize for incoming jobs
   job_queue = new squeue ("cust");
   //
   application = new batch("Batch");

   cout << "Workload parameters -  mean inter-arrival: " << mean_int_arr
        << "  mean CPU service demand: " << mean_ser << endl;
   cout << "  and memory demand: " << mem_l << " to " << mem_u << endl;
   cout << "Systems parameters - queue capacity: " << qsize
        << "  and system memory: " << totmem << endl;
   //

   application->pstart();

   //

   run->end_sim();
   // cout << "Ending simulation" << endl;
   return 0;

}
It looks like you are not compiling a lot of needed .cpp files along with batch.cpp such as proc.cpp/etc.

You need to add these source files to your compile command and then link.

corey
""t looks like you are not compiling a lot of needed .cpp files along with batch.cpp such as proc.cpp/etc.

You need to add these source files to your compile command and then link."


Hey Corey - i know this is a stupid question, but how do I do that?  I do not have the proc.cpp files.  All i have are the header files proc.h.

When i do compile only it works fine.  it is when i try to link everything that it crashes.

i am using "-lpthread" in my g++ command line, so it should be linking to the pthread library..... this works fine on a RedHat system - i just don't understand why it is not working on my Knoppix (Debian) system
proc.h is a file that you or someone in your team created right?  If it is in your source directory, that is what I was assuming.

Apparantly, it is a base class, and you're deriving from it.  Because of that, you also need to link in the implementation of process.

If this is part of a standard library, please specify.  The pthread library only includes pthread calls, not your other source code.

To add source files, you simply append them to your compilation command

g++ -I/some/dir/include -o MyExecutable Source1.cpp Source2.cpp Source3.cpp -lm -lpthread

corey
Well, unfortunately, it is not a program that i wrote or that a team member wrote.

A professor at my university wrote it and like an idiot i took on a project to write a web page "wrapper" around this program.  My first step is just to get the stupid thing to compile under debian linux.

My professor is being complelely un-helpful ....... his answer:  "it works on my red hat box here"  

So i am stuck trying to figure this out on my own.

There is a library file called "libpsim3.a" - inside of it there are a bunch of .o files like "proc.o"  

So i have the compiled versions that the header files point to.

This is the command I am using to compile/link:

g++ -w -I/usr/psim3 -o gobatch batch.cpp -lm -lpthread

So it looks like i have all the files i need i just can't figure out why it won't properly link them in....
I should clarify - i extracted the .o files out into the directory i am compiling in which is "/usr/psim3"

Also, i did try using "g++ -w batch.cpp /usr/psim3/libpsim3.a -I/usr/psim3 -lm -lpthread
ASKER CERTIFIED SOLUTION
Avatar of _corey_
_corey_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey Corey,

It is still not working.  I am going to change my project a little bit as the professor is not being very helpful.

I can edit/compile the program on his machine, so I will just modify the programs to take parameters from the command line.  I can then compile it on his box and just copy the executables to my box.  I wanted to be able to recompile on the fly, but i will just tell him that will be a phase 2 project if he wants that and he will have to give me access to all the source files so i can recompile everything from scratch.

I am still getting the same messages:

root@600x:/usr/psim3# g++ -I/usr/psim3 -L/usr/psim3 -o gobatch batch.cpp -lm -lpthread -lpsim3

In file included from /usr/include/c++/3.3/backward/iostream.h:31,
                 from proc.h:13,
                 from batch.cpp:13:
/usr/include/c++/3.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
/tmp/ccf7azU5.o(.text+0x1d): In function `CPU::CPU[not-in-charge](char*)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccf7azU5.o(.text+0x5d): In function `CPU::CPU[not-in-charge](char*)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccf7azU5.o(.text+0x93): In function `CPU::CPU[in-charge](char*)':
: undefined reference to `process::process[not-in-charge](char*, objtype)'
/tmp/ccf7azU5.o(.text+0xd3): In function `CPU::CPU[in-charge](char*)':
: undefined reference to `process::~process [not-in-charge]()'
/tmp/ccf7azU5.o(.text+0xf4): In function `CPU::Main_body()':
: undefined reference to `psched::get_simper()'
/tmp/ccf7azU5.o(.text+0xfc): In function `CPU::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccf7azU5.o(.text+0x113): In function `CPU::Main_body()':
: undefined reference to `get_clock()'
/tmp/ccf7azU5.o(.text+0x126): In function `CPU::Main_body()':
: undefined reference to `squeue::empty()'
/tmp/ccf7azU5.o(.text+0x13e): In function `CPU::Main_body()':
: undefined reference to `squeue::out()'

..... and more......
Corey,

Even though we didn't get this one solved i'm going to give you the points anyway because I now understand the compile/linking process on Linux a lot better than I did before.........  i haven't done command line compile/link since i was a PASCAL programmer back in the late 1980's!!!  Funny how quickly we get spoiled with IDEs :))

Well, however you score it and award points I'm just hear to help if I can.

It seems to me that the library (.a file) that he made is missing an object file or two.  There's no reason for it to not link parts of the library if they objects do indeed exist in there.

Here is the official GCC documentation.  Some of it is a little obtuse, but it has all the command options.

The output options such as -o are in the "Overall Options" link and you can find the others.

http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Invoking-GCC.html#Invoking-GCC ["GCC Command Options"]

corey