473,383 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How will you know about the libraries

Neo

I am using linux for my c programs and while compiling I some times
have to use -lm for math libraries ..

that is linker option,

but how will I know the library which I have to link ... meaning
math will be with -lm
etc ?
please help ... in linker options

Nov 14 '05 #1
7 1263
In article <11*********************@g14g2000cwa.googlegroups. com>,
Neo <bv********@gmail.com> wrote:
I am using linux for my c programs and while compiling I some times
have to use -lm for math libraries .. that is linker option, but how will I know the library which I have to link ... meaning
math will be with -lm
etc ?


On unix, you read the man page for the function you are interested
in, and you look at the 'see also' section, which will refer
you to the 'intro' man page for the appropriate section. You
read the intro man page, and it tells you which libraries you
need to link in.
--
Look out, there are llamas!
Nov 14 '05 #2
On 9 Apr 2005 11:01:36 -0700, Neo
<bv********@gmail.com> wrote:

I am using linux for my c programs and while compiling I some times
have to use -lm for math libraries ..

that is linker option,

but how will I know the library which I have to link ... meaning
math will be with -lm
etc ?
please help ... in linker options


Well, for Unix-like systems you can use man <name_of_function> which
will tell you the header files you need to include and the libraries (if
not default).

However, many people regard this 'feature' of GCC (not including -lm by
default) as a bug, because a C compiler should arguably include any
libraries necessary to provide the standard functions without having
to do some system-dependent thing. The overhead is minimal (if there
are no functions still unlinked, it doesn't even have to read the extra
library, and no extra code should be linked if the functions in -lm
aren't needed). Indeed, the library supplied with the Cygwin port has
the maths functions in it so -lm isn't needed.

Chris C
Nov 14 '05 #3
On Sat, 9 Apr 2005 23:15:06 +0100, in comp.lang.c , Chris Croughton
<ch***@keristor.net> wrote:
However, many people regard this 'feature' of GCC (not including -lm by
default) as a bug,
its worth noting that this isn't a GCC feature so much as a feature of
most early compilers. Some compilers even required you to *use* some
FP in main() to get the lib linked.
because a C compiler should arguably include any
libraries necessary to provide the standard functions without having
to do some system-dependent thing.
I agree with this.
The overhead is minimal
on a modern PC, yes. Not so on an original IBM-PC, or on many non-PC
implementations.
the library supplied with the Cygwin port has
the maths functions in it so -lm isn't needed.


so long as it silently ignores the -lm if you do include it. Otherwise
thered be a lot of broken makefiles.... :-)
--
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 14 '05 #4
"Neo" <bv********@gmail.com> wrote:
#
# I am using linux for my c programs and while compiling I some times
# have to use -lm for math libraries ..
#
# that is linker option,
#
# but how will I know the library which I have to link ... meaning
# math will be with -lm
# etc ?

If you're lucky, it's included upfront in the interface documentation.
Usually if it's mentionned at all, it's one obscure sentence deep in
build notes. Sucks, but that's the accepted practice.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Mention something out of a Charleton Heston movie, and suddenly
everybody's a theology scholar.
Nov 14 '05 #5
On Sun, 10 Apr 2005 00:26:17 +0100, Mark McIntyre
<ma**********@spamcop.net> wrote:
On Sat, 9 Apr 2005 23:15:06 +0100, in comp.lang.c , Chris Croughton
<ch***@keristor.net> wrote:
However, many people regard this 'feature' of GCC (not including -lm by
default) as a bug,
its worth noting that this isn't a GCC feature so much as a feature of
most early compilers. Some compilers even required you to *use* some
FP in main() to get the lib linked.


Many (most?) of those early compilers gave you a choice of math
libraries, for one reason or another (hardware fpp vs software fpp vs
emulated hardware vs no fpp, for example). A common way to do this was
to choose which library to link with.
because a C compiler should arguably include any
libraries necessary to provide the standard functions without having
to do some system-dependent thing.


I agree with this.
The overhead is minimal


on a modern PC, yes. Not so on an original IBM-PC, or on many non-PC
implementations.
the library supplied with the Cygwin port has
the maths functions in it so -lm isn't needed.


so long as it silently ignores the -lm if you do include it. Otherwise
thered be a lot of broken makefiles.... :-)


--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 14 '05 #6
On Sat, 09 Apr 2005 23:15:06 +0100, Chris Croughton wrote:

....
However, many people regard this 'feature' of GCC (not including -lm by
default) as a bug, because a C compiler should arguably include any
libraries necessary to provide the standard functions without having
to do some system-dependent thing.
It isn't a bug as such, because it is almost certainly deliberate and it
is not a conformance issue. Many compilers are conforming by default and
require you to give extra options to make them conforming (or the best
approximation to it). There is for example -ansi in gcc or -stdc= . A
compiler doesn't have to be conforming by default, there just needs to be
a way to invoke it as such.
The overhead is minimal (if there
are no functions still unlinked, it doesn't even have to read the extra
library, and no extra code should be linked if the functions in -lm
aren't needed). Indeed, the library supplied with the Cygwin port has
the maths functions in it so -lm isn't needed.


I agree that it isn't obvious what is gained by not making -lm implicit
these days.

Lawrence
Nov 14 '05 #7
Lawrence Kirby wrote:
On Sat, 09 Apr 2005 23:15:06 +0100, Chris Croughton wrote:

...

However, many people regard this 'feature' of GCC (not including -lm by
default) as a bug, because a C compiler should arguably include any
libraries necessary to provide the standard functions without having
to do some system-dependent thing.

It isn't a bug as such, because it is almost certainly deliberate and it
is not a conformance issue. Many compilers are conforming by default and
require you to give extra options to make them conforming (or the best
approximation to it). There is for example -ansi in gcc or -stdc= . A
compiler doesn't have to be conforming by default, there just needs to be
a way to invoke it as such.

The overhead is minimal (if there
are no functions still unlinked, it doesn't even have to read the extra
library, and no extra code should be linked if the functions in -lm
aren't needed). Indeed, the library supplied with the Cygwin port has
the maths functions in it so -lm isn't needed.

I agree that it isn't obvious what is gained by not making -lm implicit
these days.

Lawrence


Probably just comfort with old habits. It also occurs to me that I
haven't typed 'gcc' and '-lm' for a long time. I use short scripts or
makefiles to invoke the compiler.

--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lindon | last post by:
Until now I've been programming straight console apps, and all I've been doing to compile is a simple 'gcc file1.cpp file2.cpp ....'. What more is there to know about the compiler? I'd like to know...
5
by: Cecil Westerhoff | last post by:
I just started with programming under linux with c++. I have programmed for years with Borland C++ Builder. So I have some experience. But I can not find the libraries for intenet stuff. (Ping,...
1
by: rajesh_krec | last post by:
Hello Everybody, I'm using Microsoft Visual Studio .NET 2003 (with Vc7 compiler) I have some 15 projects each of which generate a static library when i build the solution in release mode. ...
48
by: meyer | last post by:
Hi everyone, which compiler will Python 2.5 on Windows (Intel) be built with? I notice that Python 2.4 apparently has been built with the VS2003 toolkit compiler, and I read a post from Scott...
10
by: Chris Thomasson | last post by:
I am working on a high-speed futures implementation in C++, and was tinkering around with ways to wrap the function pointer logic. I am a C/Assembly programmer that doesn't make a lot of use of...
9
by: PengYu.UT | last post by:
Hi, I feel argparse has some useful things that optparse doesn't have. But I can't find it argparse in python library reference. I'm wondering when it will be available in the python standard...
8
by: Jazi | last post by:
Hi All, I made a copy of a static library from an open-source code and changed its name to something different. In my driver I linked to both of these libraries. My question is will the global...
17
by: Jack | last post by:
My program is about several thousands lines. It takes arguements from the command line. If no arguement is given, it should simply exist. Below is the architectureof main() : int main(int argc,...
8
by: Dan Christensen | last post by:
Hi, I am an amateur software developer, and would like to know if some freeware I developed a few years ago using VB6 and XP will work under Vista. If so, what must I do to create a Vista...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.