Project configuration - flex dependency
-
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. -
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: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.
-
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.
-
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.
@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. -
@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.@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). -
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
orgeos_c
in$ENV{LIB_DIR}/lib
or$ENV{LIB}
So again, you have to configure your environment bey either setting
LIB_DIR
environment variable to the GEOS installation directory, or settingINCLUDE
andLIB
environment variables to the appropriate paths. That is, modifyINCLUDE
so the directory wheregeos_c.h
is listed, and modifyLIB
so it lists the path wheregeos_c.lib
is found. -
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.