By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

C++ noob - compiler question.

P: n/a
I'm not new to programming, but I am fairly new to C++. I've got a bit of a
problem with a project that I am working on. My environment is as follows:

OS: Mandrake 10
IDE: Anjuta
Compiler: gnu

The project I am working on is a C/C++ combo. I've created a class (in C++)
to encapsulate a particular bit of functionality; this class makes calls to
some C functions in a separate file (nothing complicated). All of the
necessary includes are in place.

The problem is this: when I "Compile" my file, it works fine and produces no
errors, but when I go to "Build" my file I get errors in the file that I
just compiled with no errors. The errors read "undefined reference to
function_name_here(param1*, param2)". The errors are produced on each line
that makes a call to a function in the C file.

I'm a little confused as to what I need to do here. Why does it compile but
not build?

Thanks.

-Sheppe
Jul 22 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Noone wrote:

I'm not new to programming, but I am fairly new to C++. I've got a bit of a
problem with a project that I am working on. My environment is as follows:

OS: Mandrake 10
IDE: Anjuta
Compiler: gnu

The project I am working on is a C/C++ combo. I've created a class (in C++)
to encapsulate a particular bit of functionality; this class makes calls to
some C functions in a separate file (nothing complicated). All of the
necessary includes are in place.

The problem is this: when I "Compile" my file, it works fine and produces no
errors, but when I go to "Build" my file I get errors in the file that I
just compiled with no errors. The errors read "undefined reference to
function_name_here(param1*, param2)". The errors are produced on each line
that makes a call to a function in the C file.


See the FAQ (particularly item 32):
http://www.parashift.com/c++-faq-lite

Denis
Jul 22 '05 #2

P: n/a
Noone wrote:
[...]
I'm a little confused as to what I need to do here. Why does it compile but
not build?


Get a decent book on gnu tools. You probably forget that for linking
you need to supply all object modules in the same command line.

BTW, compiler command lines are off-topic here. Please refer to
newsgroups comp.os.linux.development.* and gnu.g++.help for further
information.

V
Jul 22 '05 #3

P: n/a

"Noone" <no***@nowhere.com> wrote in message
news:SuLWc.208928$gE.115676@pd7tw3no...
I'm not new to programming, but I am fairly new to C++. I've got a bit of a problem with a project that I am working on. My environment is as follows:

OS: Mandrake 10
IDE: Anjuta
Compiler: gnu

The project I am working on is a C/C++ combo. I've created a class (in C++) to encapsulate a particular bit of functionality; this class makes calls to some C functions in a separate file (nothing complicated). All of the
necessary includes are in place.

The problem is this: when I "Compile" my file, it works fine and produces no errors, but when I go to "Build" my file I get errors in the file that I
just compiled with no errors. The errors read "undefined reference to
function_name_here(param1*, param2)". The errors are produced on each line
that makes a call to a function in the C file.

I'm a little confused as to what I need to do here. Why does it compile but not build?


Look up "extern C". If that doesn't help, try creating
a small example that produces the problem and post it here
(standard code only, please).

-Mike
Jul 22 '05 #4

P: n/a
Thanks for the link. :)

-Sheppe

"Denis Remezov" <fi***************@yahoo.removethis.ca> wrote in message
news:41***************@yahoo.removethis.ca...
Noone wrote:

I'm not new to programming, but I am fairly new to C++. I've got a bit of a problem with a project that I am working on. My environment is as follows:
OS: Mandrake 10
IDE: Anjuta
Compiler: gnu

The project I am working on is a C/C++ combo. I've created a class (in C++) to encapsulate a particular bit of functionality; this class makes calls to some C functions in a separate file (nothing complicated). All of the
necessary includes are in place.

The problem is this: when I "Compile" my file, it works fine and produces no errors, but when I go to "Build" my file I get errors in the file that I
just compiled with no errors. The errors read "undefined reference to
function_name_here(param1*, param2)". The errors are produced on each line that makes a call to a function in the C file.


See the FAQ (particularly item 32):
http://www.parashift.com/c++-faq-lite

Denis

Jul 22 '05 #5

P: n/a
On Tue, 24 Aug 2004 18:08:50 GMT in comp.lang.c++, "Noone"
<no***@nowhere.com> wrote,
just compiled with no errors. The errors read "undefined reference to
function_name_here(param1*, param2)". The errors are produced on each line
that makes a call to a function in the C file.


Are you sure that you declared the function with
extern "C"
in the C++ part?

This issue is covered in Marshall Cline's C++ FAQ. See section
"[32] How to mix C and C++" It is always good to check the FAQ before
posting. You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/

Jul 22 '05 #6

P: n/a
Awesome! That fixed me up. Thanks for the tip. :)

-Sheppe

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:bI*******************@newsread1.news.pas.eart hlink.net...

"Noone" <no***@nowhere.com> wrote in message
news:SuLWc.208928$gE.115676@pd7tw3no...
I'm not new to programming, but I am fairly new to C++. I've got a bit of
a
problem with a project that I am working on. My environment is as
follows:
OS: Mandrake 10
IDE: Anjuta
Compiler: gnu

The project I am working on is a C/C++ combo. I've created a class (in

C++)
to encapsulate a particular bit of functionality; this class makes calls

to
some C functions in a separate file (nothing complicated). All of the
necessary includes are in place.

The problem is this: when I "Compile" my file, it works fine and produces no
errors, but when I go to "Build" my file I get errors in the file that I
just compiled with no errors. The errors read "undefined reference to
function_name_here(param1*, param2)". The errors are produced on each

line that makes a call to a function in the C file.

I'm a little confused as to what I need to do here. Why does it compile

but
not build?


Look up "extern C". If that doesn't help, try creating
a small example that produces the problem and post it here
(standard code only, please).

-Mike

Jul 22 '05 #7

P: n/a
As I replied to Mr. Wahler, doing this fixed things right up for me. Thanks!
:)

-Sheppe

"David Harmon" <so****@netcom.com.invalid> wrote in message
news:41**************@news.east.earthlink.net...
On Tue, 24 Aug 2004 18:08:50 GMT in comp.lang.c++, "Noone"
<no***@nowhere.com> wrote,
just compiled with no errors. The errors read "undefined reference to
function_name_here(param1*, param2)". The errors are produced on each linethat makes a call to a function in the C file.


Are you sure that you declared the function with
extern "C"
in the C++ part?

This issue is covered in Marshall Cline's C++ FAQ. See section
"[32] How to mix C and C++" It is always good to check the FAQ before
posting. You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/

Jul 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.