LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-24-2006, 05:32 AM   #1
rigel_kent
Member
 
Registered: Nov 2004
Posts: 64

Rep: Reputation: 15
Problem compiling C++ file to 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":

Quote:
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:

Quote:
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:

Quote:
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,

Rigel_Kent
 
Old 04-24-2006, 05:41 AM   #2
Vagrant
Member
 
Registered: Nov 2001
Posts: 75

Rep: Reputation: 15
This looks like code from a Visual C++ program, with the "stdafx.h." Pragma's are not usually going to work between different compilers, you can turn the warnings off though. Could you post the top of these header files? To me, it looks like your #define's are not setup properly, but I suspect there may be more problems.

As for this problem:

"coord.h:16: warning: inline function `virtual cCoordGeo::~cCoordGeo()' used but
never defined"

This is a warning, but I believe the line in the header should be as:

virtual cCoordGeo::~cCoordGeo()=0;

Granted, this is just a cursory inspection.

-- by the way, the question about using "gcc" or "g++," well ... Actually, they are the same. It depends on the extention of the file. If you do "g++ foo.c" it has the same effect as "gcc foo.c," that is running the C compiler. While running "gcc foo.cpp" will run the C++ compiler just as "g++ foo.cpp" does. Oh, but of course, the C compiler won't know what to make of all that "class" business. =)

Last edited by Vagrant; 04-24-2006 at 05:43 AM.
 
Old 04-24-2006, 05:57 AM   #3
rigel_kent
Member
 
Registered: Nov 2004
Posts: 64

Original Poster
Rep: Reputation: 15
Hi,

The coord.h is like this:

Quote:
// coord.h
#pragma once

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;
};

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;

};
and coord.cpp is like this:

Quote:
// coord.cpp
//
#include "stdafx.h"
#include "coord.h"
#include "globals.h"

//////////////////////////////////////////////////////////////////////
// cCoordGeo Class
//////////////////////////////////////////////////////////////////////

cCoordGeo::cCoordGeo()
{
m_Lat = 0.0;
m_Lon = 0.0;
m_Alt = 0.0;
}

//////////////////////////////////////////////////////////////////////
// cCoordTopo Class
//////////////////////////////////////////////////////////////////////

cCoordTopo::cCoordTopo()
{
m_Az = 0.0;
m_El = 0.0;
m_Range = 0.0;
m_RangeRate = 0.0;

}
Kind regards,

Rigel_Kent
 
Old 04-24-2006, 06:17 AM   #4
Vagrant
Member
 
Registered: Nov 2001
Posts: 75

Rep: Reputation: 15
Well, its a bit early for me but try that file with this code instead. Don't use that pragma business.

Code:
#ifndef CCOORDGEO_H
#define CCOORDGEO_H
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; 
};
#endif

#ifndef CCOORDTOPO_H
#define CCOORDTOPO_H
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; 

};
#endif
 
Old 04-25-2006, 07:40 AM   #5
Marius2
Member
 
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 276

Rep: Reputation: 31
You may also want to change this

// coord.cpp
//
#include "stdafx.h"

into

#ifdef _WIN32
#include "stdafx.h"
#endif

(under linux, it's #ifdef __linux__)

Mind that a #include <windows.h> instead of "stdafx.h"
might do the same job for you, without the tons of headers
included by stdafx.h, which a simple console program
very likely does not need (you may have to set Project->
Settings->C/C++/Precompiled headers to "automatically use
precompiled headers")
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling many .c files in to one .o file kskkumar Linux - General 2 12-29-2005 08:51 AM
kernel compiling problem: can I use 2.4 .config file with 2.6 ? Xavius Slackware 15 01-07-2005 02:51 PM
Linux kernel compiling problem mmm Linux - General 4 08-07-2004 04:57 PM
Problem compiling util-linux buboleck Slackware 0 12-21-2003 06:41 AM
can some help with compiling .c file rameshks Linux - Networking 1 05-15-2001 01:30 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration