Recent

Author Topic: [SOLVED] ubuntu server not start lazarus application  (Read 606 times)

systemgvp

  • New member
  • *
  • Posts: 28
[SOLVED] ubuntu server not start lazarus application
« on: June 13, 2019, 12:22:49 am »
Hi,

I've make this sample application from the lazarus template. I have add only "writeln('hello word');"

Code: Pascal  [Select]
  1. program test;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Classes, SysUtils, CustApp
  10.   { you can add units after this };
  11.  
  12. type
  13.  
  14.   { testcount }
  15.  
  16.   testcount = class(TCustomApplication)
  17.   protected
  18.     procedure DoRun; override;
  19.   public
  20.     constructor Create(TheOwner : TComponent); override;
  21.     destructor Destroy; override;
  22.     procedure WriteHelp; virtual;
  23.   end;
  24.  
  25. { testcount }
  26.  
  27. procedure testcount.DoRun;
  28. var
  29.   ErrorMsg : String;
  30. begin
  31.   // quick check parameters
  32.   ErrorMsg := CheckOptions('h', 'help');
  33.   if ErrorMsg <> '' then begin
  34.     ShowException(Exception.Create(ErrorMsg));
  35.     Terminate;
  36.     Exit;
  37.   end;
  38.  
  39.   // parse parameters
  40.   if HasOption('h', 'help') then begin
  41.     WriteHelp;
  42.     Terminate;
  43.     Exit;
  44.   end;
  45.  
  46.   { add your program here }
  47.  
  48.   writeln('hello word');
  49.  
  50.   // stop program loop
  51.   Terminate;
  52. end;
  53.  
  54. constructor testcount.Create(TheOwner : TComponent);
  55. begin
  56.   inherited Create(TheOwner);
  57.   StopOnException := True;
  58. end;
  59.  
  60. destructor testcount.Destroy;
  61. begin
  62.   inherited Destroy;
  63. end;
  64.  
  65. procedure testcount.WriteHelp;
  66. begin
  67.   { add your help code here }
  68.   writeln('Usage: ', ExeName, ' -h');
  69. end;
  70.  
  71. var
  72.   Application : testcount;
  73. begin
  74.   Application := testcount.Create(nil);
  75.   Application.Title := 'testcount';
  76.   Application.Run;
  77.   Application.Free;
  78. end.
  79.  

the server is "Ubuntu 17.04 (GNU/Linux 4.10.0-42-generic i686) without GUI" and if I run I see

Quote
sudo ./test
[sudo] password di tis:
./test: 1: ./test: ELF: not found
./test: 1: ./test: �����ք: not found
./test: 1: ./test: �D~: not found
./test: 1: ./test: �: not found
./test: 2: ./test: Syntax error: ")" unexpected

why?
« Last Edit: June 16, 2019, 03:29:48 am by systemgvp »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8089
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ubuntu server not start lazarus application
« Reply #1 on: June 13, 2019, 06:18:50 am »
I believe it's library dependency problem, your program is linked against newer (quite deeply base) libraries that the ubuntu server doesn't have.
Execute `ldd test`, the output will tell you which libraries are missing or misversioned.

systemgvp

  • New member
  • *
  • Posts: 28
Re: ubuntu server not start lazarus application
« Reply #2 on: June 13, 2019, 08:55:17 am »
Quote
ldd test
        it is not a dynamic executable

ldd ./test
        it is not a dynamic executable

but He work on openSUSE 15/15.1 and on Ubuntu 18/19 wothout problem.

What can go wrong? It seems that for him it is not an executable. Also when I try to start it it creates these strange files in the folder, which cannot be deleted.

PascalDragon

  • Hero Member
  • *****
  • Posts: 505
  • Compiler Developer
Re: ubuntu server not start lazarus application
« Reply #3 on: June 13, 2019, 08:59:27 am »
Would you please do the following to confirm that it's indeed an ELF executable:
Code: [Select]
hexdump -C ./test | head -n 10

systemgvp

  • New member
  • *
  • Posts: 28
Re: ubuntu server not start lazarus application
« Reply #4 on: June 13, 2019, 09:32:28 am »
Quote
hexdump -C ./test | head -n 10
00000000  7f 45 4c 46 02 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
00000010  02 00 3e 00 01 00 00 00  b0 10 40 00 00 00 00 00  |..>.......@.....|
00000020  40 00 00 00 00 00 00 00  30 92 18 00 00 00 00 00  |@.......0.......|
00000030  00 00 00 00 40 00 38 00  0a 00 40 00 26 00 25 00  |....@.8...@.&.%.|
00000040  06 00 00 00 04 00 00 00  40 00 00 00 00 00 00 00  |........@.......|
00000050  40 00 40 00 00 00 00 00  40 00 40 00 00 00 00 00  |@.@.....@.@.....|
00000060  30 02 00 00 00 00 00 00  30 02 00 00 00 00 00 00  |0.......0.......|
00000070  08 00 00 00 00 00 00 00  03 00 00 00 04 00 00 00  |................|
00000080  70 02 00 00 00 00 00 00  70 02 40 00 00 00 00 00  |p.......p.@.....|
00000090  70 02 40 00 00 00 00 00  1c 00 00 00 00 00 00 00  |p.@.............|

maybe I believe that Lazarus compiles on my PC of origin in x64 while the server is x86.
How can I match the 64bit to 32bit processor type?

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 635
Re: ubuntu server not start lazarus application
« Reply #5 on: June 13, 2019, 10:34:26 am »
Install the cross compiler. Use fpcupdeluxe to make it easier.

systemgvp

  • New member
  • *
  • Posts: 28
Re: ubuntu server not start lazarus application
« Reply #6 on: June 13, 2019, 11:35:08 am »
Forgive me, how should I do to install this?
I'm new to Lazarus.

systemgvp

  • New member
  • *
  • Posts: 28
Re: ubuntu server not start lazarus application
« Reply #7 on: June 14, 2019, 11:57:18 am »
I've download and compile "fpcupdeluxe" but I don't know how to use it

Leledumbo

  • Hero Member
  • *****
  • Posts: 8089
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ubuntu server not start lazarus application
« Reply #8 on: June 14, 2019, 02:04:50 pm »
Quote
ldd test
        it is not a dynamic executable

ldd ./test
        it is not a dynamic executable

but He work on openSUSE 15/15.1 and on Ubuntu 18/19 wothout problem.

What can go wrong? It seems that for him it is not an executable. Also when I try to start it it creates these strange files in the folder, which cannot be deleted.
OK, that output is possible as well. Other than base libraries (like libgcc, which a console program shouldn't link to, hence the output as fpc produces statically linked executables), the potential source of problem is kernel version. Those two systems might have similar kernel version but the server version is way too outdated. On what system do you compile the app?

systemgvp

  • New member
  • *
  • Posts: 28
Re: ubuntu server not start lazarus application
« Reply #9 on: June 14, 2019, 02:21:59 pm »
5.1.7, but I think that problem is cpu, because I compile on 64bit, but server is 32bit

devEric69

  • Full Member
  • ***
  • Posts: 107
Re: ubuntu server not start lazarus application
« Reply #10 on: June 14, 2019, 02:25:19 pm »
(Just for information about "fpcupdeluxe":
In the first tab of "fpcupdeluxe", you choose the version of FPC and the version of Lazarus that you want to install for native compilations (a tip, uninstall your current FPC + Laz., before using "fpcupdeluxe"). Once your FCP+Laz. combination is installed, on your machine you will have then an installed cross compiler with the OS of your machine and the CPU\processor of your machine as target ("fpcupdeluxe" detects it).

Now, if you also want to cross-compile for another target different than your OS and CPU (ie your developpment machine), you go to the "cross"-compilation tab of "fpcupdeluxe", and you choose for which other OS+CPU pair you also want to cross-compile. That's all: in the options of your project, you'll can then say with which installed OS+CPU cross-compilation couple (ie which target), you want to compile.)
use: Ubuntu 18.04 + Laz. 1.8.5 + FPC 3.0.5 (64 bits).

systemgvp

  • New member
  • *
  • Posts: 28
Re: ubuntu server not start lazarus application
« Reply #11 on: June 16, 2019, 03:29:33 am »
Thanks, this work 32/64 bit