Thread: g++ - .NET incompatibility??

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    g++ - .NET incompatibility??

    It compiles in .NET; g++ gives me this
    > g++ prog1.cpp
    Undefined first referenced
    symbol in file
    PCB::~PCB [in-charge]() /var/tmp//ccDyM5iy.o
    operator>>(std::basic_istream<char, std::char_traits<char> >&, PCB&)/var/tmp//cc
    DyM5iy.o
    operator<<(std::basic_ostream<char, std::char_traits<char> >&, PCB const&)/var/t
    mp//ccDyM5iy.o
    PCB::getStateStatus() const /var/tmp//ccDyM5iy.o
    PCB::operator>(PCB const&) const /var/tmp//ccDyM5iy.o
    PCB::PCB[in-charge](int, int, int, int, int, int, void const*)/var/tmp//ccDyM5iy
    .o
    ld: fatal: Symbol referencing errors. No output written to a.out
    collect2: ld returned 1 exit status
    titan/jsigar >
    The following is a little bit of everything
    Code:
    PCB::~PCB() 
    {
      // this section is intentionally left blank
    }
    ...
    std::ostream &operator<<(std::ostream &stream, const PCB &pcb)
    {
      stream << pcb.pid << " ";
      stream << pcb.arrival_time << " ";
      stream << pcb.last_cpu_burst << " ";
      stream << pcb.test_cpu_burst << " ";
      stream << pcb.priority << " ";
      stream << pcb.state_status << " ";
      if (pcb.hook != NULL) {
        stream << reinterpret_cast<const char *>(pcb.hook);
      }
    
      return stream;
    }
    ...
    int PCB::getStateStatus() const
    {
      return state_status;
    }
    ...
    bool PCB::operator>(const PCB &anotherPCB) const
    {
      return (priority > anotherPCB.priority);
    }
    Note that I'm so illiterate in UNIX so will need clear answer. Thnx!
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Did you compile all the files, or is everything in prog1.cpp?

    Eg.
    g++ prog1.cpp pcb.cpp

    The error messages are basically telling you that it can't find the symbols necessary to complete the executable file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    g++ prog1.cpp pcb.cpp
    Ohh, that's how you do it. I did "g++ prog1.cpp" only and I though it will compile evertyhing that's l inked to "prog1.cpp". Thnx, it works now.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    When you have a few more files, you will want to investigate using makefiles, which are the equivalent of VC++ project files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. migrate from .Net 2.0 to .Net 3.0
    By George2 in forum C# Programming
    Replies: 3
    Last Post: 07-25-2007, 04:07 AM
  2. Some .NET Distribution Stats
    By nickname_changed in forum C# Programming
    Replies: 2
    Last Post: 05-14-2005, 03:41 AM
  3. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM
  4. .net
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 02-15-2002, 01:15 AM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM