Author Topic: "Syntax Error" When Compiling zlib?  (Read 15006 times)

Offline kartari

  • Multiple posting newcomer
  • *
  • Posts: 10
"Syntax Error" When Compiling zlib?
« on: November 26, 2009, 06:07:15 am »
Hi,

  I'm trying to add libpng to my own project, and libpng requires zlib.  So I downloaded the zlib source, opened the MSVC++ project file with Code::Blocks, and get a "Syntax Error" on line 6 of the "win32\zlib1.rc" file when I compile either the dynamic or static library, debug or release.  The .rc file is as follows, with line 6 commented:

Code
#include <windows.h>

#ifdef GCC_WINDRES
VS_VERSION_INFO VERSIONINFO
#else
VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE     // Line 6: "syntax error"
#endif
  FILEVERSION 1,2,2,0
  PRODUCTVERSION 1,2,2,0
  FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
  FILEFLAGS 1
#else
  FILEFLAGS 0
#endif
  FILEOS VOS_DOS_WINDOWS32
  FILETYPE VFT_DLL
  FILESUBTYPE 0 // not used
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904E4"
    //language ID = U.S. English, char set = Windows, Multilingual
    BEGIN
      VALUE "FileDescription", "zlib data compression library\0"
      VALUE "FileVersion", "1.2.3\0"
      VALUE "InternalName", "zlib1.dll\0"
      VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0"
      VALUE "OriginalFilename", "zlib1.dll\0"
      VALUE "ProductName", "zlib\0"
      VALUE "ProductVersion", "1.2.3\0"
      VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
    END
  END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x0409, 1252
  END
END

  It's been a long time since I've dealt with .rc files, but this appears to be the correct syntax to me.  I'm guessing there's some kind of setting that's off, probably the MSVC++ project file was not imported 100% correctly.  What project settings should I be checking to ensure that C::B is in fact compiling this .rc file correctly?  I checked the platform field, which is set to "All" (Windows, Unix and Mac).  I tried setting it to Windows only and got the same result.  I would try the included MinGW makefile instead, but to be honest, I haven't dealt with makefiles since... the mid 90's. :)

  I'm using C::B 8.02 with the included GNU GCC compiler.  My development platform is Windows XP Pro, 32 bit.  I'm very new to C::B (I used MSVC++ in the past), and have been on a hiatus from coding for around four years and am starting to get back into it now, so please forgive any potential ignorance on my part. :)

  Thanks.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: "Syntax Error" When Compiling zlib?
« Reply #1 on: November 26, 2009, 03:24:58 pm »
Did you try to define GCC_WINDRES ?

NOTE: This question really has little to do with Code::Blocks; so, it might end up being locked.

Edit: How to define Macro under Code::Blocks

1. Select project
2. "Project" -> "Build Options"
3. Select correct target, if you have no idea which target select the top one
4. Under "Compiler Settings" Tab
5. Under "#defines" sub tab
6 Add define in window

Edit2: Link to FAQ all beginners should turn on for full Compiler Log
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Tim S.
« Last Edit: November 26, 2009, 03:32:44 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline kartari

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: "Syntax Error" When Compiling zlib?
« Reply #2 on: November 26, 2009, 04:34:50 pm »
Did you try to define GCC_WINDRES ?

I just tried it, and got the same syntax error.

NOTE: This question really has little to do with Code::Blocks; so, it might end up being locked.

Oh.  I guess I'll look for a gnu gcc or mingw forum if this gets locked, thanks for the heads up.  I figured it was a problem with the C::B project file and settings though, or maybe a windres issue specifically, despite receiving a "syntax error" during compilation, especially since zlib is a well known and well tested open source project which I'm pretty sure would not have a simple syntax error.  I think I'll do some Google research into windres settings and see if something's off with the command line arguments, perhaps ("windres.exe -i D:\DOCUME~1\B\SOFTWA~1\zlib123\win32\zlib1.rc -J rc -o Win32_LIB_Debug\win32\zlib1.res -O coff").

Edit2: Link to FAQ all beginners should turn on for full Compiler Log
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Thanks Tim.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: "Syntax Error" When Compiling zlib?
« Reply #3 on: November 26, 2009, 04:40:52 pm »
Some versions of windres can NOT do spaces or special characters.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline kartari

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: "Syntax Error" When Compiling zlib?
« Reply #4 on: November 26, 2009, 05:56:17 pm »
Some versions of windres can NOT do spaces or special characters.

So it might not like the tilde in my input file path... if that is so in my case, wouldn't it give me a "can't find the rc file" error instead of seeing the file and giving me a syntax error?  For the heck of it, I could try altering the command line to put the file name in quotes perhaps?  I can't seem to find where to enter command line arguments, however... the only way I know what the command line args are is from the build log.  Where can I change them?  Otherwise, I guess I'll have to try moving my Documents folder to fit 8.3 format, or move my project files out of my Documents and into a 8.3 compliant path...

Offline kartari

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: "Syntax Error" When Compiling zlib?
« Reply #5 on: December 02, 2009, 12:41:41 am »
Update: I've tried moving the project to a folder that has no spaces or special characters (D:\Projects\zlib123\) and receive the same syntax error.  I've checked with windres and the default parameters used by C::B are correct.  I finally gave up and altered the code for zlib1.rc and commented out "MOVEABLE IMPURE LOADONCALL DISCARDABLE" from line 6 and got it compiling now.  All four of those keywords cause a syntax error (I tried them all individually).  I guess I'll see if this has deleterious effects on my program in the future.

In the meantime, I suppose this means one of two things:
  a) The source code of GCC included with Code::Blocks 8.02 is buggy concerning Windows resource files, or
  b) The version of Windres included with Code::Blocks 8.02 is buggy.

I read elsewhere that windres doesn't compile well with the windows.h header included; I tried using other windows headers to no avail.  The fact that it marks these keywords as syntax errors suggest to me that it's more likely a problem with not recognizing them than confusing them... if I had time I'd check through the Windows headers and see if they're defined anywhere in the GCC source include files.

I don't know enough to know which component is to blame here, but something's wrong, and it doesn't seem to be me this time! :)