vsg-dev / vsgXchange

Utility library for converting data+materials to/from VulkanSceneGraph
MIT License
65 stars 39 forks source link

Undefined Reference linker error for vsgconv #199

Open robspearman opened 2 weeks ago

robspearman commented 2 weeks ago

I am trying to build the v1.1.3 tag linking with vsg v1.1.7 tag on Linux. Getting this linker error;

/usr/bin/c++ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DNDEBUG -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld CMakeFiles/vsgconv.dir/vsgconv.cpp.o -o ../../bin/vsgconv  -Wl,-rpath,/home/engineer/rpmbuild/BUILD/vsgXchange-1.1.3/lib: ../../lib/libvsgXchange.so.1.1.3 /usr/lib64/libvsg.so.1.1.7 /lib64/libvulkan.so -lpthread 
CMakeFiles/vsgconv.dir/vsgconv.cpp.o:(.data.rel.ro._ZTVN7vsgconv19CollectReadRequestsE[_ZTVN7vsgconv19CollectReadRequestsE]+0x748): undefined reference to `vsg::Visitor::apply(vsg::AnimationPath&)'
../../lib/libvsgXchange.so.1.1.3: undefined reference to `vsg::Object::Object(vsg::Object const&)'
collect2: error: ld returned 1 exit status
robertosfield commented 2 weeks ago

How are you going about building the VSG/vsgXchange? Using CMake or using your own build tools? What options are you using for build? I see a .so so this looks like you are building shared libraries.

FYI, my main development environment is Kubuntu 22.04, but I also have Kubuntu 24.04 and Windows 11 that I can build against.

robspearman commented 2 weeks ago

I am just using cmake and tried with no options or -DBUILD_SHARED_LIBS=ON.

robertosfield commented 2 weeks ago

I've just kicked off a shared libs build on my Kubuntu 22.04 system. I'm using a development branch of VSG right now, if that works fine I'll check out 1.1.7.

What compiler do you have on your system?

This is what I'm presently building the VSG one:

$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

As a test could you try a static build of the VSG, vsgXchange etc?

robspearman commented 2 weeks ago

gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22)

A static VSG build does not change the error.

robertosfield commented 2 weeks ago

I just tried my Kubuntu 24.04 system with VSG v.1.1.7 and vsgXchange v.1.1.3 and it builds cleanly:

$ gcc --version
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So I guess there might be an issue with older compilers compatibility with modern C++17.

robspearman commented 2 weeks ago

OK, I'll see what else I can determine on my end.

robertosfield commented 2 weeks ago

Looking at your original link error:

/usr/bin/c++ -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DNDEBUG -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld CMakeFiles/vsgconv.dir/vsgconv.cpp.o -o ../../bin/vsgconv  -Wl,-rpath,/home/engineer/rpmbuild/BUILD/vsgXchange-1.1.3/lib: ../../lib/libvsgXchange.so.1.1.3 /usr/lib64/libvsg.so.1.1.7 /lib64/libvulkan.so -lpthread 
CMakeFiles/vsgconv.dir/vsgconv.cpp.o:(.data.rel.ro._ZTVN7vsgconv19CollectReadRequestsE[_ZTVN7vsgconv19CollectReadRequestsE]+0x748): undefined reference to `vsg::Visitor::apply(vsg::AnimationPath&)'
../../lib/libvsgXchange.so.1.1.3: undefined reference to `vsg::Object::Object(vsg::Object const&)'
collect2: error: ld returned 1 exit status

It looks like vsgXchange is trying to build against VSG headers that define '''vsg::Object::Object(vsg::Object const&)''' but in VSG-1.1.7 the definition is '''Object(const Object& object, const CopyOp& copyop = {});'''

The code is: https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/core/Object.h#L64

My best guess on what might cause this would be having an older version of the VSG installed on your system with it's headers being picked up by vsgXchange. If it's not this then there is something odd going on with the compiler.

robspearman commented 2 weeks ago

I can confirm I had missed an old header version and problem is resolved. Thanks for the assistance!