Hi again,
I am new to compiling C programs in Linux/Unix. I wanted to compile a
program by using gcc, but it turned out that gcc does not know where to
locate the library being called.
The program is as follows,
#include <math.h>
int main()
{
double ss;
double ff;
ss=1.0;
ff=sin(ss);
printf("%6.4f\n ",ff);
return 0;
}
The error message is,
/tmp/ccIV3yAb.o: In function `main':
/tmp/ccIV3yAb.o(.tex t+0x1e): undefined reference to `sin'
The command I used to compile is
gcc test.c
Could anyone please let me know where I did wrong? Thanks!
Fan 7 2207
Fan Zhang wrote: The error message is,
/tmp/ccIV3yAb.o: In function `main': /tmp/ccIV3yAb.o(.tex t+0x1e): undefined reference to `sin'
The command I used to compile is gcc test.c
Could anyone please let me know where I did wrong? Thanks!
You need to link with the math library which is called libm
so,
gcc test.c -lm
comp.os.linux.d evelopment.apps or comp.unix.progr ammer
is probably more appropriate for this Q though.
On Tue, 12 Oct 2004, Fan Zhang wrote: /tmp/ccIV3yAb.o: In function `main': /tmp/ccIV3yAb.o(.tex t+0x1e): undefined reference to `sin'
The command I used to compile is gcc test.c
This is practically word-for-word a FAQ. http://www.eskimo.com/~scs/C-faq/q14.3.html
Read the whole thing.
-Arthur
Fan Zhang wrote: I am new to compiling C programs in Linux/Unix. I wanted to compile a program by using gcc but it turned out that gcc does not know where to locate the library being called.
The program is as follows,
#include <math.h> int main() { double ss; double ff; ss=1.0; ff=sin(ss); printf("%6.4f\n ",ff); return 0; }
The error message is,
/tmp/ccIV3yAb.o: In function `main': /tmp/ccIV3yAb.o(.tex t+0x1e): undefined reference to `sin'
The command I used to compile is gcc test.c
Could anyone please let me know where I did wrong? Thanks!
gcc test.c -lm
"Fan Zhang" <fa******@sas.u penn.edu> writes: I am new to compiling C programs in Linux/Unix. I wanted to compile a program by using gcc, but it turned out that gcc does not know where to locate the library being called. The command I used to compile is gcc test.c. Could anyone please let me know where I did wrong? Thanks!
See http://www.network-theory.co.uk/docs...cintro_16.html
for information on linking with external libraries with gcc.
--
Brian Gough
Network Theory Ltd,
Publishing "An Introduction to GCC" --- http://www.network-theory.co.uk/gcc/
In <87************ @network-theory.co.uk> Brian Gough <bj*@network-theory.co.uk> writes: "Fan Zhang" <fa******@sas.u penn.edu> writes:
I am new to compiling C programs in Linux/Unix. I wanted to compile a program by using gcc, but it turned out that gcc does not know where to locate the library being called. The command I used to compile is gcc test.c. Could anyone please let me know where I did wrong? Thanks!
See http://www.network-theory.co.uk/docs...cintro_16.html for information on linking with external libraries with gcc.
Except that the sin function has nothing to do with *any* external
library: it's part of the standard C library.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
On Tue, 12 Oct 2004 18:25:30 -0400, "Fan Zhang"
<fa******@sas.u penn.edu> wrote in comp.lang.c: Hi again,
I am new to compiling C programs in Linux/Unix. I wanted to compile a program by using gcc, but it turned out that gcc does not know where to locate the library being called.
Linux is not UNIX, UNIX is not Linux.
The program is as follows,
#include <math.h> int main() { double ss; double ff; ss=1.0; ff=sin(ss); printf("%6.4f\n ",ff); return 0; }
The error message is,
/tmp/ccIV3yAb.o: In function `main': /tmp/ccIV3yAb.o(.tex t+0x1e): undefined reference to `sin'
The command I used to compile is gcc test.c
Could anyone please let me know where I did wrong? Thanks!
Fan
Despite the fact that Linux is not UNIX, gcc on Linux continues the
old UNIX tradition of pretending that part of the standard C library
is not part of the standard C library.
UNIX elitists do not like to make things easy for the uninitiated,
unwashed masses, even when the reason for a particular piece of
stupidity has been obsolete for 20 years.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jack Klein wrote: On Tue, 12 Oct 2004 18:25:30 -0400, "Fan Zhang" <fa******@sas.u penn.edu> wrote in comp.lang.c:
Hi again,
I am new to compiling C programs in Linux/Unix. I wanted to compile a program by using gcc, but it turned out that gcc does not know where to locate the library being called.
Linux is not UNIX, UNIX is not Linux.
The program is as follows,
#include <math.h> int main() { double ss; double ff; ss=1.0; ff=sin(ss); printf("%6.4f\n ",ff); return 0; }
The error message is,
/tmp/ccIV3yAb.o: In function `main': /tmp/ccIV3yAb.o(.tex t+0x1e): undefined reference to `sin'
The command I used to compile is gcc test.c
try this gcc -Wall -lm test.c This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jhuola Hoptire |
last post by:
Just installed J2RE 1.4.2 on a Linux server. I am very
knew to the POSIX world.
I couldn't dig-up much in the docs or via google about
the following:
1 - Is there a standard way to make sure users (all, or
some) can "reach" java? eg one could presumably create
a java.sh or aliases ... Where is the standard Linux
directory to put such a script (and why)?
|
by: Eric Raymond |
last post by:
When installing the rpms (or the tar file) onto Red Hat Enteprise
Linux AS Beta 1 (Taroon), we get the follwing error:
Installing all prepared tables
/usr/bin/mysql_install_db: line 1: 7690 Segmentation fault
/usr/sbin/mysqld --bootstrap --skip-grant-tables --basedir=/
--datadir=/var/lib/mysql --skip-innodb --skip-bdb
Installation of grant tables failed
The log file simply shows a start and a stop of the server.
|
by: gnu |
last post by:
Rationale to use Linux
=======================
- I can't afford paying for $199 for the license of an OS that's
arguably better thank Linux for each of 10 computers I have.
- I want to be free of Microsoft stigma, and of constant lockdown on
Microsoft products. The world is better than that.
- Linux runs .NET :-) Reverse engineers in less than a year. That's
|
by: Travis 'Bailo' Bickel |
last post by:
Lately, I have been having a bear of a time trying to acquire a Linux driver
for my S3/ProSavage chipset -- but that quest is now almost at an end as I
have located a noble band of people who are pushing the envelop with S3 and
Savage chipset drivers!
Though my quest might sound like food for trolls to mock Linux -- hear me
out. I think I have discovered part of the message of the new Linux
economy. Many of us have criticized the...
|
by: srihari |
last post by:
Hai,
I am trying to install IBM DB2 8.1 on Red Hat linux 8.0. My
machine is Intel XEON 64bit. The installation went well except for the
creation of tools catalog. When I tried to install the tools catalog
as a post installation task I get some java error.
$ db2 CREATE TOOLS CATALOG SYSTOOLS USE EXISTING
DATABASE TOOLSDB FORCE SQL22209N The DB2 Administration Server
encountered an unexpected Java error on host "".
I have jdk1.3 already...
| |
by: Zorba.GR |
last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64
bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite
Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager Express
Edition v1.3.2 Win, IBM Tivoli System Automation v1.2.0 Linux, IBM
Tivoli Workload Scheduler Virtualized Data Centers v8.2 , other
IBM Tivoli CDs, WEBSPHERE EVERYPLACE MOBILE PORTAL v5.0 - ALTIUM , other IBM WebSphere Business CDs...
|
by: cranium.2003 |
last post by:
hi,
Here is my code
#include <iostream.h>
int main()
{
cout <<"HI";
return 0;
}
and using following command to compile a C++ program
g++ ex1.cpp -o ex1
|
by: rada.lambretha |
last post by:
Configuring Linux as a Firewall
* Making installation choices
* Introducing iptables
* Using iptables commands
* Simplifying things with firewall GUIs
* Adding proxy functionality
As Linux gains increasing acceptance in corporate datacenters and
|
by: Nepomuk |
last post by:
You might have heard about Linux, but you don't know what it is? Or you know a few things about it, but they terrify you? Well, then this article is for you. Don't be afraid - Everyone can use Linux!
Part 1: What is Linux and why should I use it?
Linux is an Operating System (short: OS). OK, so what is an OS? Let me explain:
Nearly everybody knows Windows. But what exactly does it actually do?
Windows is an example for a OS and one of it's...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |