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
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.
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.
>
|
|
|
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.
Top Community Contributors
|