Question

I have a TestTime.cpp

/* test-time.cpp */
// Testing time management

#include <iostream>
#include <cmath>
#include "./gpstk/DayTime.hpp"

using namespace std;
using namespace gpstk;

int main()
{
   cout << fixed << setprecision(3);   // Set a proper output format

   DayTime epoch1(2009,10,28,10,30,0.0);

   DayTime epoch2 = epoch1 + 3600.0;

   cout << epoch1 << endl
        << epoch2 << endl;

   cout << epoch1.GPSfullweek() << " "
        << epoch1.DOY()         << " "
        << epoch1.GPSsecond()   << endl;

   return 0;

}

I used g++ TestTime.cpp -o test

I caught error:

/tmp/ccRwny9k.o: In function `main':
TestTime.cpp:(.text+0x206): undefined reference to `gpstk::DayTime::DayTime(short, short, short, short, short, double, gpstk::DayTime::TimeFrame)'
TestTime.cpp:(.text+0x222): undefined reference to `gpstk::DayTime::operator+(double) const'
TestTime.cpp:(.text+0x238): undefined reference to `gpstk::operator<<(std::basic_ostream<char, std::char_traits<char> >&, gpstk::DayTime const&)'
TestTime.cpp:(.text+0x259): undefined reference to `gpstk::operator<<(std::basic_ostream<char, std::char_traits<char> >&, gpstk::DayTime const&)'
TestTime.cpp:(.text+0x282): undefined reference to `gpstk::DayTime::DOY() const'
TestTime.cpp:(.text+0x291): undefined reference to `gpstk::DayTime::GPSfullweek() const'
/tmp/ccRwny9k.o: In function `gpstk::DayTime::GPSsecond() const':
TestTime.cpp:(.text._ZNK5gpstk7DayTime9GPSsecondEv[gpstk::DayTime::GPSsecond() const]+0xd): undefined reference to `gpstk::DayTime::GPSsow() const'
collect2: ld returned 1 exit status

Could you help me???

-- TrinhThiYen - 04 Jan 2010

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

The problem is that when the g++ complier tries to link application, there is no link library specified. You will need to first build the GPSTk and then specify the link library to g++. For example, if you do a
g++ -c TestTime.cpp
you will see that the source compiles correctly into an object (.o) file without error. Thus this is a linking problem.

-- RickMach - 04 Jan 2010 No such template def TMPL:DEF{PROMPT:supportquery}

Topic revision: r2 - 04 Jan 2010, RickMach
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback