ellson / MOTHBALLED-graphviz

Moved to https://gitlab.com/graphviz/graphviz
Eclipse Public License 1.0
1.29k stars 256 forks source link

Trying to compile on windows: flex: can't open scan.c #1184

Closed chtenb closed 7 years ago

chtenb commented 7 years ago

I'm trying to build graphviz on windows, but I'm currently stuck with the following error. I installed bison and flex from gnu win 32 page on sourceforge (http://gnuwin32.sourceforge.net/), they're now available from the PATH.

When building the cgraph project from the graphviz.sln with Visual Studio 2015 or when using msbuild from gitbash, I get the error pasted below. Any idea what's going on?

Btw, I saw there is another graphviz.sln in the windows folder, but it seems out of date. Is that correct? Or is that the solution I should use? It's a bit confusing.

$ msbuild graphviz.sln //t:cgraph
Microsoft (R) Build Engine version 14.0.25123.0
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 2016-12-13 18:28:21.
Project "C:\Users\Chiel.tenBrinke\Projects\graphviz\graphviz.sln" on node 1 (cgraph target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Win32".
Project "C:\Users\Chiel.tenBrinke\Projects\graphviz\graphviz.sln" (1) is building "C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj" (2) on node 1 (default targets).
Project "C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj" (2) is building "C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cdt\cdt.vcxproj" (3) on node 1 (default targets).
InitializeBuildStatus:
  Creating "Debug\cdt.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
  All outputs are up-to-date.
Link:
  All outputs are up-to-date.
  cdt.vcxproj -> C:\Users\Chiel.tenBrinke\Projects\graphviz\Debug\Graphviz\bin\cdt.dll
RunMergeNativeCodeAnalysis:
Skipping target "RunMergeNativeCodeAnalysis" because all output files are up-to-date with respect to the input files.
RunNativeCodeAnalysis:
Skipping target "RunNativeCodeAnalysis" because all output files are up-to-date with respect to the input files.
FinalizeBuildStatus:
  Deleting file "Debug\cdt.tlog\unsuccessfulbuild".
  Touching "Debug\cdt.tlog\cdt.lastbuildstate".
Done Building Project "C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cdt\cdt.vcxproj" (default targets).
InitializeBuildStatus:
  Touching "Debug\cgraph.tlog\unsuccessfulbuild".
PreBuildEvent:
  bison -dy grammar.y -o grammar.c
  flex -o scan.c scan.l
  :VCEnd
  flex: can't open scan.c
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(123,5): error MSB3073: The command "bison -dy grammar.y -o grammar.c [C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(123,5): error MSB3073: flex -o scan.c scan.l [C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(123,5): error MSB3073: :VCEnd" exited with code 1. [C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj]
Done Building Project "C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\Chiel.tenBrinke\Projects\graphviz\graphviz.sln" (cgraph target(s)) -- FAILED.

Build FAILED.

"C:\Users\Chiel.tenBrinke\Projects\graphviz\graphviz.sln" (cgraph target) (1) ->
"C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj" (default target) (2) ->
(PreBuildEvent target) ->
  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(123,5): error MSB3073: The command "bison -dy grammar.y -o grammar.c [C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(123,5): error MSB3073: flex -o scan.c scan.l [C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(123,5): error MSB3073: :VCEnd" exited with code 1. [C:\Users\Chiel.tenBrinke\Projects\graphviz\lib\cgraph\cgraph.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.83
ellson commented 7 years ago

I'm not the Windows build expert, but is there a problem with write permissions?

flex -o scan.c scan.l :VCEnd flex: can't open scan.c

chtenb commented 7 years ago

Where is this scan.c file supposed to live?

chtenb commented 7 years ago

Googling around tells me that there should probably be a scan.c file in lib/cgraph/, but in my clone there isn't. There's just a scan.l file. Is that correct or is something going wrong there?

ErwinJanssen commented 7 years ago

Flex will generate this file as a pre build event, with scan.l as input. The message stating that flex can't open scan.c probably means that flex can't create this file. So the problem can be like @ellson suggested: flex doesn't have permission to write to this directory. Can you verify this?

The other Visual Studio solutions are outdated, the one in the root of the project is indeed the correct one.

chtenb commented 7 years ago

I bumped the permissions of flex.exe to the max, and run git bash as administrator, but I still get the same error, even in a different folder, like my Desktop:

Chiel.tenBrinke@IM-Chiel-2015 MINGW64 ~/Projects/graphviz/lib/cgraph (master)
$ flex --version
C:\Program Files (x86)\GnuWin32\bin\flex.exe version 2.5.4

Chiel.tenBrinke@IM-Chiel-2015 MINGW64 ~/Projects/graphviz/lib/cgraph (master)
$ cp scan.l ~/Desktop/

Chiel.tenBrinke@IM-Chiel-2015 MINGW64 ~/Projects/graphviz/lib/cgraph (master)
$ flex -o ~/Desktop/scan.c ~/Desktop/scan.l
C:\Program Files (x86)\GnuWin32\bin\flex.exe: can't open C:/Users/Chiel.tenBrinke/Desktop/scan.c
chtenb commented 7 years ago

All right, I think I found the culprit. The space between -o and its argument doesn't seem to be allowed. Removing it makes the cgraph project build.

flex -oscan.c scan.l
chtenb commented 7 years ago

The other Visual Studio solutions are outdated, the one in the root of the project is indeed the correct one.

Shouldn't those be removed then? And what about those *.cs files in windows/?