469,578 Members | 1,325 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

conio.h (linking?) problem

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.
Nov 15 '05 #1
17 6530
In article <e5***************************@news1.tudelft.nl> ,
Mitas Nikos <mi******@yahoo.gr> wrote:
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 .
--
"Never install telephone wiring during a lightning storm." -- Linksys
Nov 15 '05 #2
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
Nov 15 '05 #3
Walter Roberson wrote:
In article <e5***************************@news1.tudelft.nl> ,
Mitas Nikos <mi******@yahoo.gr> wrote:
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 .


Sorry, here is the link to http://conio.sourceforge.net/docs/html/conio2_8h.html.
Nov 15 '05 #4
Mitas Nikos wrote:
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

Nov 15 '05 #5
Ulrich Eckhardt wrote on 17/09/05 :
Mitas Nikos wrote:
I am trying to use the library conio2


As others have totally failed to inform you about, conio2 is not part of
standard C,


What are the words you don't understand in

"Non-standard functions headers and library."
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Mal nommer les choses c'est ajouter du malheur au
monde." -- Albert Camus.
Nov 15 '05 #6
Emmanuel Delahaye wrote:
Ulrich Eckhardt wrote on 17/09/05 :
Mitas Nikos wrote:
I am trying to use the library conio2


As others have totally failed to inform you about, conio2 is not part of
standard C,


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

Nov 15 '05 #7
In article <3p************@uni-berlin.de>,
Ulrich Eckhardt <do******@knuut.de> wrote:
: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.
--
The rule of thumb for speed is:

1. If it doesn't work then speed doesn't matter. -- Christian Bau
Nov 15 '05 #8
Mitas Nikos <mi******@yahoo.gr> wrote:
Sorry, here is the link to http://conio.sourceforge.net/docs/html/conio2_8h.html.


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.

http://www.ungerhu.com/jxh/clc.welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 15 '05 #9
Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Mitas Nikos <mi******@yahoo.gr> wrote:
Sorry, here is the link to
http://conio.sourceforge.net/docs/html/conio2_8h.html.


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.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #10
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.org> wrote:
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.
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
Nov 15 '05 #11

"Ulrich Eckhardt" <do******@knuut.de> wrote

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.
Nov 15 '05 #12
Malcolm wrote:
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

Nov 15 '05 #13
Ulrich Eckhardt wrote:
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
Nov 15 '05 #14
Mitas Nikos wrote on 18/09/05 :
Finally I have solved the problem that was the order of the parameter
-lconio.h


<OT>
No. You meant "-lconio"
</>
--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

..sig under repair
Nov 15 '05 #15
On Sat, 17 Sep 2005 18:37:45 +0200, in comp.lang.c , Mitas Nikos
<mi******@yahoo.gr> wrote:
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?
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 15 '05 #16
Emmanuel Delahaye wrote:
Mitas Nikos wrote on 18/09/05 :
Finally I have solved the problem that was the order of the parameter
-lconio.h


<OT>
No. You meant "-lconio"
</>


Again I'm sorry i meant "-lconio".
End of problem.
Nov 15 '05 #17
Christopher Benson-Manica wrote:
Mitas Nikos <mi******@yahoo.gr> wrote:
Sorry, here is the link to http://conio.sourceforge.net/docs/html/conio2_8h.html.


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

Nov 15 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Eduardo Elias Camponez | last post: by
1 post views Thread by buchalino | last post: by
17 posts views Thread by annai | last post: by
13 posts views Thread by 7stud | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.