This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: undefined reference error/g++-6


On 18 July 2017 at 09:33, sothy shan wrote:
> Hi,
> I am running g++-6 in UBuntu 16.04. I'm using open-source library to
> develop my application.
>
>
> In the third part library, there is only DTOR and no copy CTOR and
> copy assignment.
> So I created copy CTOR. The open source library is compiled.
>
> Now I am trying to compile my application. It gives error.
>
> g++-6 test2.cc -lfluid_msg -o test2 -g -fsanitize=address
> /tmp/ccEKzcOk.o: In function
> `fluid_msg::of10::PacketOut::PacketOut(fluid_msg::of10::PacketOut
> const&)':
> /usr/local/include/fluid/of10msg.hh:230: undefined reference to
> `fluid_msg::PacketOutCommon::PacketOutCommon(fluid_msg::PacketOutCommon
> const&)'
> collect2: error: ld returned 1 exit status
>
> I dont know why? When compiler creates automatically, it works. It
> means when I remove the copy CTOR, compilation goes well.
>
> I wish to know what is problem in linking? may be becasue of
> inheritance and copy CTOR.??  PacketOut is inherited from
> PacketOutCommon. I declare and defined copy CTOR in PacketOutCommon.

You say you defined it, but the linker says it is not found.

Where did you define it? Is it meant to be defined in libfluid_msg?
Did you rebuild that library?

We can't help you without more information, because this doesn't look
like a GCC problem. You just need to compile the definition and ensure
you link to it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]