osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

Latest master branch code Compile error with cesium-native v0.31.0

Open shiner-chen opened this issue 5 months ago • 1 comments

Describe the bug In Ubuntu 22.04.3 aarch64 os, the latest master code compile error with cesium-native v0.31.0.

Consolidate compiler generated dependencies of target application_osgearth_imgui
[ 80%] Linking CXX executable ../../../bin/osgearth_imgui
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `tinyxml2::XMLNode::NextSiblingElement(char const*) const'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `tinyxml2::XMLDocument::Parse(char const*, unsigned long)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `Cesium3DTilesReader::SubtreeFileReader::load(CesiumAsync::AsyncSystem const&, std::shared_ptr<CesiumAsync::IAssetAccessor> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&) const'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `tinyxml2::XMLElement::Attribute(char const*, char const*) const'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeospatial::BoundingRegionBuilder::setPoleTolerance(double)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeospatial::BoundingRegionBuilder::expandToIncludePosition(CesiumGeospatial::Cartographic const&)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `tinyxml2::XMLElement::GetText() const'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeometry::Transforms::Z_UP_TO_Y_UP'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeometry::Transforms::X_UP_TO_Z_UP'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeospatial::BoundingRegionBuilder::toRegion() const'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `tinyxml2::XMLDocument::XMLDocument(bool, tinyxml2::Whitespace)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `Cesium3DTilesSelection::ViewState::create(glm::vec<3, double, (glm::qualifier)0> const&, glm::vec<3, double, (glm::qualifier)0> const&, glm::vec<3, double, (glm::qualifier)0> const&, glm::vec<2, double, (glm::qualifier)0> const&, double, double, CesiumGeospatial::Ellipsoid const&)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGltfContent::GltfUtilities::applyRtcCenter(CesiumGltf::Model const&, glm::mat<4, 4, double, (glm::qualifier)0> const&)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeometry::QuadtreeTileID::computeInvertedY(CesiumGeometry::QuadtreeTilingScheme const&) const'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeometry::Transforms::Y_UP_TO_Z_UP'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumUtility::JsonValue::getValuePtrForKey(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `tinyxml2::XMLNode::FirstChildElement(char const*) const'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGltf::convertPropertyComponentTypeToString[abi:cxx11](CesiumGltf::PropertyComponentType)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeometry::clipTriangleAtAxisAlignedThreshold(double, bool, int, int, int, double, double, double, std::vector<std::variant<int, CesiumGeometry::InterpolatedVertex>, std::allocator<std::variant<int, CesiumGeometry::InterpolatedVertex> > >&)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `Cesium3DTilesReader::SubtreeFileReader::SubtreeFileReader()'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGltfContent::GltfUtilities::applyGltfUpAxisTransform(CesiumGltf::Model const&, glm::mat<4, 4, double, (glm::qualifier)0> const&)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGeospatial::BoundingRegionBuilder::BoundingRegionBuilder()'
collect2: error: ld returned 1 exit status
make[2]: *** [src/applications/osgearth_imgui/CMakeFiles/application_osgearth_imgui.dir/build.make:223: bin/osgearth_imgui] Error 1
make[1]: *** [CMakeFiles/Makefile2:2104: src/applications/osgearth_imgui/CMakeFiles/application_osgearth_imgui.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
chenx@chenx-rk3588:~/osgearth/build$ grep NextSiblingElement /usr/local/lib
lib/   lib64/
chenx@chenx-rk3588:~/osgearth/build$ grep NextSiblingElement /usr/local/lib/
cmake/                       libCesiumGltfContent.a       libmeshoptimizer.a           libosgFX.so                  libosgParticle.so.3.7.0      libosg.so.202                libosgUtil.so                libosgWidget.so.3.7.0        libwebpdecoder.a
libasync++.a                 libCesiumGltfReader.a        libmodp_b64.a                libosgFX.so.202              libosgPresentation.so        libosg.so.3.7.0              libosgUtil.so.202            libs2geometry.a              libz.a
libCesium3DTiles.a           libCesiumGltfWriter.a        libOpenThreads.so            libosgFX.so.3.7.0            libosgPresentation.so.202    libosgTerrain.so             libosgUtil.so.3.7.0          libspdlog.a                  osgPlugins-3.7.0/
libCesium3DTilesContent.a    libCesiumIonClient.a         libOpenThreads.so.21         libosgGA.so                  libosgPresentation.so.3.7.0  libosgTerrain.so.202         libosgViewer.so              libsqlite3.a                 pkgconfig/
libCesium3DTilesReader.a     libCesiumJsonReader.a        libOpenThreads.so.3.3.1      libosgGA.so.202              libosgShadow.so              libosgTerrain.so.3.7.0       libosgViewer.so.202          libsqlite3.la                python3.10/
libCesium3DTilesSelection.a  libCesiumJsonWriter.a        libosgAnimation.so           libosgGA.so.3.7.0            libosgShadow.so.202          libosgText.so                libosgViewer.so.3.7.0        libsqlite3.so
libCesium3DTilesWriter.a     libCesiumRasterOverlays.a    libosgAnimation.so.202       libosgManipulator.so         libosgShadow.so.3.7.0        libosgText.so.202            libosgVolume.so              libsqlite3.so.0
libCesiumAsync.a             libCesiumUtility.a           libosgAnimation.so.3.7.0     libosgManipulator.so.202     libosgSim.so                 libosgText.so.3.7.0          libosgVolume.so.202          libsqlite3.so.0.8.6
libCesiumGeometry.a          libcsprng.a                  libosgDB.so                  libosgManipulator.so.3.7.0   libosgSim.so.202             libosgUI.so                  libosgVolume.so.3.7.0        libtinyxml2.a
libCesiumGeospatial.a        libdraco.a                   libosgDB.so.202              libosgParticle.so            libosgSim.so.3.7.0           libosgUI.so.202              libosgWidget.so              libturbojpeg.a
libCesiumGltf.a              libktx_read.a                libosgDB.so.3.7.0            libosgParticle.so.202        libosg.so                    libosgUI.so.3.7.0            libosgWidget.so.202          liburiparser.a
chenx@chenx-rk3588:~/osgearth/build$ grep NextSiblingElement /usr/local/lib/libt
libtinyxml2.a   libturbojpeg.a
chenx@chenx-rk3588:~/osgearth/build$ grep NextSiblingElement /usr/local/lib/ -rn
grep: /usr/local/lib/libCesiumRasterOverlays.a: binary file matches
grep: /usr/local/lib/libtinyxml2.a: binary file matches

To Reproduce Steps to reproduce the behavior:

  1. Build the cesium-native git clone https://github.com/CesiumGS/cesium-native.git --recurse-submodules git checkout v0.31.0 cmake -B build -S . cmake --build build --config RelWithDebInfo -j 8 sudo cmake --install build

  2. build and install the OpenSceneGraph

  3. Build osgearth git clone --recurse-submodules https://github.com/gwaldron/osgearth.git osgearth cd osgearth/ mkdir build cd build/ cmake -DCESIUM_NATIVE_DIR=/usr/local -DOSGEARTH_BUILD_CESIUM_NODEKIT=ON ..

Expected behavior should build successfully.

Screenshots compile failled, the log, please see above.

Desktop (please complete the following information):

  • OS: Ubuntu 22.04.3 Aarch64
  • Version master branch + cesium-native v0.31.0

shiner-chen avatar Jan 25 '24 07:01 shiner-chen

This is also reproducible with cesium-native v0.30.0 & v0.32.0, from the latest osgEarth master back to commit c4ca2a4ea48a85a69135b4ea9ae80b937ba56d49

Using cesium-native v0.29.0 and prior fail to compile with error: unknown target 'osgEarthCesium'. osgEarth prior to c4ca2a4ea48a85a69135b4ea9ae80b937ba56d49 fails with error: use of undeclared identifier 'GL_R'.

It seems there is no combination of versions currently which will build the cesium-native node kit on Linux.

Would it be possible to enable the cesium node kit for CI builds?

TheTastefulToastie avatar Feb 02 '24 04:02 TheTastefulToastie

@jasonbeverage how to fix this build issue, I tried some method, but still failed :(

shiner-chen avatar Mar 07 '24 09:03 shiner-chen

when I build the cesium-native with command: cmake -DCMAKE_INSTALL_PREFIX=/opt/cesium-native -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_C_FLAGS="-fPIC" -DBUILD_SHARED_LIBS=ON -DCESIUM_TESTS_ENABLED=OFF .., and then compiled the osgearth, get the error as below.

[ 80%] Linking CXX executable ../../../bin/osgearth_imgui
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumAsync::CesiumImpl::QueuedScheduler::schedule(async::task_run_handle)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumAsync::CesiumImpl::TaskScheduler::schedule(async::task_run_handle)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `Cesium3DTilesSelection::ViewState::create(glm::vec<3, double, (glm::qualifier)0> const&, glm::vec<3, double, (glm::qualifier)0> const&, glm::vec<3, double, (glm::qualifier)0> const&, glm::vec<2, double, (glm::qualifier)0> const&, double, double, CesiumGeospatial::Ellipsoid const&)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGltfContent::GltfUtilities::applyRtcCenter(CesiumGltf::Model const&, glm::mat<4, 4, double, (glm::qualifier)0> const&)'
/usr/bin/ld: ../../../lib/libosgEarthCesium.so.3.5.0: undefined reference to `CesiumGltfContent::GltfUtilities::applyGltfUpAxisTransform(CesiumGltf::Model const&, glm::mat<4, 4, double, (glm::qualifier)0> const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [src/applications/osgearth_imgui/CMakeFiles/application_osgearth_imgui.dir/build.make:223: bin/osgearth_imgui] Error 1
make[1]: *** [CMakeFiles/Makefile2:1998: src/applications/osgearth_imgui/CMakeFiles/application_osgearth_imgui.dir/all] Error 2
make: *** [Makefile:136: all] Error 2


shiner-chen avatar Mar 07 '24 09:03 shiner-chen

Thanks for the report. I've looked into this and pushed a fix to the master in 49f989ccedfd6cd6e9d78337c97e628334b397f6. It was an issue with the order of static libraries being very particular on linux as well as having to ensure that the same GLM preprocessor definitions were defined in osgEarthCesium as what was used in cesium-native.

I also found that instead of specifying -fPIC as a CMAKE_CXX_FLAGS you can define -DCMAKE_POSITION_INDEPENDENT_CODE=ON instead which I didn't realize.

I haven't tried running it on Linux yet, just getting it built. Let us know if it works for you!

jasonbeverage avatar Mar 14 '24 21:03 jasonbeverage

@shiner-chen have you managed to build osgearth with cesium native support? in the end, which were the tags that you built using which build flags? I'm encountering similar fPIC - related problems.

Thanks you!

rebmaso avatar Mar 29 '24 10:03 rebmaso

Try the master, it should be ok now. Make sure you build cesium-native by passing in the -DCMAKE_POSITION_INDEPENDENT_CODE=ON setting when you run cmake configure.

jasonbeverage avatar Mar 29 '24 15:03 jasonbeverage