Posts: 3,279
Threads: 170
Joined: Nov 2003
OK...I'm attempting to write a circle routine in VC++ using the TinyPTC graphics library. The problem is that when I use sqrt, the linker tells me that there's two unresolved external symbols: __fltused and __ftol. This makes zero sense to me, does it make sense to anyone else? And any idea how I can fix it, or is it just another monumental Microsoft messup that has no solution?
I'd knock on wood, but my desk is particle board.
Posts: 1,241
Threads: 107
Joined: Feb 2003
you could always do a:
Pow(Number, .5);
other than that, math.h has always been screwed up. there is nothing anybody can do about it :wink:
the mind is a beautiful thing, use it and make the world a more beautiful place.
Posts: 3,279
Threads: 170
Joined: Nov 2003
Not quite sure how I would go about that...here's what causes the messup:
Code:
yl = (int) sqrt(xr * xr - xl * xl) * yr / xr;
In DJGPP, it works fine.
Oh...and I converted everything back to C, and now there's a third unresolved external symbol: _sqrt.
:evil: :evil: :evil: :evil: :evil: :evil: :evil: :evil: :evil: :evil:
I'd knock on wood, but my desk is particle board.
Posts: 691
Threads: 5
Joined: Apr 2002
Stuff in the math.h header usually requires linking with the math library, not sure what the name of it is for VC++ though.
Unresolved externals are either functions or variables that have been declared extern that cannot be found during linking. For example, the following code will compile:
Code:
#include <stdio.h>
int main(void) {
external_func();
return 0;
}
But when you try to link it, you will get an "Unresolved external: external_func()". The reason you get those underscored names is because they are internal functions to the C libraries (the underscores are used to prevent namespace pollution), for example the sqrt function may exist in the standard C library like this:
Code:
double sqrt(double i) {
return(_sqrt(i));
}
And then the function _sqrt would be defined in the math library.
Are you using an IDE for DJGPP? Its possible that it noticed you were using math functions and automagically linked with the math library for you.
esus saves.... Passes to Moses, shoots, he scores!
Posts: 3,279
Threads: 170
Joined: Nov 2003
Ya, I use RHIDE with DJGPP. It sucks but it sure beats the hell out of emacs.
I'm still relatively new to VC++, so I have no idea how to check to see if the math library is being linked in or not.
Where do I find such information?
I'd knock on wood, but my desk is particle board.
Posts: 3,279
Threads: 170
Joined: Nov 2003
OK got that fixed (VC++ was ignoring default libraries...DUMB!), but now the EXE is crashing whenever I try to use fread or fgetc after using fopen. Wtf? This is dumb.
I'd knock on wood, but my desk is particle board.
Posts: 3,279
Threads: 170
Joined: Nov 2003
OK got that fixed too. But now my BMP routine won't work.
Sheesh...C doesn't like me very much lately.
I'd knock on wood, but my desk is particle board.
Posts: 691
Threads: 5
Joined: Apr 2002
Quote:Ya, I use RHIDE with DJGPP. It sucks but it sure beats the hell out of emacs.
Emacs is brilliant if you know how to use it properly. I still don't get people who use vi though ;-)
Quote:so I have no idea how to check to see if the math library is being linked in or not. Where do I find such information?
Have a look through the build menus in your IDE and see if there is a way to select which libraries you want to link with, alternatively you can use the command line version of the compiler/linker. I haven't used VC++, so I cant really help here.
Quote:Sheesh...C doesn't like me very much lately.
A good debugger nevers goes amiss. I quite like gdb, but there are plenty of other good ones available. A lot of crashes in C programs are caused by dynamic memory allocation errors or stray pointers, debuggers are good for hunting down both.
esus saves.... Passes to Moses, shoots, he scores!
Posts: 3,279
Threads: 170
Joined: Nov 2003
I guess I'm just spoiled by menu/dialog driven editors.
The problem with math.h is that VC++ has this UBER STUPID default setting to ignore all default libraries. Unchecking that option allowed the math library to be linked in. And the other problem I was having was due to C's string mess...damned double backslashes.
Someone on efnet #c suggsted I use forward slashes instead to escape the backslash nightmare, so that's what I'm doing now.
This is such a friggin touchy language...no wonder BASIC is so popular.
I'd knock on wood, but my desk is particle board.
Posts: 294
Threads: 9
Joined: Oct 2002
Heh.
Nek did your avatar change lately? It makes your teath look bigger.