Trunk MSVC projects

Discuss any Chipmunk bugs here.

Trunk MSVC projects

Postby debug » Mon Nov 24, 2008 8:23 pm

No longer compile kaaboom!

Code: Select all
Compiling...
cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
Demo1.c
c1xx : fatal error C1083: Cannot open source file: '..\..\Demo\Demo1.c': No such file or directory
Demo2.c
c1xx : fatal error C1083: Cannot open source file: '..\..\Demo\Demo2.c': No such file or directory
Demo3.c
c1xx : fatal error C1083: Cannot open source file: '..\..\Demo\Demo3.c': No such file or directory
Demo4.c
c1xx : fatal error C1083: Cannot open source file: '..\..\Demo\Demo4.c': No such file or directory
Demo5.c
c1xx : fatal error C1083: Cannot open source file: '..\..\Demo\Demo5.c': No such file or directory
Demo6.c
c1xx : fatal error C1083: Cannot open source file: '..\..\Demo\Demo6.c': No such file or directory
Demo7.c
c1xx : fatal error C1083: Cannot open source file: '..\..\Demo\Demo7.c': No such file or directory
main.c
c1xx : fatal error C1083: Cannot open source file: '..\..\Demo\main.c': No such file or directory
Generating Code...


Replacing all those files with the ones now found in Demo results in

Code: Select all
Linking...
LogoSmash.obj : error LNK2005: "struct cpSpace * space" (?space@@3PAUcpSpace@@A) already defined in Bounce.obj
MagnetsElectric.obj : error LNK2005: "struct cpSpace * space" (?space@@3PAUcpSpace@@A) already defined in Bounce.obj
MagnetsElectric.obj : error LNK2005: "struct cpBody * staticBody" (?staticBody@@3PAUcpBody@@A) already defined in Bounce.obj
Planet.obj : error LNK2005: "struct cpSpace * space" (?space@@3PAUcpSpace@@A) already defined in Bounce.obj
Planet.obj : error LNK2005: "struct cpBody * staticBody" (?staticBody@@3PAUcpBody@@A) already defined in Bounce.obj
PyramidStack.obj : error LNK2005: "struct cpSpace * space" (?space@@3PAUcpSpace@@A) already defined in Bounce.obj
PyramidStack.obj : error LNK2005: "struct cpBody * staticBody" (?staticBody@@3PAUcpBody@@A) already defined in Bounce.obj
PyramidTopple.obj : error LNK2005: "struct cpSpace * space" (?space@@3PAUcpSpace@@A) already defined in Bounce.obj
PyramidTopple.obj : error LNK2005: "struct cpBody * staticBody" (?staticBody@@3PAUcpBody@@A) already defined in Bounce.obj
Test.obj : error LNK2005: "struct cpSpace * space" (?space@@3PAUcpSpace@@A) already defined in Bounce.obj
Test.obj : error LNK2005: "struct cpBody * staticBody" (?staticBody@@3PAUcpBody@@A) already defined in Bounce.obj
TheoJansen.obj : error LNK2005: "struct cpSpace * space" (?space@@3PAUcpSpace@@A) already defined in Bounce.obj
TheoJansen.obj : error LNK2005: "struct cpConstraint * motor" (?motor@@3PAUcpConstraint@@A) already defined in Pump.obj
TheoJansen.obj : error LNK2005: "struct cpBody * staticBody" (?staticBody@@3PAUcpBody@@A) already defined in Bounce.obj
WalkBot.obj : error LNK2005: "struct cpSpace * space" (?space@@3PAUcpSpace@@A) already defined in Bounce.obj
WalkBot.obj : error LNK2005: "struct cpConstraint * motor" (?motor@@3PAUcpConstraint@@A) already defined in Pump.obj
WalkBot.obj : error LNK2005: "struct cpBody * staticBody" (?staticBody@@3PAUcpBody@@A) already defined in Bounce.obj
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo MagnetsElectric" (?MagnetsElectric@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo TheoJansen" (?TheoJansen@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo WalkBot" (?WalkBot@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo Pump" (?Pump@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo Springies" (?Springies@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo Planet" (?Planet@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo Bounce" (?Bounce@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo PyramidTopple" (?PyramidTopple@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo Tumble" (?Tumble@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo Plink" (?Plink@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo PyramidStack" (?PyramidStack@@3UchipmunkDemo@@A)
ChipmunkDemo.obj : error LNK2001: unresolved external symbol "struct chipmunkDemo LogoSmash" (?LogoSmash@@3UchipmunkDemo@@A)
F:\My Libraries\chipmunk-physics\MSVCSolution\\bin\Chipmunk4MSVC2k3.exe : fatal error LNK1120: 12 unresolved externals


Adding externs to all demos that have space, staticbody and motor and adding a motor to chipmunk demo fixes all but the unresolveds

demos
Code: Select all
extern cpSpace *space;
extern cpBody *staticBody;
extern cpConstraint *motor;


chipmunkdemo
Code: Select all
cpSpace *space;
cpBody *staticBody;
cpConstraint *motor;


removing the CONST from the structs ( ANSI C specifies the qualifiers must match between extern and static ) in the .c files fixes the rest

Code: Select all
chipmunkDemo Bounce = {
   "Bounce",
   NULL,
   init,
   update,
   destroy,
};
debug
 
Posts: 19
Joined: Sun Nov 23, 2008 4:42 pm

Re: Trunk MSVC projects

Postby debug » Tue Nov 25, 2008 10:29 am

Would you like some MSVC 2008 SP1 project files and a patch for those changes?
debug
 
Posts: 19
Joined: Sun Nov 23, 2008 4:42 pm

Re: Trunk MSVC projects

Postby ippa » Sun Jun 21, 2009 8:49 pm

bump. I ran into something like this too when trying to compile trunk.
http://rubylicio.us/ - tasty links for the ruby connoisseur.
ippa
 
Posts: 14
Joined: Mon Aug 25, 2008 4:53 am

Re: Trunk MSVC projects

Postby mcneja » Sat Jul 17, 2010 6:35 pm

I ran into this as well; I haven't completely sorted things out. Here are some of the things I did work out:

As far as I can tell, MSVC doesn't have the __typeof__ operator used in chipmunk_ffi.h. It does have "decltype" which I think works the same way, but it was only introduced with VC10. I did this:

Code: Select all
#if _MSC_VER >= 1600
#define MAKE_REF(name) decltype(name) *_##name = name
#else
#define MAKE_REF(name) __typeof__(name) *_##name = name
#endif


It looks like decltype will be standard in the next version of C++. I don't know if it'll be added to C as well.

I believe the trunk version of Chipmunk includes a static body in every space; you use it by passing a NULL body pointer. So all the examples with their own staticBody can probably remove that. For the space, motor, etc. variables that are colliding, I put static qualifiers on them since each example file creates its own space.

I've been compiling the code as C++ because it uses features that my C compiler doesn't recognize, like declaring variables inline (instead of at the top of each block as in traditional C). For the most part it works. I'm not sure whether this is due to compiling as C++, or if it is true in C99 as well, but declaring a const variable (such as all the chipmunkDemo objects) implies module scope, so none of the chipmunkDemo objects can be linked to ChipmunkDemo.c. Adding the "extern" keyword to their definitions fixes this. However, the differing const-ness of the defined objects and the declarations in ChipmunkDemo.c also keeps things from linking, so I've threaded const-ness through ChipmunkDemo.c as well.

My MSVC compiler balks at attempts to implicitly cast from void* to another pointer type, so I've had to add explicit casts in a few places:

cpSpace.c:58:
Code: Select all
return cpArbiterInit((cpArbiter *) cpArrayPop(space->pooledArbiters), shapes[0], shapes[1]);

cpSpace.c:283:
Code: Select all
cpCollisionHandler *old_handler = (cpCollisionHandler *) cpHashSetRemove(space->collFuncSet, CP_HASH_PAIR(a, b), &ids);

cpSpace.c:885:
Code: Select all
cpArbiter *arb = (cpArbiter *) arbiters->arr[i];

cpSpaceHash.c:86:
Code: Select all
cpHandle *hand = cpHandleInit((cpHandle *) cpArrayPop(hash->pooledHandles), obj);
mcneja
 
Posts: 4
Joined: Mon Feb 01, 2010 1:56 pm


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron