• Advertisement

Archived

This topic is now archived and is closed to further replies.

Making Library Files

This topic is 6596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;

Yanroy@usa.com

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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;

Yanroy@usa.com

Share this post


Link to post
Share on other sites

  • Advertisement