sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Filimon Roukoutakis's Avatar

Strange linking behaviour


Question posted by: Filimon Roukoutakis (Guest) on February 3rd, 2007 04:25 PM
Dear all,

I have a MyClass.h file with declarations and MyClass.cxx file with
definitions. From this I create a library libMyLib.a, containing
properly the MyClass.o object. When I try to link with MyExec.o,
containing the main function, I get an undefined reference for a MyClass
member function which can be eliminated if I move the definition from
the MyClass.cpp file to the MyClass.h file. What could be the cause of
this? Thanks,

filimon
2 Answers Posted
gw7rib@aol.com's Avatar
Guest - n/a Posts
#2: Re: Strange linking behaviour

On 3 Feb, 16:17, Filimon Roukoutakis <fili...@phys.uoa.grwrote:
Quote:
Originally Posted by
Dear all,
>
I have a MyClass.h file with declarations and MyClass.cxx file with
definitions. From this I create a library libMyLib.a, containing
properly the MyClass.o object. When I try to link with MyExec.o,
containing the main function, I get an undefined reference for a MyClass
member function which can be eliminated if I move the definition from
the MyClass.cpp file to the MyClass.h file. What could be the cause of
this? Thanks,
>
filimon


Does it matter where in the .h file you move it to? I'm thinking
perhaps in one file you have it within a class, or a namespace, or an
extern "C", or the like, and when you move it you don't. Otherwise, I
think you are going to have to post some code - just whittle it down
to the the smallest length of file that goes wrong.

Paul.

Filimon Roukoutakis's Avatar
Filimon Roukoutakis February 3rd, 2007 07:55 PM
Guest - n/a Posts
#3: Re: Strange linking behaviour

Hi, the problem was related to KDevelop make configuration for building
libraries, it is fixed now. Thanks,

filimon

Join Bytes! wrote:
Quote:
Originally Posted by
On 3 Feb, 16:17, Filimon Roukoutakis <fili...@phys.uoa.grwrote:
Quote:
Originally Posted by
>Dear all,
>>
>I have a MyClass.h file with declarations and MyClass.cxx file with
>definitions. From this I create a library libMyLib.a, containing
>properly the MyClass.o object. When I try to link with MyExec.o,
>containing the main function, I get an undefined reference for a MyClass
>member function which can be eliminated if I move the definition from
>the MyClass.cpp file to the MyClass.h file. What could be the cause of
>this? Thanks,
>>
>filimon

>
Does it matter where in the .h file you move it to? I'm thinking
perhaps in one file you have it within a class, or a namespace, or an
extern "C", or the like, and when you move it you don't. Otherwise, I
think you are going to have to post some code - just whittle it down
to the the smallest length of file that goes wrong.
>
Paul.
>

 
Not the answer you were looking for? Post your question . . .
197,004 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,004 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors