Cross platform compilation

Discussion in 'C++' started by saneman, Aug 1, 2008.

  1. saneman

    saneman Guest

    I have some code that compiles fine with g++ (gnu c++ compiler for linux):


    #include <math_types.h>
    int main() {
    //graphics::MyMathTypes::vector3_type v1;
    typedef graphics::MyMathTypes math_types;
    typedef math_types::matrix4x4_type matrix4x4_type;
    typedef math_types::vector3_type vector3_type;
    typedef math_types::real_type real_type;
    matrix4x4_type m1;
    vector3_type v1;
    vector3_type v2;
    Dot(v1, v2);
    return 0;
    }


    But when I try to compile the same code on windows XP with visual studio
    2008 I get:


    1>test.obj : error LNK2019: unresolved external symbol "public: virtual
    __thiscall Matrix<float,4,4>::~Matrix<float,4,4>(void)"
    (??1?$Matrix@M$03$03@@UAE@XZ) referenced in function _main
    1>test.obj : error LNK2019: unresolved external symbol "public: virtual
    __thiscall ColumnVector<float,3>::~ColumnVector<float,3>(void)"
    (??1?$ColumnVector@M$02@@UAE@XZ) referenced in function _main
    1>test.obj : error LNK2019: unresolved external symbol "float __cdecl
    Dot<float,3>(class ColumnVector<float,3> const &,class ColumnVector<float,3>
    const &)" (??$Dot@M$02@@YAMABV?$ColumnVector@M$02@@0@Z) referenced in
    function _main
    1>test.obj : error LNK2019: unresolved external symbol "public: __thiscall
    ColumnVector<float,3>::ColumnVector<float,3>(void)"
    (??0?$ColumnVector@M$02@@QAE@XZ) referenced in function _main
    1>test.obj : error LNK2019: unresolved external symbol "public: __thiscall
    Matrix<float,4,4>::Matrix<float,4,4>(void)" (??0?$Matrix@M$03$03@@QAE@XZ)
    referenced in function _main


    What might be causing these linking errors?
    saneman, Aug 1, 2008
    #1
    1. Advertising

  2. saneman

    mlimber Guest

    On Aug 1, 4:37 pm, "saneman" <> wrote:
    > I have some code that compiles fine with g++ (gnu c++ compiler for linux):
    >
    > #include <math_types.h>
    > int main() {
    >     //graphics::MyMathTypes::vector3_type v1;
    >     typedef graphics::MyMathTypes math_types;
    >     typedef math_types::matrix4x4_type matrix4x4_type;
    >     typedef math_types::vector3_type vector3_type;
    >     typedef math_types::real_type real_type;
    >     matrix4x4_type m1;
    >     vector3_type v1;
    >     vector3_type v2;
    >     Dot(v1, v2);
    >     return 0;
    >
    > }
    >
    > But when I try to compile the same code on windows XP with visual studio
    > 2008 I get:
    >
    > 1>test.obj : error LNK2019: unresolved external symbol "public: virtual
    > __thiscall Matrix<float,4,4>::~Matrix<float,4,4>(void)"
    > (??1?$Matrix@M$03$03@@UAE@XZ) referenced in function _main
    > 1>test.obj : error LNK2019: unresolved external symbol "public: virtual
    > __thiscall ColumnVector<float,3>::~ColumnVector<float,3>(void)"
    > (??1?$ColumnVector@M$02@@UAE@XZ) referenced in function _main
    > 1>test.obj : error LNK2019: unresolved external symbol "float __cdecl
    > Dot<float,3>(class ColumnVector<float,3> const &,class ColumnVector<float,3>
    > const &)" (??$Dot@M$02@@YAMABV?$ColumnVector@M$02@@0@Z) referenced in
    > function _main
    > 1>test.obj : error LNK2019: unresolved external symbol "public: __thiscall
    > ColumnVector<float,3>::ColumnVector<float,3>(void)"
    > (??0?$ColumnVector@M$02@@QAE@XZ) referenced in function _main
    > 1>test.obj : error LNK2019: unresolved external symbol "public: __thiscall
    > Matrix<float,4,4>::Matrix<float,4,4>(void)" (??0?$Matrix@M$03$03@@QAE@XZ)
    > referenced in function _main
    >
    > What might be causing these linking errors?


    Technically this is is off topic since it is related to platform
    specifics (linking is always platform specific), not the C++ language
    proper. If you have further questions, you should direct them to a VC+
    + group or forum. See FAQ 5.9.

    <OT>Have you included math_types.cpp in your project?</OT>

    Cheers! --M
    mlimber, Aug 1, 2008
    #2
    1. Advertising

  3. saneman

    saneman Guest

    "mlimber" <> skrev i en meddelelse
    news:...
    On Aug 1, 4:37 pm, "saneman" <> wrote:
    > I have some code that compiles fine with g++ (gnu c++ compiler for linux):
    >
    > #include <math_types.h>
    > int main() {
    > //graphics::MyMathTypes::vector3_type v1;
    > typedef graphics::MyMathTypes math_types;
    > typedef math_types::matrix4x4_type matrix4x4_type;
    > typedef math_types::vector3_type vector3_type;
    > typedef math_types::real_type real_type;
    > matrix4x4_type m1;
    > vector3_type v1;
    > vector3_type v2;
    > Dot(v1, v2);
    > return 0;
    >
    > }
    >
    > But when I try to compile the same code on windows XP with visual studio
    > 2008 I get:
    >
    > 1>test.obj : error LNK2019: unresolved external symbol "public: virtual
    > __thiscall Matrix<float,4,4>::~Matrix<float,4,4>(void)"
    > (??1?$Matrix@M$03$03@@UAE@XZ) referenced in function _main
    > 1>test.obj : error LNK2019: unresolved external symbol "public: virtual
    > __thiscall ColumnVector<float,3>::~ColumnVector<float,3>(void)"
    > (??1?$ColumnVector@M$02@@UAE@XZ) referenced in function _main
    > 1>test.obj : error LNK2019: unresolved external symbol "float __cdecl
    > Dot<float,3>(class ColumnVector<float,3> const &,class
    > ColumnVector<float,3>
    > const &)" (??$Dot@M$02@@YAMABV?$ColumnVector@M$02@@0@Z) referenced in
    > function _main
    > 1>test.obj : error LNK2019: unresolved external symbol "public: __thiscall
    > ColumnVector<float,3>::ColumnVector<float,3>(void)"
    > (??0?$ColumnVector@M$02@@QAE@XZ) referenced in function _main
    > 1>test.obj : error LNK2019: unresolved external symbol "public: __thiscall
    > Matrix<float,4,4>::Matrix<float,4,4>(void)" (??0?$Matrix@M$03$03@@QAE@XZ)
    > referenced in function _main
    >
    > What might be causing these linking errors?


    Technically this is is off topic since it is related to platform
    specifics (linking is always platform specific), not the C++ language
    proper. If you have further questions, you should direct them to a VC+
    + group or forum. See FAQ 5.9.

    <OT>Have you included math_types.cpp in your project?</OT>



    Ok I will try to find som VS group.

    <OT>Found out that 3 different files/classes contained a function called
    Norm, this seems to be the problem (eventhough its allowed on linux)</OT>
    saneman, Aug 1, 2008
    #3
  4. saneman

    Rafał Guest

    saneman wrote:

    > <OT>Found out that 3 different files/classes contained a function called
    > Norm, this seems to be the problem (eventhough its allowed on linux)</OT>


    There is nothing wrong in having several classes with a method with same
    name.

    Topics like Compilation Units / Translation Units, Include guards etc can be
    helpfull.

    Most probably the code is not correctly separated into .cpp / .hpp
    headers/sources, or some files are not linked.
    Rafał, Aug 2, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jcc
    Replies:
    15
    Views:
    4,696
    Nigel Wade
    May 12, 2006
  2. Ivan
    Replies:
    2
    Views:
    274
    Mark Gordon
    Nov 1, 2003
  3. Coca
    Replies:
    15
    Views:
    639
    Alan Balmer
    Jan 14, 2004
  4. John Harper

    Cross platform compilation?

    John Harper, Feb 3, 2009, in forum: Python
    Replies:
    2
    Views:
    295
    David Boddie
    Feb 5, 2009
  5. Kaspar Schiess

    platform.rb (was: PLATFORM tests)

    Kaspar Schiess, Nov 25, 2005, in forum: Ruby
    Replies:
    0
    Views:
    123
    Kaspar Schiess
    Nov 25, 2005
Loading...

Share This Page