Make a small c lib using Watcom C/C++ 10.6.

Posted on 1997-04-18
Last Modified: 2008-03-10
How do I make a small library in c, Using Watcom C/C++ 10.6.
Here are some sample code I have tried.
The code works, just wanna know how to put it in a LIB ?

I compiled the myconio.c to myconio.obj then used the library
utility to make myconio.lib, but then I can't use it.

How should myconio.h look like and how should I go about doing a lib ?

// myconio.h
extern void clrscr(void);

// myconio.c
void clrscr(void);
#pragma aux clrscr =            \
      "Mov Ax, 0B800h"        \
      "Mov Es, Ax"            \
      "Mov Cx, 07D0h"         \
      "Xor Di, Di"            \
      "Mov Ax, 0700h"         \
      "Rep stosw";
// clrscr ends.

Question by:virgo21

Expert Comment

ID: 1249951
You say you can't use it ?

Is it the lib file or the lib creater util you can't use ?

What is the error message/problem ?
(I can't use it does not say much about the problem)

Author Comment

ID: 1249952
What I mean is when I have created the myconio.lib
how do I then use the function in a c program ?
Have I declared the prototype correctly in the header file ?

I do like this.

wcc myconio.c -> myconio.obj
wlib -b -n myconio +myconio -> myconio.lib

Now I'll create a file called mytest.c:
// mytest.c

then I do wcl mytest.c ->

D:\DEV\WATCOM\BINW>wcl mytest.c
WATCOM C/C++16 Compile and Link Utility Version 10.6
Copyright by WATCOM International Corp. 1988, 1996. All rights reserved.
WATCOM is a trademark of WATCOM International Corp.
       wcc MYTEST.C
WATCOM C16 Optimizing Compiler  Version 10.6
Copyright by WATCOM International Corp. 1984, 1996. All rights reserved.
WATCOM is a trademark of WATCOM International Corp.
MYTEST.C: 6 lines, included 15, 0 warnings, 0 errors
Code size: 9

WATCOM Linker Version 10.6
Copyright by WATCOM International Corp. 1985, 1996. All rights reserved.
WATCOM is a trademark of WATCOM International Corp.
loading object files
searching libraries
Warning(1028): clrscr_ is an undefined reference
creating a DOS executable
file MYTEST.obj(D:\DEV\WATCOM\BINW\MYTEST.C): undefined symbol clrscr_
Error: Linker returned a bad status

What am I doing wrong ?
Please help and forgive me for not giving enough info. :)


Expert Comment

ID: 1249953
You need to link your program with your library. I don't use Watcom C but look up your link help and it will tell you the commands. An alternative is to set up a project in the IDE including your program and library.
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.


Author Comment

ID: 1249954
Watcom dosen't have an IDE it's totally command based, at least the one I'm using. I think it's because I only use the DOS hosted Watcom compiler.

I could always link in the .obj file like something like this:
wcc myconio.c
wcc mytest.c
wlink myconio.c mytest.c

then I would get a .exe file that works, but that was what I wanted to avoid.

I need an answer from somebody who knows about Watcom C/C++.

Thanks for your answer, but your answer should have been a comment since it's not an answer only a suggestion.

I have allready tried to read the online manuals, but they really suck, It's very difficult to find the info you need.
If I could find the answer in the manuals I wouldn't ask around here. :)

Hoping for a really good answer.

Author Comment

ID: 1249955
Increased points.

Expert Comment

ID: 1249956
wcl myconio.c mytest.lib
This is the shortest way  to do it.

Author Comment

ID: 1249957
bjacob: Your answer dosen't work at all.
By the way you got the extensions wrong. :)
Neither of theese works for me though:
wcl myconio.lib mytest.c
wcl mytest.c myconio.lib

Thanks for your try, I really thought this question was simple, but maybe not ?

Have a nice day all of you.

Author Comment

ID: 1249958
Trying to reject answer since it dosen't work.

Accepted Solution

nils pipenbrinck earned 40 total points
ID: 1249959
I have an answer that'll work!

Please note: If you write #pragma statements to inline assembly-code into your c-files no code will be generated at this point. The code will be directly expanded into the function that actually calls the subroutine.

Therefore your object file didn't contain any single public definition.

Now you have two options to make your library:

1. Put the routine into the headerfile (along with the #pragma).
   Whenever you now use clrscr the compiler will inline the code.
   (nice and fast. Since the function is very tiny I would go    this way.

2. Rename the function to something like clrscr_inline and create
   a function in your c-file which calls clrscr_inline.

   It would look like this:

   void clrscr (void)

   Now you've generated code and the object file will contain
   a public definition for clrscr. The librarian and linker will
   find the function and you'll get rid out of your errors.

I tested it.. It works!


 Nils Pipenbrinck


Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question