Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8353632

[Linux] Undefined reference to PlatformSupport::OBSERVED_SETTINGS with C++14

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • jfx25
    • jfx24
    • javafx
    • In Review

      When compiling the gtk glass library for Linux, using the OpenJDK build system, an error occurs when linking the objectfiles into libglass.so:

      `
      in function `PlatformSupport::PlatformSupport(JNIEnv_*, _jobject*)':
      PlatformSupport.cpp:90: undefined reference to `PlatformSupport::OBSERVED_SETTINGS'
      `

      My understanding is that this is related to different compiler assumptions and flags.
      The OpenJDK command for creating the library is:

      ```/usr/bin/g++ -Wl,-z,defs -Wl,-z,relro -Wl,-z,now -Wl,--no-as-needed -Wl,--exclude-libs,ALL -Wl,-z,noexecstack -Wl,-O1 -m64 -shared -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,--disable-new-dtags -Wl,-soname=libglassgtk3.so -o /home/johan/openjdk/github/jdk/build/jfx0326/support/modules_libs/javafx.graphics/libglassgtk3.so @/home/johan/openjdk/github/jdk/build/jfx0326/support/native/javafx.graphics/libglassgtk3/_BUILD_LIBGLASSGTK3_objectfilenames.txt -static-libstdc++ -static-libgcc -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgthread-2.0 -pthread -lXtst -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lX11 -ldl
      ```

      PlatformSupport.cpp itself is compiled with the following flags (excluding -I for brevity)
      ```
      /usr/bin/g++ -MMD -MF /home/johan/openjdk/github/jdk/build/jfx0326/support/native/javafx.graphics/libglassgtk3/PlatformSupport.d.tmp -fvisibility=hidden -pipe -fstack-protector -DLIBC=gnu -D_GNU_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DLINUX -DNDEBUG -fmacro-prefix-map=/home/johan/openjdk/github/jdk/= -std=c++14 -Wall -Wextra -Wformat=2 -Winvalid-pch -Wpointer-arith -Wreturn-type -Wsign-compare -Wtrampolines -Wtype-limits -Wundef -Wuninitialized -Wunused-const-variable=1 -Wunused-function -Wunused-result -Wunused-value -Woverloaded-virtual -Wreorder -m64 -D_LITTLE_ENDIAN -DARCH='"amd64"' -Damd64 -D_LP64=1 -fno-omit-frame-pointer -fno-lifetime-dse -fPIC -pthread -I.... -g -gdwarf-4 -fdebug-prefix-map=/home/johan/openjdk/github/jdk/= -fdebug-prefix-map=/usr/include/=/usr/include/ -fdebug-prefix-map=/usr/lib/gcc/x86_64-linux-gnu/13/include/=/usr/local/gcc_include/ -fdebug-prefix-map=/usr/include/c++/13/=/usr/local/gxx_include/ -fdebug-prefix-map=/home/johan/openjdk/github/jdk/build/jfx0326/= -Wno-unused-parameter -O3 -c -o /home/johan/openjdk/github/jdk/build/jfx0326/support/native/javafx.graphics/libglassgtk3/PlatformSupport.o /home/johan/openjfx/github/jfx/modules/javafx.graphics/src/main/native-glass/gtk/PlatformSupport.cpp -frandom-seed="PlatformSupport.cpp"
      ```

      An easy fix for this is to explicitly set the definition inside PlatformSupport.cpp itself:

      `constexpr const char* PlatformSupport::OBSERVED_SETTINGS[];`

            kcr Kevin Rushforth
            jvos Johan Vos
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: