Menu

Getting errors while building Linux

Anonymous
2021-05-27
2021-05-27
  • Anonymous

    Anonymous - 2021-05-27

    I followed the steps of installing with cmake. Here is what I did steps by steps

    tar xfpz GeographicLib-1.51.tar.gz
    cd GeographicLib-1.51
    mkdir BUILD
     cd BUILD
     cmake ..
     make
     make test
     make install
    

    The library is installed at usr/local/include, lib and bin

    The issue arrises when I try to build the example

    g++ -o example-Geodesic example-Geodesic.cpp

    The error message I get

    /tmp/cc6F2Etx.o: In function `main':
    example-Geodesic.cpp:(.text+0x40): undefined reference to `GeographicLib::Geodesic::Geodesic(double, double)'
    /tmp/cc6F2Etx.o: In function `GeographicLib::Geodesic::Direct(double, double, double, double, double&, double&) const':
    example-Geodesic.cpp:(.text._ZNK13GeographicLib8Geodesic6DirectEddddRdS1_[_ZNK13GeographicLib8Geodesic6DirectEddddRdS1_]+0xa3): undefined reference to `GeographicLib::Geodesic::GenDirect(double, double, double, bool, double, unsigned int, double&, double&, double&, double&, double&, double&, double&, double&) const'
    /tmp/cc6F2Etx.o: In function `GeographicLib::Geodesic::Inverse(double, double, double, double, double&) const':
    example-Geodesic.cpp:(.text._ZNK13GeographicLib8Geodesic7InverseEddddRd[_ZNK13GeographicLib8Geodesic7InverseEddddRd]+0x8b): undefined reference to `GeographicLib::Geodesic::GenInverse(double, double, double, double, unsigned int, double&, double&, double&, double&, double&, double&, double&) const'
    collect2: error: ld returned 1 exit status
    

    Specifying linker did not solve the problem

    g++ -o example-Geodesic -l Geographic example-Geodesic.cppclear

    There wasn't any issues with make and all the test passed.

    Please let me know what step I am missing.

    Thanks

     
  • Charles Karney

    Charles Karney - 2021-05-27

    The documentation page https://geographiclib.sourceforge.io/html/start.html says that if you build GeographicLib as a shared library (which you did), then you have to specify the location of shared libraries at runtime with, for example,

    g++ -o prog prog.cpp -lGeographic -Wl,-rpath=/usr/local/lib
    

    (You can also build these programs using make exampleprograms in the cmake build directory.)

     
  • Anonymous

    Anonymous - 2021-05-27

    Thank you.

     

Anonymous
Anonymous

Add attachments
Cancel