Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT5 Compilation - catastrophic error
Forum Updated to NodeBB v4.3 + New Features

QT5 Compilation - catastrophic error

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 15.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rrr2
    wrote on last edited by
    #1

    A similar question was asked in the post "Qt5 Compilation - global.h" , with a twist. I believe that I am not using
    -reduce-relocations.

    I have compiled qt5 using the steps from " Building qt5 with git". I am using Debian Linux with gcc , cmake-2.8.11.
    The steps I followed are shown below. There are no errors when compiling or installing. But I get the following message when I try to compile within Creator. I get the same error with Creator 2.7 and 2.8. As a test I am using example problems that are installed with Qt5. Is -reduce-relocations being built even though I am not specifying it in the build process?

    Build steps
    git clone git://gitorious.org/qt/qt5.git qt5
    cd qt5
    perl init-repository --no-webkit
    ./configure -prefix /opt/local/Qt-5.1.1 -developer-build -opensource -nomake tests
    make
    make install

    ERROR MESSAGE
    /opt/local/qt/Qt-5.1.1/include/QtCore/qglobal.h:975: catastrophic error: #error directive: "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC or -fPIE."

    error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      When you run configure, the script prints out all the options and settings it is using. Could be good to read that list (just pipe it to a file or grep for relocations).

      Otherwise, you can indeed try building with -fPIC or PIE :) You can add compile flags in Qt Creator's project options, or in .pro file (I don't know about cmake, but they must have an option for that, too).

      (Z(:^

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Guigui
        wrote on last edited by
        #3

        If you are using CMake: SET (CMAKE_CXX_FLAGS "-fPIC")

        I put this line in the root CMakeList.txt file of my project.

        This problem does remind me of something. Yet, all examples compile just fine without the use of additional options with qmake...

        1 Reply Last reply
        0
        • T Offline
          T Offline
          th.thielemann
          wrote on last edited by
          #4

          I had this error after I removed Qt5Widgets_INCLUDE_DIRS from the list of include_directories.
          But widgets were not link to target!.

          @find_package(Qt5Core REQUIRED)
          find_package(Qt5Widgets REQUIRED)
          find_package(Qt5Sql REQUIRED)
          find_package(Qt5Test REQUIRED)

          include_directories(
          ${Qt5Core_INCLUDE_DIRS}
          #${Qt5Widgets_INCLUDE_DIRS} # After I comment this line out, the error happens.
          ${Qt5Sql_INCLUDE_DIRS}
          ${Qt5Test_INCLUDE_DIRS}
          )

          add_executable(${TARGET_NAME} $<TARGET_OBJECTS:objlib${TARGET_NAME}> main.cpp)
          qt5_use_modules(${TARGET_NAME} Sql) @

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kicer86
            wrote on last edited by
            #5

            [quote author="Guigui" date="1371494219"]If you are using CMake: SET (CMAKE_CXX_FLAGS "-fPIC")

            I put this line in the root CMakeList.txt file of my project.

            This problem does remind me of something. Yet, all examples compile just fine without the use of additional options with qmake...[/quote]

            With this line in Your CMakeLists.txt you make your project compatible only with gnu compilers, which is not nice ;)

            EDIT:
            right way of doing it:
            SET (CMAKE_POSITION_INDEPENDENT_CODE ON)

            "here is and example":https://github.com/Cockatrice/Cockatrice/commit/9cfb09cd5b25a01fb142d425ba70b77b89f65a09

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kicer86
              wrote on last edited by
              #6

              [quote author="Guigui" date="1371494219"]If you are using CMake: SET (CMAKE_CXX_FLAGS "-fPIC")

              I put this line in the root CMakeList.txt file of my project.

              This problem does remind me of something. Yet, all examples compile just fine without the use of additional options with qmake...[/quote]

              With this line in Your CMakeLists.txt you make your project compatible only with gnu compilers, which is not nice ;)

              EDIT:
              right way of doing it:
              SET (CMAKE_POSITION_INDEPENDENT_CODE ON)

              "here is and example":https://github.com/Cockatrice/Cockatrice/commit/9cfb09cd5b25a01fb142d425ba70b77b89f65a09

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved