This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: undefined reference error/g++-6
On Tue, Jul 18, 2017 at 2:30 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> 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.
Yes. I already included definition into the libfluid_msg and compiled
as seen below.
/////
PacketOutCommon(const PacketOutCommon &other);
PacketOutCommon& operator=(const PacketOutCommon &other);
When I compile the my application, it gives compilation error. When I
remove my changes, it works.
It means compiler generated works.
Based on the error, PacketOut researching for PacketOutCommon. Couldnt
find. That is why I am guess problem with compiler. Am I right?