error LNK2019: unresolved external symbol

This is a discussion on error LNK2019: unresolved external symbol within the C++ Programming forums, part of the General Programming Boards category; When I try to compile my code in VC++ I get the following 2 errors: scheduling error LNK2019: unresolved external ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Location
    Canada
    Posts
    80

    error LNK2019: unresolved external symbol

    When I try to compile my code in VC++ I get the following 2 errors:
    scheduling error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
    scheduling fatal error LNK1120: 1 unresolved externals
    Any ideas what these mean? I have looked on the 'net but nothing meaningful (everyone's talking about DLL files).

    FYI, here's the source code:
    Code:
    #include <iostream>
    #include <stdarg.h>
    #include "scheduling.h"
    #define MAXSIZE 100
    
    using namespace std;
    
    typedef unsigned char boolean;
    
    // default constructor for head of list
    process_list::process_list() {
      m_curr = this;
      m_prev = NULL;
      m_next = NULL;
    }
    
    //constructor for extra nodes
    process_list::process_list(process_list* prev) 
    {
      m_prev = prev;
      m_next = NULL;
    }
    
    //inserts a new process with data given
    void process_list::insert(int temp_pid, int temp_tarq, int temp_prio, int temp_tncpu, int temp_cpu_burst[], int temp_IO_burst[]) 
    {
      while (m_curr->get_next() != NULL)
        m_curr = m_curr->get_next();
      m_curr->set_data(temp_pid, temp_tarq, temp_prio, temp_tncpu, temp_cpu_burst, temp_IO_burst);
      m_curr->set_next(new process_list(m_curr));
    }
    
    
    //Fetch PID functions
    int process_list::get_pidE1() 
    {
      return pid;
    }
    
    int process_list::get_pid() 
    {
      return m_curr->get_pidE1();
    }
    
    
    //Fetch tarq functions
    int process_list::get_tarqE1() 
    {
      return tarq;
    }
    int process_list::get_tarq() 
    {
      return m_curr->get_tarqE1();
    }
    
    
    //Fetch Prio functions
    int process_list::get_prioE1() 
    {
      return prio;
    }
    int process_list::get_prio() 
    {
      return m_curr->get_prioE1();
    }
    
    
    //Fetch tncpu functions
    int process_list::get_tncpuE1() 
    {
      return tncpu;
    }
    int process_list::get_tncpu() 
    {
      return m_curr->get_tncpuE1();
    }
    
    
    //Fetch cpu_burst functions
    int process_list::get_cpu_burstE1(int cpu_num) 
    {
      return cpu_burst[cpu_num];
    }
    int process_list::get_cpu_burst(int cpu_num) 
    {
      return m_curr->get_cpu_burstE1(cpu_num);
    }
    
    
    //Fetch IO_burst_lenth functions
    int process_list::get_IO_burstE1(int IO_num)
    {
      return IO_burst[IO_num];
    }
    int process_list::get_IO_burst(int IO_num)
    {
      return m_curr->get_IO_burstE1(IO_num);
    }
    
    
    // set process information function
    void process_list::set_data(int temp_pid, int temp_tarq, int temp_prio, int temp_tncpu, int temp_cpu_burst[], int temp_IO_burst[]) 
    {
        pid = temp_pid;		
    	tarq = temp_tarq;	
    	prio = temp_prio;	
    	tncpu = temp_tncpu;	
    	cpu_burst[MAXSIZE] = temp_cpu_burst[MAXSIZE];
    	IO_burst[MAXSIZE-1] = temp_IO_burst[MAXSIZE-1];
    }
    
    //returns a pointer to the previous process
    process_list* process_list::get_prev() 
    {
      return m_prev;
    }
    
    //returns a pointer to the next process
    process_list* process_list::get_next() 
    {
      return m_next;
    }
    
    
    //add a new process to the list
    void process_list::set_next(process_list* process) 
    {
      m_next = process;
    }
    
    
    //sets m_curr pointer back to the start of the list
    void process_list::reset()
     {
      m_curr = this;
    }
    
    //moves m_curr to the next process in the list
    void process_list::next() 
    {
      m_curr = m_curr->get_next();
    }
    
    //moved m_curr to the previous process in the list
    void process_list::prev() 
    {
      m_curr = m_curr->get_prev();
    }
    
    //check for end
    boolean process_list::is_end() 
    {
      return m_curr->get_next() == NULL ? 1 : 0;
    }
    
    //check for biginning
    boolean process_list::is_beginning() 
    {
      return m_curr == NULL ? 1 : 0;
    }
    
    //check if any entries have been added to the list
    boolean process_list::is_empty() 
    {
      return m_curr->get_next() == m_curr->get_prev() ? 1 : 0;
    }
    And here's the header file:
    Code:
    //process list header file
    //this is the interface of processlist
    #include <iostream>
    #define MAXSIZE 100
    
    using namespace std;
    
    typedef unsigned char boolean;
    
    class process_list {
      
      private:
        process_list *m_curr, *m_next, *m_prev;
        int pid;		//PID = process ID code,
    	int	tarq;		//TARQ = time of arrival into the ready queue (the first time, right when it was created only!),
    	int prio;		//PRIO = priority code,
    	int tncpu;		//TNCPU = total number of cpu bursts of the process
    	int cpu_burst[MAXSIZE];
    	int IO_burst[MAXSIZE-1];
    
    
      public:    
        /*Constructors*/
        process_list();
    	process_list(process_list* prev);
        
        /*Operations*/
        void insert(int temp_pid, int temp_tarq, int temp_prio, int temp_tncpu, int temp_cpu_burst[], int temp_IO_burst[]);  
    
        /*data setting*/
        int get_pid();
        int get_tarq();
    	int get_prio();
    	int get_tncpu();
    	int get_cpu_burst(int cpu_num);
    	int get_IO_burst(int IO_num);
    	int get_pidE1();
        int get_tarqE1();
    	int get_prioE1();
    	int get_tncpuE1();
    	int get_cpu_burstE1(int cpu_num);
    	int get_IO_burstE1(int IO_num);
        void set_data(int temp_pid, int temp_tarq, int temp_prio, int temp_tncpu, int temp_cpu_burst[], int temp_IO_burst[]);
        process_list* get_prev();
        process_list* get_next();
        void set_next(process_list* );        
        
        /*Movement*/
        void reset();
        void prev();
        void next();
        void end();           
        
        /*Boolean*/
        boolean is_beginning();
        boolean is_end();
        boolean is_empty();
        
    };

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    >scheduling error LNK2019: unresolved external symbol _main referenced in function >_mainCRTStartup
    >scheduling fatal error LNK1120: 1 unresolved externals

    The linker is looking for the main function, I scanned both of the above and there is no sign oif a function called int main(). You must include a main function into a C++ program / project to make it run, it is the first function looked for and called by the compiler.
    I'm just trying to be a better person - My Name Is Earl

  3. #3
    Registered User
    Join Date
    Nov 2005
    Location
    Canada
    Posts
    80
    Oh gee, really? I thought it'd compile even without a main()! How I get stuck by simple things... Thanks very much swgh.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    It did compile. It just did not link. There are two steps to the process, compiling each source file and then linking them all together to form a program.

    In VC++, Ctrl-F7 will compile a file, or you can right-click on the source file in the workspace tree and select compile. Then when you are ready to write a main you can use F7 to build the whole application.

    Or you can just write an empty main or a main function that does simple tests of your code until you are ready to write the real one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21