Problem compiling a C++ file in Linux


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Problem compiling a C++ file in Linux

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Location
    Porto - Portugal
    Posts
    42

    Exclamation Problem compiling a C++ file in Linux

    I've used some routines from a already made program to make my own; but I get this error (both with gcc and g++) - the errors are in the "< HERE":

    In file included from SxP4Test.cpp:8:
    stdafx.h:4:9: warning: #pragma once is obsolete
    In file included from SxP4Test.cpp:11:
    cTle.h:10:9: warning: #pragma once is obsolete
    In file included from cTle.h:12,
    from SxP4Test.cpp:11:
    globals.h:4:9: warning: #pragma once is obsolete
    In file included from SxP4Test.cpp:12:
    cEci.h:6:9: warning: #pragma once is obsolete
    In file included from cEci.h:8,
    from SxP4Test.cpp:12:
    cVector.h:6:9: warning: #pragma once is obsolete
    cVector.h:27:3: warning: no newline at end of file
    In file included from cEci.h:9,
    from SxP4Test.cpp:12:
    cJulian.h:6:9: warning: #pragma once is obsolete
    In file included from cEci.h:10,
    from SxP4Test.cpp:12:
    Coord.h:6:9: warning: #pragma once is obsolete
    In file included from SxP4Test.cpp:13:
    cOrbit.h:11:9: warning: #pragma once is obsolete
    In file included from cOrbit.h:15,
    from SxP4Test.cpp:13:
    cNoradBase.h:9:9: warning: #pragma once is obsolete
    In file included from SxP4Test.cpp:14:
    cSite.h:8:9: warning: #pragma once is obsolete
    In file included from cSite.h:10,
    from SxP4Test.cpp:14:
    coord.h:6:9: warning: #pragma once is obsolete
    In file included from cSite.h:10,
    from SxP4Test.cpp:14:
    coord.h:11: error: redefinition of `class cCoordGeo' < HERE
    Coord.h:11: error: previous definition of `class cCoordGeo' < HERE
    coord.h:26: error: redefinition of `class cCoordTopo' < HERE
    Coord.h:26: error: previous definition of `class cCoordTopo' < HERE
    In file included from SxP4Test.cpp:14:
    cSite.h:38:3: warning: no newline at end of file
    coord.h:16: warning: inline function `virtual cCoordGeo::~cCoordGeo()' used but
    never defined
    coord.h:31: warning: inline function `virtual cCoordTopo::~cCoordTopo()' used
    but never defined
    The class cCoordGeo and cCoordTopo at coord.h are like this:

    class cCoordGeo
    {
    public:
    cCoordGeo();
    cCoordGeo(double lat, double lon, double alt) :
    m_Lat(lat), m_Lon(lon), m_Alt(alt) {}
    virtual ~cCoordGeo() {};

    double m_Lat;
    double m_Lon;
    double m_Alt;
    };
    and class cCoordTopo:

    class cCoordTopo
    {
    public:
    cCoordTopo();
    cCoordTopo(double az, double el, double rng, double rate) :
    m_Az(az), m_El(el), m_Range(rng), m_RangeRate(rate) {}
    virtual ~cCoordTopo() {};

    double m_Az;
    double m_El;
    double m_Range;
    double m_RangeRate;
    };
    What's wrong? - I'm not an expert in C++

    This is a little bit urgent ( as always )

    Kind regards,

    Kepler

  2. #2
    Join Date
    Nov 2003
    Posts
    4,118
    These are warnings, so you can still get a runnable .exe from this file.
    There are two problems in the program: your compiler doesn't like the #pragma once directive (which is probably inserted into header files that your project uses). Simply comment this directive out:
    //#pragma once

    The destructors of your classes look weird. They are defined but contain nothing. In addition, there's a redundant ; after the definition which is probably confusing your compiler. If your destructor does nothing, remove it altogether. It's easier to manage your code when it contains fewer vacuous constructs.
    Danny Kalev

  3. #3
    Join Date
    Dec 2003
    Posts
    3,366
    do you have include guards on those .h files ? I suspect that this is the problem or part of it.

  4. #4
    Join Date
    Aug 2007
    Posts
    1
    I had this same problem, but I was in Windows. To give an example I had three files named employee.h, employee.cpp, and driver.cpp

    I put a #includes "employee.h" and #includes "employee.cpp" in the driver.cpp file when all I needed was #includes "employee.h"

Similar Threads

  1. Tab Delimited text file problem
    By nanban4u in forum VB Classic
    Replies: 2
    Last Post: 08-12-2005, 08:49 PM
  2. Replies: 0
    Last Post: 07-21-2003, 02:17 PM
  3. Replies: 0
    Last Post: 09-02-2002, 07:45 AM
  4. Replies: 0
    Last Post: 09-02-2002, 06:11 AM
  5. Re: compiling...problem solved
    By Joar Vatnaland in forum Java
    Replies: 0
    Last Post: 11-14-2000, 11:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center