473,608 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ noob - compiler question.

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_h ere(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
7 1348
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_h ere(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
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.d evelopment.* and gnu.g++.help for further
information.

V
Jul 22 '05 #3

"Noone" <no***@nowhere. com> wrote in message
news:SuLWc.2089 28$gE.115676@pd 7tw3no...
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_h ere(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
Thanks for the link. :)

-Sheppe

"Denis Remezov" <fi************ ***@yahoo.remov ethis.ca> wrote in message
news:41******** *******@yahoo.r emovethis.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_h ere(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
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
Awesome! That fixed me up. Thanks for the tip. :)

-Sheppe

"Mike Wahler" <mk******@mkwah ler.net> wrote in message
news:bI******** ***********@new sread1.news.pas .earthlink.net. ..

"Noone" <no***@nowhere. com> wrote in message
news:SuLWc.2089 28$gE.115676@pd 7tw3no...
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_h ere(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
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.eas t.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2106
by: Matt Hollingsworth | last post by:
Hello, Very new to python, so a noob question. When I've written stuff in JavaScript or MEL in the past, I've always adopted the variable naming convention of using a $ as the first character (no, I don't use perl, never have). Not possible in python. What are some good options that people commonly use so that they can easily and quickly identify variable with just a glance? When I was writing stuff in SoftImage XSI/JScript, many of...
14
8196
by: Olumide | last post by:
In the following C++ class, MyClass{ // Members } From which I create two objects (using the default constructor), (1) MyClass *object1 = new MyClass(); // Stack (2) MyClass object2 = MyClass(); // Stack or Heap?
8
2137
by: Ivan Shevanski | last post by:
Alright heres another noob question for everyone. Alright, say I have a menu like this. print "1. . .Start" print "2. . .End" choice1 = raw_input("> ") and then I had this to determine what option.
13
1550
by: cgough | last post by:
My true programming language is C++. I am at best a VB6 hacker that is just getting into VB.NET. I have a quick question about when to new and when not to new. Consider the following 2 classes. In the first I new an integer and assign it to i, in the second one I don't bother. In both cases, an integer is created and I can use it. If I try to use a Collection object without New, I get a NULL reference exception.
42
3424
by: Holger | last post by:
Hi guys Tried searching for a solution to this, but the error message is so generic, that I could not get any meaningfull results. Anyways - errormessage: ---------------------------------------------------- TypeError: addFile() takes exactly 1 argument (2 given) ----------------------------------------------------
14
1330
by: streamkid | last post by:
i'm a learning newbie at c++... and i have the following question... reading some source code, i saw this: int function(const void * one, const void * two) { int var1, var2; var1 = *((int*)one); var2 = *((int*)two); /* sm other code here*/ }
4
1209
by: jobs | last post by:
Three noob questions. Please help. 1. Is there a way to have arguments on subroutine that are optional? 2. Say I need to convert datetime to string..in this format : 2006-09-07 23:00:00.000
8
1253
by: azz131 | last post by:
Hi, i want to access an array of objects inside a method like this using System; using System.Collections.Generic; namespace ObjectArray { class MainClass{ class MyClass
7
3943
by: * Tong * | last post by:
Hi, I couldn't figure out how to properly type cast in this case: $ cat -n type_cast.c 1 #include <stdio.h> 2 3 typedef unsigned char Byte; 4 typedef signed char Small_Int; 5
0
8000
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,...
0
8330
tracyyun
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...
0
6815
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6011
isladogs
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...
0
3960
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...
0
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2474
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1328
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.