conio.h (linking?) problem

M

Mitas Nikos

I am trying to use the library conio2 and though I have managed with a
few relatively simple examples when i try to compile a program which
conio's function clrscr is not in main() i get an error from the linker.

[Linker error] undefined reference to `clrscr'
ld returned 1 exit status

I include the conio2.h on top of the file where clrscr() fn is.

How do I pass the -lconio parameter when I have multiple files?Isn't it:
gcc -lconio main.c clr_file.c file1.c file2.c ....

Is there a different way?The same thing worked when the whole program
was in one file.
 
W

Walter Roberson

I am trying to use the library conio2

Please post a link to standard-compliant code for the library conio2,
as the library is not specified by the C standard. We only deal with
standard C in comp.lang.c .
 
E

Emmanuel Delahaye

Mitas Nikos wrote on 17/09/05 :
I am trying to use the library conio2 and though I have managed with a few
relatively simple examples when i try to compile a program which conio's
function clrscr is not in main() i get an error from the linker.

Non-standard functions headers and library.
[Linker error] undefined reference to `clrscr'
ld returned 1 exit status

I include the conio2.h on top of the file where clrscr() fn is.

How do I pass the -lconio parameter when I have multiple files?Isn't it:
gcc -lconio main.c clr_file.c file1.c file2.c ....

Is there a different way?The same thing worked when the whole program was in
one file.

<OT>
You must add the missing library (something like -lconio) to the
project.
</>

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"It's specified. But anyone who writes code like that should be
transmogrified into earthworms and fed to ducks." -- Chris Dollin CLC
 
U

Ulrich Eckhardt

Mitas said:
I am trying to use the library conio2

As others have totally failed to inform you about, conio2 is not part of
standard C, so is partially off-topic here. There is no portable, standard
replacement though, so it's use is not totally bogus.
and though I have managed with a
few relatively simple examples when i try to compile a program which
conio's function clrscr is not in main() i get an error from the linker.

[Linker error] undefined reference to `clrscr'
ld returned 1 exit status

I include the conio2.h on top of the file where clrscr() fn is.

OK, this header contains the declarations of the conio library. A
declaration only means 'hey compiler, there is a function foo that takes
these arguments and returns a bar'. You still need the function itself to
complete your program.
How do I pass the -lconio parameter when I have multiple files?Isn't it:
gcc -lconio main.c clr_file.c file1.c file2.c ....

Almost. Let me say here too that the use of particular compilers is not
really something discussed here, there are more specific groups for that.
However, in your case, there is a systematic error: you need to put the
library after the program-files that depend on it. Yes, it's appalling,
but the order matters here.

Uli
 
U

Ulrich Eckhardt

Emmanuel said:
Ulrich Eckhardt wrote on 17/09/05 :

What are the words you don't understand in

"Non-standard functions headers and library."

I personally? None, apart from the typo. However, I believe you fail to
understand that one has to have much deeper knowledge about what can or
could be standard than what can be expected from someone asking such an
obvious beginner's question. It's not about the raw information, it's the
fact that it is useless to a beginner when just thrown at them without the
simplest bit of explanation.

Uli
 
W

Walter Roberson

:As others have totally failed to inform you about, conio2 is not part of
:standard C, so is partially off-topic here.

It seems to me that I wrote,

"Please post a link to standard-compliant code for the library conio2,
as the library is not specified by the C standard."

?

Do you perceive a substative difference between
"not specified by the C standard" and
"not part of standard C" ?


conio2 is not part of C89 or C99; and since names get reused and
we didn't know which one the OP meant, there was the -possibility-
that the library being referred to had a compliant implementation.


Alas, it turned out to be not only Windows-specific but C++ code.
 
K

Keith Thompson

Christopher Benson-Manica said:
You missed the point of Walter's post: This newsgroup deals with
standard C only; conio is not standard. Therefore you should ask your
question in another newsgroup.

I agree, but IMHO Walter didn't make the point very clearly. We can't
all be expected to know the names of all the platform-specific
libraries, but we've all seen enough off-topic posts to make a
reasonable guess that something called "conio" is probably
Windows-specific (or that a function called "fork" is probably
Unix-specific). Walter's request for "standard-compliant code for the
library conio2" sounded like someone pretending to know nothing beyond
standard C, rather than someone actually trying to be helpful. The
very fact that the OP posted his question here implies that he's
unlikely to get the joke.

We need to discourage off-topic discussion, but there's nothing wrong
with helpfully suggesting where a question might be topical.

Walter, I'm only guessing what you had in mind with your response; I
apologize if I guessed wrong.
 
W

Walter Roberson

We can't
all be expected to know the names of all the platform-specific
libraries, but we've all seen enough off-topic posts to make a
reasonable guess that something called "conio" is probably
Windows-specific (or that a function called "fork" is probably
Unix-specific). Walter's request for "standard-compliant code for the
library conio2" sounded like someone pretending to know nothing beyond
standard C, rather than someone actually trying to be helpful.

The OP showed a gcc command line, so I didn't want to presume that
it was Windows. Might have been a Linux compatability library,
or something for Lindow,s or something providing a Windows-like
interface to make it easier for people to ease into the hard
drugs such as terminfo...

The reference to clrscn did make it fairly likely that
-something- non-standard was being discussed, but there wasn't
enough unambigous context to determine what.
 
M

Malcolm

Ulrich Eckhardt said:
As others have totally failed to inform you about, conio2 is not part of
standard C, so is partially off-topic here. There is no portable, standard
replacement though, so it's use is not totally bogus.
C is designed so that platform-specific libraries can be shipped with the
compiler, or by third parties. There's absolutely nothing wrong with using
such libraries, as long as you don't expect your code to port to all
platforms.What we cannot do is give advice on the details of every third party library
itself, or otherwise the group would become unmanageable in scope, since
there are so many.
 
U

Ulrich Eckhardt

Malcolm said:
What we cannot do is give advice on the details of every third party
library itself, or otherwise the group would become unmanageable in
scope, since there are so many.

I'm aware of that and I wouldn't want discussions about the use of every
third-party library to happen here. However, two points about the OPs
post:

1. He didn't have a problem which was specific to the use of a third-party
library but rather a general linking problem. Yes, I'm aware that the C
standard doesn't define anything like a linker, but since it is a thing
that comes up in every compiled C implementation (which is the majority)
general advise about linking is on-topic here.

2. He obviously is a beginner in C, so telling him that his request is
off-topic doesn't help. In fact it often requires some knowledge to say
where the problem exactly lies and then to judge whether here is the right
place to ask for help. Just telling a beginner to buzz off and not even a
reason in beginner-understandable language is plain rude.

Lastly, I admit that my language was cynic but I think it is deserved due
to people being intentionally rude and non-helpful.

Uli
 
M

Mitas Nikos

Ulrich said:
I'm aware of that and I wouldn't want discussions about the use of every
third-party library to happen here. However, two points about the OPs
post:

1. He didn't have a problem which was specific to the use of a third-party
library but rather a general linking problem. Yes, I'm aware that the C
standard doesn't define anything like a linker, but since it is a thing
that comes up in every compiled C implementation (which is the majority)
general advise about linking is on-topic here.

2. He obviously is a beginner in C, so telling him that his request is
off-topic doesn't help. In fact it often requires some knowledge to say
where the problem exactly lies and then to judge whether here is the right
place to ask for help. Just telling a beginner to buzz off and not even a
reason in beginner-understandable language is plain rude.

Lastly, I admit that my language was cynic but I think it is deserved due
to people being intentionally rude and non-helpful.

Uli

Finally I have solved the problem that was the order of the parameter -lconio.h passed on to the
linker(and the fact that my IDE had a bug and could not switch profiles for linking).Thank you for
your help,and sorry for the fuss I have created.And yes the problem was not from the third party
library(conio.h and conio2.h work perfectly well).

I agree on the policy of not solving off topic problems(questions) but the least you can do is
redirect the inquirer to another newsgroup.Thanks again
 
M

Mark McIntyre

I am trying to use the library conio2 and though I have managed with a
few relatively simple examples when i try to compile a program which
conio's function clrscr is not in main() i get an error from the linker.

This is a FAQ.
How do I pass the -lconio parameter when I have multiple files?Isn't it:
gcc -lconio main.c clr_file.c file1.c file2.c ....

and this is a question about the gcc compiler, not about C itself.
Is there a different way?The same thing worked when the whole program
was in one file.

RTFM?
 
T

Thad Smith

Christopher said:
You missed the point of Walter's post: This newsgroup deals with
standard C only; conio is not standard. Therefore you should ask your
question in another newsgroup.

The essential issue of topicality isn't that conio isn't a standard
library or isn't written in Standard C, but rather that the
implementation must be told how to link object libraries, and that is
platform specific. What conio functions do or what it is written in is
irrelevant when linking object modules.

Thad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top