I have codewarrior 3.1 for win98. I wrote a sample library just to see if I could make a .lib file before I started my project.... It doesn''t work. I chose the linker to be lib, and the output file to be .lib. I then wrote a simple function called hello() that prints hello world on the screen. To compile this, I needed to include iostream.h. This all worked fine. I then made a new project, added my test.lib file to it, and in the main() declaration I added the line hello(); The compiler says it is an undeclared something or other. I have used many libraries before (such as winsock) and they all work fine. The codewarrior documentation says I am doing everything right... I really need to be able to make a library file for my new project. If you have any thoughts or know what I am doing wrong, please help!
--------------------
You are not a real programmer until you end all your sentences with semicolons;
Making Library Files
--------------------
You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
You haven't declared the function. When you used the Winsock library you included a header file (.h) didn't you? You need to do the same thing with your own lib (make a header file with the function prototype and then include it in your .cpp file).
Example:
// my_lib.h
#ifndef __MY_LIB_H_
void hello(void);
#endif
// source_file.cpp
#include "my_lib.h"
main()
{
hello();
}
And when you add more functions to your lib you just add the prototype to the my_lib.h file.
/. Muzzafarath
Edited by - Muzzafarath on 3/31/00 8:34:27 AM
Example:
// my_lib.h
#ifndef __MY_LIB_H_
void hello(void);
#endif
// source_file.cpp
#include "my_lib.h"
main()
{
hello();
}
And when you add more functions to your lib you just add the prototype to the my_lib.h file.
/. Muzzafarath
Edited by - Muzzafarath on 3/31/00 8:34:27 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Actually, I tried that too. That just gave me the error illegal function definition or something like that. I also tried it with a class and got similar results. I have played with the link order too. Makes no difference what I do... there must be something basic I am doing wrong.
--------------------
You are not a real programmer until you end all your sentences with semicolons;
--------------------
You are not a real programmer until you end all your sentences with semicolons;
--------------------
You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement