473,396 Members | 2,011 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,396 software developers and data experts.

undefined references to functions when linking

Hi,

In a file test1.c, in have the two functions f1 and f2. These are
declared in the header file t1.h. I want to call these functions in
another file subprog.c, which contains the function call_funcs. I have
included the header file t1.h in subprog.c. Using gcc, I can compile
and get subprog.o without any problems.

However, when I try to link subprog.o into the main application, I get
the errors

In function call_funcs undefined reference to f1
In function call_funcs undefined reference to f2

Anybody have any idea what could be causing this.

Many Thanks
Bob

Jun 12 '07 #1
6 27525
<st*****@yahoo.comschrieb im Newsbeitrag
news:11**********************@j4g2000prf.googlegro ups.com...
Hi,

In a file test1.c, in have the two functions f1 and f2. These are
declared in the header file t1.h. I want to call these functions in
another file subprog.c, which contains the function call_funcs. I have
included the header file t1.h in subprog.c. Using gcc, I can compile
and get subprog.o without any problems.

However, when I try to link subprog.o into the main application, I get
the errors

In function call_funcs undefined reference to f1
In function call_funcs undefined reference to f2

Anybody have any idea what could be causing this.
You need to compile test1.c too and link the resulting .o with the
subprog.o.

Bye, Jojo
Jun 12 '07 #2
On Jun 12, 6:13 pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
<sten...@yahoo.comschrieb im Newsbeitragnews:11**********************@j4g2000pr f.googlegroups.com...Hi,
In a file test1.c, in have the two functions f1 and f2. These are
declared in the header file t1.h. I want to call these functions in
another file subprog.c, which contains the function call_funcs. I have
included the header file t1.h in subprog.c. Using gcc, I can compile
and get subprog.o without any problems.
However, when I try to link subprog.o into the main application, I get
the errors
In function call_funcs undefined reference to f1
In function call_funcs undefined reference to f2
Anybody have any idea what could be causing this.

You need to compile test1.c too and link the resulting .o with the
subprog.o.

Bye, Jojo
Thanks Jojo...that fixed it...I now get multiple definition
errors...you don't know how to solve that???

Jun 12 '07 #3
<st*****@yahoo.comschrieb im Newsbeitrag
news:11**********************@n15g2000prd.googlegr oups.com...
On Jun 12, 6:13 pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
><sten...@yahoo.comschrieb im
Newsbeitragnews:11**********************@j4g2000p rf.googlegroups.com...>
Hi,
In a file test1.c, in have the two functions f1 and f2. These are
declared in the header file t1.h. I want to call these functions in
another file subprog.c, which contains the function call_funcs. I have
included the header file t1.h in subprog.c. Using gcc, I can compile
and get subprog.o without any problems.
However, when I try to link subprog.o into the main application, I get
the errors
In function call_funcs undefined reference to f1
In function call_funcs undefined reference to f2
Anybody have any idea what could be causing this.

You need to compile test1.c too and link the resulting .o with the
subprog.o.

Bye, Jojo

Thanks Jojo...that fixed it...I now get multiple definition
errors...you don't know how to solve that???
Not without seeing the code...

Bye, Jojo
Jun 12 '07 #4
st*****@yahoo.com wrote:
>
In a file test1.c, in have the two functions f1 and f2. These are
declared in the header file t1.h. I want to call these functions
in another file subprog.c, which contains the function call_funcs.
I have included the header file t1.h in subprog.c. Using gcc, I
can compile and get subprog.o without any problems.

However, when I try to link subprog.o into the main application,
I get the errors

In function call_funcs undefined reference to f1
In function call_funcs undefined reference to f2

Anybody have any idea what could be causing this.
Failure to link t1.o.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 12 '07 #5
st*****@yahoo.com writes:
On Jun 12, 6:13 pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
><sten...@yahoo.comschrieb im Newsbeitragnews:11**********************@j4g2000pr f.googlegroups.com...Hi,
In a file test1.c, in have the two functions f1 and f2. These are
declared in the header file t1.h. I want to call these functions in
another file subprog.c, which contains the function call_funcs. I have
included the header file t1.h in subprog.c. Using gcc, I can compile
and get subprog.o without any problems.
However, when I try to link subprog.o into the main application, I get
the errors
In function call_funcs undefined reference to f1
In function call_funcs undefined reference to f2
Anybody have any idea what could be causing this.

You need to compile test1.c too and link the resulting .o with the
subprog.o.

Thanks Jojo...that fixed it...I now get multiple definition
errors...you don't know how to solve that???
A wild guess: t1.h defines (rather than declares) one or more global
variables. I.e. you have "int x;" rather than "extern int x;" in
t1.h. If this is the problem, you need to use the extern form in the
..h file and ensure that only one (you get to chose) compilation unit
contains the actual definition.

--
Ben.
Jun 13 '07 #6
On Jun 12, 8:55 pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
<sten...@yahoo.comschrieb im Newsbeitragnews:11**********************@n15g2000p rd.googlegroups.com...
On Jun 12, 6:13 pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
<sten...@yahoo.comschrieb im
Newsbeitragnews:11**********************@j4g2000pr f.googlegroups.com...>
Hi,
In a file test1.c, in have the two functions f1 and f2. These are
declared in the header file t1.h. I want to call these functions in
another file subprog.c, which contains the function call_funcs. I have
included the header file t1.h in subprog.c. Using gcc, I can compile
and get subprog.o without any problems.
However, when I try to link subprog.o into the main application, I get
the errors
In function call_funcs undefined reference to f1
In function call_funcs undefined reference to f2
Anybody have any idea what could be causing this.
You need to compile test1.c too and link the resulting .o with the
subprog.o.
Bye, Jojo
Thanks Jojo...that fixed it...I now get multiple definition
errors...you don't know how to solve that???

Not without seeing the code...

Bye, Jojo- Hide quoted text -

- Show quoted text -
Hi All,

Got it sorted...had to rename a few functions and that cleared
everything up.

Many Thanks to all that replied

Bob

Jun 13 '07 #7

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

Similar topics

2
by: RU | last post by:
Hi, I am working on a porting project to port C/C++ application from unixware C++, AT&T Standard components to g++ with STL on Linux. This application has been working properly on...
0
by: Ryan Liu | last post by:
All, Now I have meet a strange problems. When all the files have been compiled and when linking, make always recompiles some files. I don't know why. Would you mind giving some suggestion? The...
3
by: Kevin Burton | last post by:
I am trying to use managed C++ but I am getting the following link errors: Metadata file 'D:\Projects\Visa\AddressVerification\AddressVerificat...
5
by: lars.uffmann | last post by:
Hi - since my Suse 10.1 didn't have netcdf support enabled by default, I downloaded the sources from http://www.unidata.ucar.edu/software/netcdf/ then did ../configure --prefix=/usr make make...
13
by: 7stud | last post by:
test1.py: -------------------- import shelve s = shelve.open("/Users/me/2testing/dir1/aaa.txt") s = "red" s.close() --------output:------ $ python test1.py
0
by: hivdb2 | last post by:
Hi all, I have an app developed in Access 2000/2003 (2000 compatible). I have a routine to refresh table links. Both files are MDB files (the front end and back end). The code I use is as...
16
by: Greg (codepug | last post by:
If one converts that .mdb into an .mde the code is secure but the tables can still be imported. Just for Very Basic protection, I have placed a Password on the database using the "Set Database...
7
by: coolsti | last post by:
I have the task to set up an application at work,using MS Access as a front end to a MySQL database. This will be done using an appropriate ODBC driver, and linking the MySQL database to Access. ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.