Strange linking behaviour

  • Thread starter Filimon Roukoutakis
  • Start date
F

Filimon Roukoutakis

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
 
G

gw7rib

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.
 
F

Filimon Roukoutakis

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

filimon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top