You are here:

C++/linking error


it's me again soor to trouble u again!
i have tried deleting the whole stuff and reinstalling it.
below is the simplest code that i could think off(ie excluding cos,moth,etc.)
it shows the ascii value of the key pressed(as you might have gessed
void main()
  int a;
  while(a!=27)//exit when Esc key pressed
       printf("\nThe key no. is %d\nPress Esc to quit\n",a);
Followup To
Question -
i use a turbo 3.0 editor to write c/c++ programs.
i did not use the compiler for a while.
But now when ever i try to run any file i get an error saying
Linking error:COS.OBJ not found
where as i never used math.h or cos function in the program.
I have checked the directory settings(They are correct).
please help me.
thanking you
Eagerly waiting for your reply
Answer -

What kind of program was this that needed to link to an object file? As far as whats going wrong, I have no clue. Have you tried opening a new solution and either copying and pasting the files into new files, or dropping the old files in the directory of the solution and reincluding them? Howabout a clean solution/rebuild all? Also, the cosine function could be included somewhere in your program you're unaware of via an included file the includeds either math.h or cmath as well. Thats something you might want to look in to.

I hope this information was helpful.

- Eddie

Hello again,

This isn't ANSI standard C++. Your main should return an int(0), and clrscr() as far as I know isn't a C standard library function. Most people use: system("clr") I believe it is.

Another problem is that your while loop is looping an undefined variable the first time, as "a" is not initialized. A quick way to fix this would be to change your loop to a do-while:

int a;
   printf("\nThe key no. is %d\nPress Esc to quit\n",a);

} while(a!=27);

That way by the time it uses a in the printf and in the while loop condition, it has been filled out by getch(). I hope this information helps you figure out your problem.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2017 All rights reserved.

[an error occurred while processing this directive]