• C

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

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.

virgo21Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tovergaardCommented:
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)
0
virgo21Author Commented:
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
main()
{
   clrscr();
}

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. :)

0
bjacobsCommented:
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.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

virgo21Author Commented:
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.
0
virgo21Author Commented:
Increased points.
0
bjacobsCommented:
wcl myconio.c mytest.lib
This is the shortest way  to do it.
0
virgo21Author Commented:
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.
0
virgo21Author Commented:
Trying to reject answer since it dosen't work.
0
nils pipenbrinckCommented:
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)
   {  
     clrscr_inline();
   }

   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!

Regards,

 Nils Pipenbrinck

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.