Recent

Author Topic: Compiler Error  (Read 14970 times)

Newmann

  • Jr. Member
  • **
  • Posts: 62
Compiler Error
« on: February 24, 2011, 12:11:50 am »
Hey guys,
I'm getting a weird error when compiling a little project that I'm working on. It seems to find some kind of a problem in my resource file- take a look at the following:

Code: [Select]
program textCan;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, main, about, compare, daily;

{$IFDEF WINDOWS}{$R textCan.rc}{$ENDIF} {<<== GETTING ERROR HERE}

begin
  Application.Title:='TxtCan';
  Application.Initialize;
  Application.CreateForm(Tfrm_main, frm_main);
  Application.Run;
end.

The error messages that it kicks out is:
Quote
Compiling resource C:\Development\prj-textCan\textCan.rc
c:\lazarus\fpc\2.2.4\bin\i386-win32\windres.exe: C:/DEVELO~1/PRJ-TE~1/textCan.rc:4: syntax error
textCan.lpr(19,1) Error: Error while linking
textCan.lpr(19,1) Fatal: There were 1 errors compiling module, stopping

I tried deleting that file and recreating it- no effect. Does anybody have any idea what causes this to happen? If I simply comment the line out the program compiles 100%...just doesn't have any application icons then...
Lazarus 1.0.14
FPC 2.6.0
Win7 Pro 64bit/Win XP Pro 32bit

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Compiler Error
« Reply #1 on: February 24, 2011, 06:07:35 pm »
Try compiling the .rc manually, if that works, then the problem isn't the .rc file.

Newmann

  • Jr. Member
  • **
  • Posts: 62
Re: Compiler Error
« Reply #2 on: February 24, 2011, 06:22:25 pm »
I actually deleted all the files in my project folder except for the *.lpr, *.lpi, and *.pas files, then did a full build so it can re-create all the files from scratch...still get the error.

How do I compile the .rc file manually? I have a program called Resource Builder that I used with Delphi and it worked like a dream- can I use that instead?
Lazarus 1.0.14
FPC 2.6.0
Win7 Pro 64bit/Win XP Pro 32bit

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Compiler Error
« Reply #3 on: February 24, 2011, 06:56:08 pm »
Quote
How do I compile the .rc file manually?
Try fpcres (or windres) xxx.rc

Lush

  • New Member
  • *
  • Posts: 15
Re: Compiler Error
« Reply #4 on: February 25, 2011, 04:20:03 am »
I had the same kind of problem twice, yesterday and today.

Once with 0.9.28, just a compiler error pointing to the {$IFDEF WINDOWS} directive in the .lpr file

Once with 0.9.31-29660, the compiler error pointing to the .lrs file, saying something about "LazarusResources" not being valid.

In both cases I had loaded a 128x128 PNG icon (a different icon every time) in the Project Options.

With other 128x128 icons it works fine, without even generating a {$IFDEF WINDOWS} directive.
(and why would Windows be the only OS that can display an icon anyway?)

So I suspect those two PNGs had some special metadata or something corrupt with them that made the icon importer go weirdo somehow...

j0x

  • Full Member
  • ***
  • Posts: 126
Re: Compiler Error
« Reply #5 on: February 25, 2011, 05:00:34 am »
this might help you so read this thread -> http://www.lazarus.freepascal.org/index.php/topic,11068.0.html

Lush

  • New Member
  • *
  • Posts: 15
Re: Compiler Error
« Reply #6 on: February 25, 2011, 05:21:48 am »
this might help you so read this thread
hmm... not sure it will help. You wanted to "embed" a console app inside your GUI app which is quite different.
I'm not convinced a resource file should even be created for a simple application icon in the first place.

@Newmann: did you try to clean up and use a different icon (from a different set) just to see if it compiles ?

EDIT: looks like it's not a PNG problem after all. Have a look here: http://lazarus-dev.blogspot.com/2010/02/work-on-0930-changes-in-resource.html
« Last Edit: February 25, 2011, 06:20:48 am by Lush »

Newmann

  • Jr. Member
  • **
  • Posts: 62
Re: Compiler Error
« Reply #7 on: February 26, 2011, 04:16:02 am »
Tried a whole new Icon, tried removing the icon completely...still gives me the same error!

What bugs the crap out of me is the fact that it was working perfectly, and then just suddenly started giving this problem. The only funny thing I did was to copy the textCan.rc to my desktop, and open that one with Resource Builder (didn't change it or anything, just wanted to see if it was able to read it- afterwards I deleted it).

If I messed around with the file then sure I can understand, but i didn't!?!

I'm at the end of my rope here...seriously starting to ponder the idea of rewriting the entire application from scratch (which is obviously not a solution to the problem- just a lengthy work around)

If it's of any importance, I'm running Windows7 Ultimate 64bit, and Lazarus0.9.28.2.

Alternatively- I can maybe upload the project files onto my webserver and PM a link to you guys to download it? I don't mind as I'm not actually planning on selling the little app...
« Last Edit: February 26, 2011, 01:30:37 pm by Newmann »
Lazarus 1.0.14
FPC 2.6.0
Win7 Pro 64bit/Win XP Pro 32bit

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Compiler Error
« Reply #8 on: February 26, 2011, 06:18:55 pm »
Alternatively (as opposed to rebuilding the whole app from the ground up) you can fallback on the old Lazarus away of including resources using lazres to create a resource file (myicons.lrs), in the main form's unit do {$I myicons.lrs} in the initialization section, and then use LoadFromLazarusResource to load the icons?

Bart

Newmann

  • Jr. Member
  • **
  • Posts: 62
Re: Compiler Error
« Reply #9 on: February 27, 2011, 02:52:43 am »
Okay thanks, I'll give it a try and let you know if it works. I'm assuming that it's the stuff in this article that you're talking about:

http://wiki.lazarus.freepascal.org/Lazarus_Resources

It is 03:45 in the morning...just came from work, so hopefully it won't be too concentration intensive ;)
Lazarus 1.0.14
FPC 2.6.0
Win7 Pro 64bit/Win XP Pro 32bit

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Compiler Error
« Reply #10 on: February 27, 2011, 11:48:18 am »
Okay thanks, I'll give it a try and let you know if it works. I'm assuming that it's the stuff in this article that you're talking about:
http://wiki.lazarus.freepascal.org/Lazarus_Resources

Yes.

Bart

Newmann

  • Jr. Member
  • **
  • Posts: 62
Re: Compiler Error
« Reply #11 on: March 06, 2011, 06:55:32 pm »
Okay...so it's been a while, and I managed to get the LRS thing compiled, but the EXE still only has the normal windows icon (the boring blue block). :-\

To keep it simple I momentarily included the icon as a separate file in my installer as well, and just have it point to that icon (if available) when the installer writes out the shortcuts to the app. :-X

This is however just a workaround...there must be something I'm missing here :o
It only gives me the error when I select an icon through the project properties, but any other resources I include into the project works perfectly!
Lazarus 1.0.14
FPC 2.6.0
Win7 Pro 64bit/Win XP Pro 32bit

Newmann

  • Jr. Member
  • **
  • Posts: 62
Re: Compiler Error
« Reply #12 on: March 08, 2011, 05:47:46 pm »
Right- I've opened up all the supplemental files and checked them line by line (since windres.exe is complaining about a syntax error).

Everything seems to be in order- but for some reason it thinks there is an error. Is there some way I can force it to tell me where exactly the error is located, or some kind of separate syntax checker for it?
Lazarus 1.0.14
FPC 2.6.0
Win7 Pro 64bit/Win XP Pro 32bit

Newmann

  • Jr. Member
  • **
  • Posts: 62
Re: Compiler Error
« Reply #13 on: March 08, 2011, 10:27:29 pm »
I FOUND THE SOLUTION!!!!!!!!!!!!  :D

The problem seems to be with the project properties- I found this article/thread:
http://www.lazarus.freepascal.org/index.php?topic=8570.0

Anyway- I removed the "Product Version" under "Additional Properties" in my project, and it started compiling immediately again! :)
Lazarus 1.0.14
FPC 2.6.0
Win7 Pro 64bit/Win XP Pro 32bit

Newmann

  • Jr. Member
  • **
  • Posts: 62
Re: Compiler Error
« Reply #14 on: March 09, 2011, 11:48:27 am »
Final footnote for this thread before closing it...

This definitely was the problem! I messed around with it until about 04:00 this morning, and it's definitely working 100% again. :)
Lazarus 1.0.14
FPC 2.6.0
Win7 Pro 64bit/Win XP Pro 32bit

 

TinyPortal © 2005-2018