Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Cross platform compilation

Reply
Thread Tools

Cross platform compilation

 
 
saneman
Guest
Posts: n/a
 
      08-01-2008
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?




 
Reply With Quote
 
 
 
 
mlimber
Guest
Posts: n/a
 
      08-01-2008
On Aug 1, 4:37*pm, "saneman" <as...@asd.com> 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
 
Reply With Quote
 
 
 
 
saneman
Guest
Posts: n/a
 
      08-01-2008

"mlimber" <> skrev i en meddelelse
news:224e870e-b402-4fbe-a1c4-...
On Aug 1, 4:37 pm, "saneman" <as...@asd.com> 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>


 
Reply With Quote
 
Rafał
Guest
Posts: n/a
 
      08-02-2008
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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross platform compilation? John Harper Python 2 02-05-2009 01:27 AM
Connecting Win98 platform to WinXP Pro platform dancesportboston Wireless Networking 1 09-02-2006 10:36 PM
does java program run on 64-bit platform as fast as on 32-bit platform jcc Java 15 05-12-2006 08:52 AM
New Windows platform and 64 bit platform =?Utf-8?B?T21hciBLaGFu?= Windows 64bit 12 11-30-2005 11:05 PM
How can I convert the C6.0 program of OS/2 platform TO a program in windows2000/xp platform? Coca C Programming 15 01-14-2004 04:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57