Strange Newton Error

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
I started trying to learn Newton but ran into a problem fairly quickly. When compiling I get this:

Code:
HeightFieldCollision.cpp:415: error: `assert' undeclared (first use this function)  (Each undeclared identifier is reported only once for each function it appears in.)


Any ideas? I looked at the code and that line is this:
Code:
(HeightFieldCollision.cpp)
_ASSERTE (det > 0.0f);


I assumed _ASSERTE was a macro and looked for it and found this:
Code:
(stdafx.h)
#ifdef _MSC_VER
    #pragma warning (disable: 4100) //unreferenced formal parameter
    #pragma warning (disable: 4505) //unreferenced local function has been removed
    #pragma warning (disable: 4201) //nonstandard extension used : nameless struct/union
    #pragma warning (disable: 4127) //conditional expression is constant


#else
    #define _ASSERTE(x) assert(x)
    #ifndef min
        #define min(a,b) (a < b ? a : b)
        #define max(a,b) (a > b ? a : b)
    #endif
    
    #ifndef asinf
        #define asinf(x) ((dFloat32) asin(x))
        #define acosf(x) ((dFloat32) acos(x))
    #endif
#endif


My problem is that all of this is the code Newton provided. Is there something I need to do to fix this? Any help is appreciated.
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #2
Try adding "#include <assert.h>" to the affected files.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
I tried adding it to HeightFieldCollision.h, HeighFieldCollision.cpp, and stdafx.h (where the last of the code I posted was found) and each time I got 868 errors and 200-and-something warnings.
Thanks for the try. Any other advice?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
neil is correct, you need to include assert.h. Who knows whether the other errors are related. I assume this is someone else's code; I'd suggest starting with one of Will Thimbleby's examples which are Mac-centric. You should find a link by searching the forums.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #5
The problem is that he doesn't use all the Newton files. He doesn't have the stdafx.h or a bunch of the others, including the one giving me trouble. I'm sure that the other errors are related because they are mostly syntax errors on lines without syntax errors and only show up if I include assert.h. Does anyone know how to fix this problem?
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #6
On reflection, you should probably include <assert.h> in your pch (precompiled header) so that it gets included everywhere, instead of hacking at the other source files.

If you're encountering other errors, it would help if you told us what the errors are, and gave further snippets of code from the trouble spots.

It's unlikely to be the case that adding assert.h makes new errors appear; more likely those errors are concealed until you fix the initial problem. Also, as you rightly observe, most of the errors are probably a consequence of the first few errors, so you should look at those first.

EDIT: Wait, did you #define _NEWTON_USE_LIB ? Do this in your pch. If you don't, it'll all fail spectacularly.
EDIT 2: Hmm, stdafx.h defines this itself if you don't have _MSC_VER defined, so maybe you don't want to do that. However, perhaps stdafx.h isn't getting included in places where it should be, so you might not be getting _NEWTON_USE_LIB everywhere. Just something to investigate....

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #7
I don't see a pch anywhere. Do I manually create this? How do I go about creating it?

I'll try some things once I get the pch thing figured out.
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #8
Nick Wrote:I don't see a pch anywhere. Do I manually create this? How do I go about creating it?
Your project doesn't already have one? If you create your project using one of Xcode's template's you should get one automatically.

If not, simply create a header with .pch as its extension and type its name into the Prefix Header slot in the target build settings. Feel free to include in this header any other standard headers that you might need. Also enable Precompile Prefix Header to get the benefit of extra compilation speed.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
what do you mean "he doesn't use all the newton files" -- there's only one, Newton.h, and he definitely uses that Rasp
Quote this message in a reply
Member
Posts: 78
Joined: 2002.06
Post: #10
Off the top of my head the two things that might catch you out are:
1. You need to define _NEWTON_USE_LIB before including Newton.h
2. You need to include libstdc++.a in the project

also it is probably more trouble than it is worth starting with an empty project. And as mentioned earlier, my examples are here: http://will.thimbleby.net/physics/
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #11
I'm back and trying to get Newton to work. Right now I have absolutely no Newton files in my project. It's a simple SDL/OpenGL app (I used the template). I've built on it and have static meshes and a simple terrain engine. I would like to now add Newton to the mix so that my terrain actually acts like a solid object. Can someone give me a quick step by step of how to do this without getting a million errors? I already downloaded and unzipped the latest Newton files from their site. In fact I've been playing Jenga for a while now. I just want to add Newton to my project. I tried a couple of things today and still can't get it to build without errors (and I'm not even trying to use it Smile).

If needed, I can put a copy of the project online later but I didn't see it as necessary now. Let me know. Thanks for all the help.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #12
add Newton.h from the SDKs folder to your project
add libnewton32.a from the SDKs folder to your project
add -D_NEWTON_USE_LIB to your target's "other c flags"
using a terminal, ranlib libnewton32.a
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #13
out of intrest, what does ranlib do?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #14
updates the table of contents and modification date of the static library.

due to somebody's complete stupidity, Mac OS X static libraries contain their own modification date and the linker refuses to use them if the date according to the library is substantially different to the date according to the file system, as it will be if the file has been copied.
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #15
Why doesn't someone hack the linker to automatically run ranlib? Wink (only half-joking)

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  'Unidentified error' error in Xcode scgames 2 3,596 Jun 10, 2006 01:38 AM
Last Post: scgames
  [ANN] Multithreaded Newton demo OneSadCookie 16 8,087 May 12, 2005 10:52 PM
Last Post: AnotherJake
  Squirrel Physics Kit vs. Newton blobbo 3 4,157 Apr 22, 2005 06:22 AM
Last Post: blobbo
  strange application error honkFactory 1 2,354 Apr 10, 2005 07:53 PM
Last Post: wadesworld
  Newton weirdness IBethune 3 3,694 Mar 25, 2005 06:24 AM
Last Post: IBethune