Recent

Author Topic: Project written in Windows will not compile in LInux  (Read 9629 times)

HappyLarry

  • Full Member
  • ***
  • Posts: 155
Project written in Windows will not compile in LInux
« on: February 03, 2012, 01:35:00 am »
I have written a project that successfully compiles and runs in  Windows. When I try to compile the code in Ubuntu Linux I get the error

Error: Can't open resource file "/home/xxx/Unit1.lfm"

What can I do to correct this?




Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Project written in Windows will not compile in LInux
« Reply #1 on: February 03, 2012, 04:22:54 am »
Is that a hard coded path in your program?

Have you reviewed this link:
http://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide
« Last Edit: February 03, 2012, 04:25:19 am by IPguy »

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Project written in Windows will not compile in LInux
« Reply #2 on: February 03, 2012, 09:20:15 am »
Check also the access rights to the files. Windows doesn't have access rights, and depending on how you copied the files, the access rights could be wrong for the user trying to open the sources.

HappyLarry

  • Full Member
  • ***
  • Posts: 155
Re: Project written in Windows will not compile in LInux
« Reply #3 on: February 03, 2012, 06:32:42 pm »
Thanks to IPguy and ludob for their suggestions but they have not solved the problem.

I ran a simple Test to check:
I created a project in Windows 7 which opens a blank form. I have added no code at all. It compiles and runs in Windows 7. I created it on a USB Stick. I copied and pasted the project folder from the USB stick into my home folder in Ubuntu (10.04).

When I compiled I got the error
Unit1.pas(27) Error: Can't open resource file "/home/xxx/Hello World 2/Unit1.lfm"

Lazarus can't open the Lazarus .lfm file.

This error is  identical to the previous error in the other project. I conclude that the problem is not in any code I wrote, since I haven't written any
and
2. The file is not corrupt since the it can be opened by the gedit text editor
3. It is openable since Its permissions are read and write for me.
4. The problem applies to all Lazarus applications written in Windows and transferred to Linux.

I wonder if anyone else has tried this and solved the problem?






Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

HappyLarry

  • Full Member
  • ***
  • Posts: 155
Re: Project written in Windows will not compile in LInux
« Reply #4 on: February 03, 2012, 06:58:39 pm »
Test 2
I created a 'blank form'  application in Ubuntu : it ran.
I transfered it to Windows  and compiled : it ran.
I tranferred it back to Ubuntu : it ran,
I replaced the 'faulty' unit1.lfm file that previously wouldn't open with the 'good' unit1.lfm of this project - the 'faulty' project compiled and ran.

The two project1.lfm files look identical to me.

My advice is: always create a project in Ubuntu Linux first.

My problem is: I didn't.

Any ideas?


Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Project written in Windows will not compile in LInux
« Reply #5 on: February 03, 2012, 07:10:50 pm »
(Un)HappyLarry,
What version of Laz and fpc are you using?  Are they the same (or similar) on both platforms?  (probably not the issue, though)

Have you grep'd for "Hello" in your project files on the unix system or reviewed the .lpi & .lpr files for odd file inclusions?

Have you looked at the project files listing on the Windows platform to see if any unexpected files are being included in your project? (I'm not near my Laz installation, so I cannot give you the proper menu steps to check this.)

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Project written in Windows will not compile in LInux
« Reply #6 on: February 03, 2012, 07:13:02 pm »
Quote
The two project1.lfm files look identical to me.
There is a line that says something
Code: [Select]
LCLVersion = '0.9.31'Are they both the same?

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Project written in Windows will not compile in LInux
« Reply #7 on: February 03, 2012, 07:15:51 pm »
From your unix box, you could do a diff on the various files of the windows blank project vs the unix blank project to see if anything interesting shows up.

HappyLarry

  • Full Member
  • ***
  • Posts: 155
Re: Project written in Windows will not compile in LInux
« Reply #8 on: February 03, 2012, 07:52:33 pm »
@ludob
The 'bad file called unit1old.lfm -

object Form1: TForm1
  Left = 240
  Height = 240
  Top = 226
  Width = 320
  Caption = 'Form1'
  LCLVersion = '0.9.30'
end

The good file called unit1.lfm -

object Form1: TForm1
  Left = 275
  Height = 240
  Top = 250
  Width = 320
  Caption = 'Form1'
  LCLVersion = '0.9.30'
end

The only difference is the position on the screen of the form.

I checked the file sizes

Bad = 131 bytes
Good =123 bytes

but I suppose this is accounted for by the different names.

Is this a bug?

Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Project written in Windows will not compile in LInux
« Reply #9 on: February 03, 2012, 07:58:53 pm »
8 bytes? That is the number of lines. So the problem is the windows CR LF line termination while linux is using LF only. 


HappyLarry

  • Full Member
  • ***
  • Posts: 155
Re: Project written in Windows will not compile in LInux
« Reply #10 on: February 03, 2012, 08:08:14 pm »
@IPguy

diff
$ diff --normal unit1.lfm unit1old.lfm
1,8c1,8
< object Form1: TForm1
<   Left = 275
<   Height = 240
<   Top = 250
<   Width = 320
<   Caption = 'Form1'
<   LCLVersion = '0.9.30'
< end
---
> object Form1: TForm1
>   Left = 240
>   Height = 240
>   Top = 226
>   Width = 320
>   Caption = 'Form1'
>   LCLVersion = '0.9.30'
> end

I  also tried 'cmp' which suggests something in line 1

cmp
$ cmp -c unit1.lfm unit1old.lfm
unit1.lfm unit1old.lfm differ: byte 21, line 1 is  12 ^J  15 ^M

Is there a hidden character at the end of line 1?








« Last Edit: February 03, 2012, 08:11:53 pm by HappyLarry »
Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Project written in Windows will not compile in LInux
« Reply #11 on: February 04, 2012, 04:46:10 am »
What is the version of Laz and fpc you are using?
as an example, I'm using:
Lazarus version 0.9.31, SVN revision: 34510, with fpc 2.5.1, on a win32 -vista system.

As to the differences you found using cmp, I refer you to ludob's comment.
Might you have hand edited your windows unit1.lfm file, by any chance?

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Project written in Windows will not compile in LInux
« Reply #12 on: February 10, 2012, 12:06:51 am »
In the non-working example, you wrote "Unit1.lfm" filename. In the latter, working one, you quoted "unit1.lfm" - the difference in starting capital letter. Could this be the problem? Linux is case sensitive, maybe the unit name is written differently in the project and in the filesystem?
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

 

TinyPortal © 2005-2018