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. Project configuration - flex dependency
QtWS25 Last Chance

Project configuration - flex dependency

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 1.5k Views
  • 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.
  • S Offline
    S Offline
    Simplexity
    wrote on last edited by
    #1

    I am attempting to build qgis source code, cloned from git, using QtCreator 7.0.2 on a windows 10 machine. The source tree has a CMakeLists.txt file which specifies a number of dependencies, however when QtCreator parses the project is throws 3 errors, including "Could NOT find FLEX (missing: FLEX_EXECUTABLE)....". The qgis documentation tells me I need flex >= 2.5.6. I have downloaded what I believe to be an ok version of flex (2.5.6) and have an executable called win_flex.exe.

    I am guessing I either/and/or need to:
    Tell QtCreator the name of the flex executable, tell QtCreator where to find flex, or easier, change the name of win-flex.exe and put it in the right place. But I do not know how to do this.

    1 Reply Last reply
    0
    • kkoehneK Offline
      kkoehneK Offline
      kkoehne
      Moderators
      wrote on last edited by kkoehne
      #2

      Tell QtCreator the name of the flex executable, tell QtCreator where to find flex, or easier, change the name of
      win-flex.exe and put it in the right place. But I do not know how to do this.

      qgis uses following line to find flex, in CMakeLists.txt:

      find_package(FLEX 2.6 REQUIRED)
      

      The logic for FLEX is actually implemented in CMake itself, and by grepping in cmake sources, it seems to be able to handle win-flex.exe just fine:

      Modules/FindFLEX.cmake:

      find_program(FLEX_EXECUTABLE NAMES flex win-flex win_flex DOC "path to the flex executable")
      

      So, it should be able to find a win-flex executable, if it is in PATH, or in one of the many other places CMake uses for find_program().

      Please make sure that your win-flex.exe is in the PATH of your build environment, see e.g. https://doc.qt.io/qtcreator/creator-project-settings-environment.html. Alternatively, you can also manually configure FLEX_EXECUTABLE CMake cache variable to point to your win-flex.exe.

      Director R&D, The Qt Company

      1 Reply Last reply
      3
      • S Offline
        S Offline
        Simplexity
        wrote on last edited by
        #3

        Many thanks. I have been developing with Qt on linux for a while so Windows is a bit new for me and I forgot that "Path" is a Windows system environment variable that can be set in Windows Control Panel.

        I added the path to also point to my downloaded win_flex.exe, and restarted Qt. Now it finds win_flex.exe, but I have too low a version 2.5.x, less than the required 2.6.

        The only compiled versions of flex for windows I could find were less than 2.6.

        So I cloned the source code for flex from git/lexxmark/winflexbison, then loaded this as a project into QtCreator, it parsed the tree fine, but told me I could only build using MVS, it seems.

        So I guess I must now setup an MVS environment and compile the latest version of Flex myself, unless someone knows where I can find a win_flex.exe version 2.6 or higher.

        S 1 Reply Last reply
        0
        • S Simplexity

          Many thanks. I have been developing with Qt on linux for a while so Windows is a bit new for me and I forgot that "Path" is a Windows system environment variable that can be set in Windows Control Panel.

          I added the path to also point to my downloaded win_flex.exe, and restarted Qt. Now it finds win_flex.exe, but I have too low a version 2.5.x, less than the required 2.6.

          The only compiled versions of flex for windows I could find were less than 2.6.

          So I cloned the source code for flex from git/lexxmark/winflexbison, then loaded this as a project into QtCreator, it parsed the tree fine, but told me I could only build using MVS, it seems.

          So I guess I must now setup an MVS environment and compile the latest version of Flex myself, unless someone knows where I can find a win_flex.exe version 2.6 or higher.

          S Offline
          S Offline
          Simplexity
          wrote on last edited by
          #4

          @Simplexity
          I installed MVS community, cloned the source for flex and bison from git, built new .exe's and now Qt doesn't complain about them. Now onto sorting the GEOS dependency.

          S 1 Reply Last reply
          0
          • S Simplexity

            @Simplexity
            I installed MVS community, cloned the source for flex and bison from git, built new .exe's and now Qt doesn't complain about them. Now onto sorting the GEOS dependency.

            S Offline
            S Offline
            Simplexity
            wrote on last edited by
            #5

            @Simplexity
            Qgis needs GEOS >= 3.4. I downloaded a geos repositiry and built is with MVS, the executable is called , geosop.exe, the build also produces geos.dll and geos_c.dll. I placed these into the same folder as flex, so that Qt could find them. Now I get the QtCreator error:
            Could not find GEOS CMakeLists.txt:355 (find_package).

            1 Reply Last reply
            0
            • kkoehneK Offline
              kkoehneK Offline
              kkoehne
              Moderators
              wrote on last edited by kkoehne
              #6

              I installed MVS community, cloned the source for flex and bison from git, built new .exe's and now Qt doesn't complain about them. Now onto sorting the GEOS dependency.

              Great! Qt btw provides also some pre-built flex.exe as part of https://download.qt.io/development_releases/gnuwin32/gnuwin32.zip.

              Could not find GEOS CMakeLists.txt:355 (find_package).

              For find_package, CMake (again) has quite some convoluted logic in how things are looked up.

              Anyway, for GEOS, it seems the logic is actually implemented in QGIS, see cmake/FindGEOS.cmake. You can see that, for MSVC, it expects

              • geos_c.h in $ENV{LIB_DIR}/include, or $ENV{INCLUDE}
              • geos_c_i or geos_c in $ENV{LIB_DIR}/lib or $ENV{LIB}

              So again, you have to configure your environment bey either setting LIB_DIRenvironment variable to the GEOS installation directory, or setting INCLUDE and LIB environment variables to the appropriate paths. That is, modify INCLUDE so the directory where geos_c.h is listed, and modify LIB so it lists the path where geos_c.lib is found.

              Director R&D, The Qt Company

              1 Reply Last reply
              1
              • S Offline
                S Offline
                Simplexity
                wrote on last edited by
                #7

                Thanks again.

                GEOS. I put the header and exe files in the same directory that I pointed my path variable to for FLEX and BISON, and this worked.

                I now realise this is a lesson in understanding what CMake does and how to interpret the CMakeLists.txt and other associated CMake files. QGIS has a lot of dependencies and now dependencies of dependecies it seems. Next one to tackle is GDAL.

                So, CMakeLists.txt for GDAL tells CMake to read the FindGDAL.cmake file in the cmake directory?

                When I read FindGDAL.cmake it indicates that I need gdal or gdal_i (I assume this is an .exe or a .dll?) and gdal.h. And to put them in the required directories e.g. GDAL_INCLUDE_DIR for the .h file?

                GDAL.h can be got from a GitHub clone, but it seems I also now need to build gdal.

                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