Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlusLib build issues with StealthLink #957

Open
mkomaiha opened this issue Jun 12, 2022 · 8 comments
Open

PlusLib build issues with StealthLink #957

mkomaiha opened this issue Jun 12, 2022 · 8 comments

Comments

@mkomaiha
Copy link

mkomaiha commented Jun 12, 2022

Hi,

I am having issues using PlusBuild. I am using the following cmake settings:

cmake ../PlusBuild \
  -DSTEALTHLINK_ROOT_DIR=/StealthPyCLinkLibs \
  -DPLUS_USE_STEALTHLINK=ON \
  -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" \
  -DBUILD_TESTING=OFF \
  -DCMAKE_BUILD_TYPE=Debug

I get these errors:

/bin/ld: /home/mkomaiha/opt/PlusBuild-bin/bin/libvtkPlusDataCollection.so: undefined reference to `MNavStealthLink::StealthServer::StealthServer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/bin/ld: /home/mkomaiha/opt/PlusBuild-bin/bin/libvtkPlusDataCollection.so: undefined reference to `MNavStealthLink::Exam::getExamData(MNavStealthLink::StealthServer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, MNavStealthLink::Error&)'
/bin/ld: /home/mkomaiha/opt/PlusBuild-bin/bin/libvtkPlusDataCollection.so: undefined reference to `boost::system::system_category()'
/bin/ld: /home/mkomaiha/opt/PlusBuild-bin/bin/libvtkPlusDataCollection.so: undefined reference to `MNavStealthLink::StealthServer::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, MNavStealthLink::DataItem&, MNavStealthLink::DateTime&, MNavStealthLink::Error&)'
/bin/ld: /home/mkomaiha/opt/PlusBuild-bin/bin/libvtkPlusDataCollection.so: undefined reference to `boost::system::generic_category()'
collect2: error: ld returned 1 exit status
make[2]: *** [src/PlusDataCollection/CMakeFiles/PlusVersion.dir/build.make:291: /home/mkomaiha/opt/PlusBuild-bin/bin/PlusVersion] Error 1
make[1]: *** [CMakeFiles/Makefile2:1677: src/PlusDataCollection/CMakeFiles/PlusVersion.dir/all] Error 2

I think it has to do with "-D_GLIBCXX_USE_CXX11_ABI=0" not getting passed to the PlusLib cmake file. However, when I manually add it to the CXX flags in PlusLib-bin and try to make again I get different issues:

/bin/ld: CMakeFiles/EditSequenceFile.dir/Tools/EditSequenceFile.cxx.o: in function `MixTrackedFrameLists(vtkIGSIOTrackedFrameList*, std::vector<std::string, std::allocator<std::string> >)':
/home/mkomaiha/opt/PlusBuild-bin/PlusLib/src/PlusCommon/Tools/EditSequenceFile.cxx:147: undefined reference to `igsioTrackedFrame::GetCustomFields()'
...
/bin/ld: /home/mkomaiha/opt/PlusBuild-bin/bin/libvtkPlusCommon.so: undefined reference to `vtksys::SystemTools::GetCurrentDateTime(char const*)'
/bin/ld: /home/mkomaiha/opt/PlusBuild-bin/bin/libvtkPlusCommon.so: undefined reference to `vtksys::SystemTools::FileIsFullPath(std::string const&)'
/bin/ld: /home/mkomaiha/opt/PlusBuild-bin/bin/libvtkPlusCommon.so: undefined reference to `vtksys::SystemTools::GetCurrentWorkingDirectory(bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [src/PlusCommon/CMakeFiles/EditSequenceFile.dir/build.make:283: /home/mkomaiha/opt/PlusBuild-bin/bin/EditSequenceFile] Error 1
make[1]: *** [CMakeFiles/Makefile2:715: src/PlusCommon/CMakeFiles/EditSequenceFile.dir/all] Error 2

Any help would be much appreciated!

@mkomaiha
Copy link
Author

Update:

I was able to get rid of the undefined reference to 'MNavStealthLink::', but not the boost::system:: by replacing -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" with -DCMAKE_CXX_FLAGS_INIT="-D_GLIBCXX_USE_CXX11_ABI=0". I'm unsure if this is the correct way to do things, but seems to not error.

I think here the warning message should be more helpful to how to set the flag or it should actually do it for you
https://github.com/PlusToolkit/PlusBuild/blob/d3e43fb5fb6f4472437b0254c6955ec15a6765fd/CMakeLists.txt#L689-L691

Similar to how this portion sets the -fPIC flag
https://github.com/PlusToolkit/PlusBuild/blob/d3e43fb5fb6f4472437b0254c6955ec15a6765fd/CMakeLists.txt#L414-L417

The thought process is that the -D_GLIBCXX_USE_CXX11_ABI=0 is passed down to all of the inner cmake files. This gets close to fixing everything I think, but still errors because IGSIO/vtkAddon does not get passed this flag.

I am unsure why boost::system::generic_category() and system_category() are still unbound. I have the following files in my STEALTHLINK_INCLUDE_DIRS

libboost_date_time-mt.so.1.49.0
libboost_iostreams-mt.so.1.49.0
libboost_program_options-mt.so.1.49.0
libboost_serialization-mt.so.1.49.0
libboost_system-mt.so.1.49.0
libboost_filesystem-mt.so.1.49.0
libboost_locale-mt.so.1.49.0
libboost_regex-mt.so.1.49.0
libboost_signals-mt.so.1.49.0
libboost_thread-mt.so.1.49.0

@adamrankin
Copy link
Member

In cmake, did you set cxx standard to 98? @lassoan can you confirm which standards are ok for stealthlink?

@mkomaiha
Copy link
Author

In cmake, did you set cxx standard to 98? @lassoan can you confirm which standards are ok for stealthlink?

CXX 98 errors with ITK5.

CMake Error at CMakeLists.txt:40 (message):
  CMAKE_CXX_STANDARD:STRING=98 is not supported in ITK version 5 and greater.


-- Configuring incomplete, errors occurred!
make[2]: *** [CMakeFiles/itk.dir/build.make:91: itk-prefix/src/itk-stamp/itk-configure] Error 1
make[1]: *** [CMakeFiles/Makefile2:123: CMakeFiles/itk.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Setting PLUS_ITK_VERSION=4 causes:

[  0%] Built target ITKThresholding-all
In file included from /home/mkomaiha/opt/PlusBuild-bin/itk/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_iostream.h:5,
                 from /home/mkomaiha/opt/PlusBuild-bin/itk/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_deprecated.cxx:4:
/home/mkomaiha/opt/PlusBuild-bin/itk/Modules/ThirdParty/VNL/src/vxl/vcl/vcl_compiler.h:90:4: error: #error "Dunno about this gcc"
   90 | #  error "Dunno about this gcc"
      |    ^~~~~

@adamrankin
Copy link
Member

Yes, the stealthlink build is stuck to old versions of libraries, which may not support modern compilers. You may want to find the offending line in itk and bypass the build error.

@mkomaiha
Copy link
Author

After looking deeper into the issue I think it is also related to the following commit PlusToolkit/PlusBuild@aa04a25.

-DSTEALTHLINK_STEALTHLINK_SHARED_LIBRARY is no longer windows only, but it is not exported for non Win32 here:
https://github.com/PlusToolkit/PlusBuild/blob/d3e43fb5fb6f4472437b0254c6955ec15a6765fd/SuperBuild/External_PlusLib.cmake#L199-L211

The IF should instead look like this:

#PlusBuild/SuperBuild/External_PlusLib.cmake#L199
IF(PLUS_USE_STEALTHLINK)
  LIST(APPEND PLUSBUILD_ADDITIONAL_SDK_ARGS
    -DSTEALTHLINK_INCLUDE_DIRS:PATH=${STEALTHLINK_INCLUDE_DIRS}
    -DSTEALTHLINK_STEALTHLINK_STATIC_LIBRARY:PATH=${STEALTHLINK_STEALTHLINK_STATIC_LIBRARY}
    -DSTEALTHLINK_STEALTHLINK_SHARED_LIBRARY:PATH=${STEALTHLINK_STEALTHLINK_SHARED_LIBRARY}
    )
  IF(WIN32)
    LIST(APPEND PLUSBUILD_ADDITIONAL_SDK_ARGS
      -DSTEALTHLINK_STEAELTHLINKD_STATIC_LIBRARY:PATH=${STEALTHLINK_STEALTHLINKD_STATIC_LIBRARY}
      -DSTEALTHLINK_STEALTHLINKD_SHARED_LIBRARY:PATH=${STEALTHLINK_STEALTHLINKD_SHARED_LIBRARY}
    )
  ENDIF()
ENDIF()

Also, BOOST should be added as a dependency (maybe UNIX only?) and the ELSE statement should be before LIST(APPEND External_Libraries_Debug (https://github.com/PlusToolkit/PlusLib/blob/f3dcf47cab4fd1d04cee543163abf4974ef37626/src/PlusDataCollection/CMakeLists.txt)

#PlusLib/PlusDataCollection/CMakeLists.txt#L1420
FIND_PACKAGE(Boost COMPONENTS system REQUIRED)
LIST(APPEND ${PROJECT_NAME}_LIBS
  ${Boost_SYSTEM_LIBRARY}
  )

I am now using the updated External_PlusLib.cmake, PlusLib/PlusDataCollection/CMakeLists.txt, and the following cmake command for PlusBuild:

ccmake ../PlusBuild \
  -DSTEALTHLINK_ROOT_DIR=/home/mkomaiha/pymodules/stealthPyModule/StealthPyCLinkLibs \
  -DPLUS_USE_STEALTHLINK=ON \
  -DCMAKE_C_FLAGS_INIT="-D_GLIBCXX_USE_CXX11_ABI=0" \
  -DCMAKE_CXX_FLAGS_INIT="-D_GLIBCXX_USE_CXX11_ABI=0" \
  -DBUILD_TESTING=OFF \
  -DCMAKE_BUILD_TYPE=Release

It seems like the ep_common_cxx_flags is only passed one level down, but ep_common_args is always forwarded so I used that instead and moved it to be the last thing to be expanded in IGSIO/SuperBuild/External_vtkAddon.

#PlusBuild/CMakeLists.txt#L412
SET(ep_common_args -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} -DCMAKE_CXX_STANDARD_REQUIRED:BOOL=ON -Dep_common_args:STRING=-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0)

This doesn't seem like a great solution at least for an automated way maybe there is something better I can do here?

With this setup I can get StealthLink to build on Linux.

@lassoan
Copy link
Contributor

lassoan commented Jun 13, 2022

Thank you very much for working on this and sharing the solution. Would you mind creating a pull request with the final working version that contains all the suggested changes?

@mkomaiha
Copy link
Author

Yes, of course! They are pretty minimal changes.
image

image

However, I'm unsure how to forward the -D_GLIBCXX_USE_CXX11_ABI=0 to ISGIO/vtkAddon for a complete solution and if setting -D_GLIBCXX_USE_CXX11_ABI=0 should be automatic here https://github.com/PlusToolkit/PlusBuild/blob/d3e43fb5fb6f4472437b0254c6955ec15a6765fd/CMakeLists.txt#L689-L691. Potentially a new option like PLUS_BUILD_ABI=0 or something.

@adamrankin
Copy link
Member

@mkomaiha Was a pull request ever submitted to resolve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants