Reputation: 30915
i try to compile libpng version 1.6.38 using Visual Studio 2019 C++ and im getting this error :
1>------ Build started: Project: genfiles, Configuration: Release x64 ------
1>Generating pnglibconf.c
1>options.awk: bad line (10): com
1>CMake Error at scripts/gensrc.cmake:68 (message):
1> Failed to generate pnglibconf.tf5
1>
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(231,5): error MSB6006: "cmd.exe" exited with code 1.
this is my pre processor defines :
WIN32
_WINDOWS
NDEBUG
PNG_NO_MMX_CODE
CMARK_STATIC_DEFINE
_CRT_SECURE_NO_WARNINGS
_CRT_SECURE_NO_DEPRECATE
CMAKE_INTDIR="Release"
what is the sulotion for this error ?
Upvotes: 4
Views: 1223
Reputation: 2578
This happens, because according to your PATH CMake uses Cygwin version of awk(gawk) which cannot process files with CRLF endings. Open the generated file libpng/bin/scripts/gensrc.cmake and find there the line which looks as "set(AWK "<path_to_awk>")" and you will see, which awk CMake uses in your case.
I had the same problem recently. In order to find the cause I added "set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT)" into scripts/gensrc.cmake.in to see exact awk commands and modified options.awk as follows:
# com <comment>
# The whole line is placed in the output file as a comment with
# the preceding 'com' removed
{ print "Line: '"$0"'" } #
$1 == "com"{
if (NF > 1) {
# sub(/^[ ]*com[ ]*/, "")
$1 = ""
print comment $0, cend >out
} else
print start end >out
print "$1='"$1"'" #
print "NEXT" #
next
}
$1 != "com"{
print "$1='"$1"'" #
print "CONTINUE" #
}
When I compared the output of C:/Cygwin64/bin/gawk.exe and a Windows-compatible C:/Program Files/Git/usr/bin/gawk.exe I saw that Cygwin gawk has CR character inside $1 (see the screenshot).
So the solution is either to use Windows-compatible awk tool or to correct line endings.
Upvotes: 3