Qbasicnews.com
November 27, 2021, 05:45:45 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: VC++ math.h screwup?  (Read 4881 times)
adosorken
*/-\*
*****
Posts: 3655



WWW
« on: June 15, 2004, 12:27:09 PM »

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?
Logged

I'd knock on wood, but my desk is particle board.
Mech1031
Na_th_an
*****
Posts: 1536



WWW
« Reply #1 on: June 15, 2004, 04:22:50 PM »

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:
Logged

the mind is a beautiful thing, use it and make the world a more beautiful place.
adosorken
*/-\*
*****
Posts: 3655



WWW
« Reply #2 on: June 15, 2004, 04:52:58 PM »

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. Cheesy

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:
Logged

I'd knock on wood, but my desk is particle board.
LooseCaboose
I hold this place together
*****
Posts: 981



« Reply #3 on: June 15, 2004, 09:13:15 PM »

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.
Logged

esus saves.... Passes to Moses, shoots, he scores!
adosorken
*/-\*
*****
Posts: 3655



WWW
« Reply #4 on: June 15, 2004, 10:07:41 PM »

Ya, I use RHIDE with DJGPP. It sucks but it sure beats the hell out of emacs. Cheesy

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. Sad Where do I find such information?
Logged

I'd knock on wood, but my desk is particle board.
adosorken
*/-\*
*****
Posts: 3655



WWW
« Reply #5 on: June 15, 2004, 11:55:18 PM »

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. Sad
Logged

I'd knock on wood, but my desk is particle board.
adosorken
*/-\*
*****
Posts: 3655



WWW
« Reply #6 on: June 16, 2004, 12:40:13 AM »

OK got that fixed too. But now my BMP routine won't work. Sad Sheesh...C doesn't like me very much lately.
Logged

I'd knock on wood, but my desk is particle board.
LooseCaboose
I hold this place together
*****
Posts: 981



« Reply #7 on: June 16, 2004, 06:26:34 AM »

Quote from: "adosorken"

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 from: "adosorken"

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 from: "adosorken"

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.
Logged

esus saves.... Passes to Moses, shoots, he scores!
adosorken
*/-\*
*****
Posts: 3655



WWW
« Reply #8 on: June 16, 2004, 07:42:24 PM »

I guess I'm just spoiled by menu/dialog driven editors. Cheesy

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. Sad Someone on efnet #c suggsted I use forward slashes instead to escape the backslash nightmare, so that's what I'm doing now. Cheesy This is such a friggin touchy language...no wonder BASIC is so popular. Cheesy
Logged

I'd knock on wood, but my desk is particle board.
Nexinarus
Wandering Guru
***
Posts: 301



WWW
« Reply #9 on: June 17, 2004, 05:12:27 AM »

Heh.

Nek did your avatar change lately? It makes your teath look bigger.
Logged
adosorken
*/-\*
*****
Posts: 3655



WWW
« Reply #10 on: June 17, 2004, 07:57:49 AM »

I also grew horns. Cheesy

ok this is kinda funny...near the end of windows.h, there's this:
Code:
/* Leave 4514 disabled. It's a stupid warning anyways. */

 :Huh:  :Huh:  :Huh:  :Huh:  :lol:  :lol:  :lol:  :lol:  :rotfl:  :rotfl:  :rotfl:  :rotfl:
Logged

I'd knock on wood, but my desk is particle board.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!