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

Novice Linker Errors

I'm relatively new to C++, and so when I ran across these linker
errors, I really didn't know how to fix them. I did a groups.google
search, and found plenty of issues with parameterized classes, or
using the wrong compiler, or a variety of other things that don't
apply to my problem. So, if anyone could help me out, that'd be
great.

DummyTester.cpp:
#include "DummyClass.h";
#include "CommunicatorImplementation.h";

int main(){
CommunicatorImplementation comm_imp;
Communicator * util = util_imp.Clone();
DummyClass dc(*util);
return 0;
}

When I run:
$g++ -I../src/ -I../../utils/src DummyTester.cpp

I get:
/tmp/ccxLnKku.o(.text+0x19): In function `main':
: undefined reference to
`CommunicatorImplementation::CommunicatorImplement ation[in-charge]()'
/tmp/ccxLnKku.o(.text+0x3d): In function `main':
: undefined reference to
`DummyClass::DummyClass[in-charge](Communicator const&)'
/tmp/ccxLnKku.o(.text+0x4c): In function `main':
: undefined reference to
`CommunicatorImplementation::~CommunicatorImplemen tation
[in-charge]()'
/tmp/ccxLnKku.o(.text+0x63): In function `main':
: undefined reference to
`CommunicatorImplementation::~CommunicatorImplemen tation
[in-charge]()'
/tmp/ccxLnKku.o(.gnu.linkonce.t._ZNK17CommunicatorImple mentation5CloneEv+0x24):
In function `CommunicatorImplementation::Clone() const':
: undefined reference to
`CommunicatorImplementation::CommunicatorImplement ation[in-charge](CommunicatorImplementation
const&)'
collect2: ld returned 1 exit status

DummyClass, Communicator, and CommunicatorImplementation are
pre-established (and non-parameterized) modules and (in theory) should
not need any alteration. What do I need to change in my code or in
the way I run the compiler/linker that will make this program link?

Thanks in advance!

Joe
Jul 22 '05 #1
2 1534
On 13 Jul 2004 09:19:28 -0700, GammaJoe <ga******@hotmail.com> wrote:
I'm relatively new to C++, and so when I ran across these linker
errors, I really didn't know how to fix them. I did a groups.google
search, and found plenty of issues with parameterized classes, or
using the wrong compiler, or a variety of other things that don't
apply to my problem. So, if anyone could help me out, that'd be
great.

DummyTester.cpp:
#include "DummyClass.h";
#include "CommunicatorImplementation.h";
int main(){
CommunicatorImplementation comm_imp;
Communicator * util = util_imp.Clone();
DummyClass dc(*util);
return 0;
}

When I run:
$g++ -I../src/ -I../../utils/src DummyTester.cpp

I get:
/tmp/ccxLnKku.o(.text+0x19): In function `main':
: undefined reference to
`CommunicatorImplementation::CommunicatorImplement ation[in-charge]()'
/tmp/ccxLnKku.o(.text+0x3d): In function `main':
: undefined reference to
`DummyClass::DummyClass[in-charge](Communicator const&)'
/tmp/ccxLnKku.o(.text+0x4c): In function `main':
: undefined reference to
`CommunicatorImplementation::~CommunicatorImplemen tation
[in-charge]()'
/tmp/ccxLnKku.o(.text+0x63): In function `main':
: undefined reference to
`CommunicatorImplementation::~CommunicatorImplemen tation
[in-charge]()'
/tmp/ccxLnKku.o(.gnu.linkonce.t._ZNK17CommunicatorImple mentation5CloneEv+0x24):
In function `CommunicatorImplementation::Clone() const':
: undefined reference to
`CommunicatorImplementation::CommunicatorImplement ation[in-charge](CommunicatorImplementation
const&)'
collect2: ld returned 1 exit status

DummyClass, Communicator, and CommunicatorImplementation are
pre-established (and non-parameterized) modules and (in theory) should
not need any alteration. What do I need to change in my code or in
the way I run the compiler/linker that will make this program link?

Thanks in advance!

Joe


You need to link with the actual code that implements what is declared in
the header files. Header file on their own are not normally sufficient.

Do you have a CommunicatorImplementation.cpp or
CommunicatorImplementation.cc file?

john

Jul 22 '05 #2
AVR
John Harrison wrote:
On 13 Jul 2004 09:19:28 -0700, GammaJoe <ga******@hotmail.com> wrote:
I'm relatively new to C++, and so when I ran across these linker
errors, I really didn't know how to fix them. I did a groups.google
search, and found plenty of issues with parameterized classes, or
using the wrong compiler, or a variety of other things that don't
apply to my problem. So, if anyone could help me out, that'd be
great.

DummyTester.cpp:
#include "DummyClass.h";
#include "CommunicatorImplementation.h";
int main(){
CommunicatorImplementation comm_imp;
Communicator * util = util_imp.Clone();
DummyClass dc(*util);
return 0;
}

When I run:
$g++ -I../src/ -I../../utils/src DummyTester.cpp

I get:
/tmp/ccxLnKku.o(.text+0x19): In function `main':
: undefined reference to
`CommunicatorImplementation::CommunicatorImplement ation[in-charge]()'
/tmp/ccxLnKku.o(.text+0x3d): In function `main':
: undefined reference to
`DummyClass::DummyClass[in-charge](Communicator const&)'
/tmp/ccxLnKku.o(.text+0x4c): In function `main':
: undefined reference to
`CommunicatorImplementation::~CommunicatorImplemen tation
[in-charge]()'
/tmp/ccxLnKku.o(.text+0x63): In function `main':
: undefined reference to
`CommunicatorImplementation::~CommunicatorImplemen tation
[in-charge]()'
/tmp/ccxLnKku.o(.gnu.linkonce.t._ZNK17CommunicatorImple mentation5CloneEv+0x24):

In function `CommunicatorImplementation::Clone() const':
: undefined reference to
`CommunicatorImplementation::CommunicatorImplement ation[in-charge](CommunicatorImplementation

const&)'
collect2: ld returned 1 exit status

DummyClass, Communicator, and CommunicatorImplementation are
pre-established (and non-parameterized) modules and (in theory) should
not need any alteration. What do I need to change in my code or in
the way I run the compiler/linker that will make this program link?

Thanks in advance!

Joe

You need to link with the actual code that implements what is declared
in the header files. Header file on their own are not normally sufficient.

Do you have a CommunicatorImplementation.cpp or
CommunicatorImplementation.cc file?

john


I'm pretty new myself, but I've chewed over this one before.
You could either include the all the .cpp files in your compile command as :
$g++ -I../src/ -I../../utils/src DummyTester.cpp \
<whatever>/CommunicatorImplementation.cpp <whatever>/DummyClass.cpp

Or you could compile the .cpp files without linking them using the -c
flag of g++ as:

$g++ -I../src/ -I../../utils/src -c \
<whatever>/CommunicatorImplementation.cpp -o \
CommunicatorImplementation.o

//similarly for DummyClass

and finally link all these along with the driver file as:

$g++ -I../src/ -I../../utils/src -c \
DummyTester.cpp CommunicatorImplementation.o ...

This is the approach used in makefiles.

HTH,
--AVR
Jul 22 '05 #3

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

Similar topics

0
by: TGF | last post by:
Hello, I am creating a console app. I try to link a static library by including it in the Linker-Input-Additional Dependencies field under the Project properties. Then I specify the path to...
0
by: TGF | last post by:
Hello, I am creating a console app. I try to link a static library by including it in the Linker-Input-Additional Dependencies field under the Project properties. Then I specify the path to...
0
by: Tom McDermott | last post by:
I am having linker errors : error LNK2022: metadata operation failed (80131188) : Inconsistent field declarations in duplicated types This code linked sucessfully in C++.NET 2002, but does...
4
by: Saran | last post by:
Hi All, I'm getting the following linker error when I try to build a library. nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv nafxcw.lib(appcore.obj) : error...
3
by: ralphsieminsky | last post by:
A project compiles fine under VS 2005 RC without the /clr option. However, when /clr is turned on several errors appear: - A symbol exported from a DLL is not found by another DLL referencing...
0
by: VivekR | last post by:
I have a MFC application developed using VC++ 5. Recently I ported that to VC++ 7.1 and now I am trying to compile the MFC application with /CLR under VC++ 7.1. And I get linker errors referring to...
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
2
by: Oneironaut | last post by:
Hello friends, I have an issue with a linker warning. It is the warning LNK4089. I am working in MSVC6.0 I investigated and this warning tells that the import of the library to which it makes...
2
by: Markus Dehmann | last post by:
What to do if an external library is header-files-only (but you have to use it), and you get lots of linker errors? You will necessarily get linker errors "multiple definition of ..." if you try...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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?
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
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.