I have been running into strange linking behavior with g++, however, I’m just a student, and I was wondering if this was normal.
I am trying to link assembly code (machine: fedora 14 gnome 32bits x86 i686 intel i7) with c++ code and to have the assembly code call a method from a fonction instanciated in the c++ file. It seems that implementing a method in the class declaration will prevent it from being put in the linker table unless it’s used at least once in the original source.
class A
{
public:
void showSUP() {
cout<<"sup";
}
};
After instanciating A, you will not be able to call _ZN1A7showSUPEv because it has not been put in the linking table:
call _ZN1A7showSUPEv
However, if you call A::showSUP() in the same .cpp as A was declared, then calling it from a seperate assembly file will work.
With (and instantiation of A)
class A
{
void showSUP();
};
A::showSUP()
{
cout<<"sup";
}
Calling _ZN1A7showSUPEv will work.
My question is, why doesn’t the first example work.
Thank you all in advance.
will only output code where the function is used.
inside the class definition are
inline (usually).
used.
binary.