测试第一个linux下的hello world

写了个极其简单的linux的程序,用的是freepascal+lazarus。我在ubuntu 7.10下测试成功,上次用realbasic测试跨平台应用的时候,其编译的程序不知道为什么不能在ubuntu下运行,并且连它免费的linux环境运行也很不正常。

有兴趣的朋友帮忙看一下,在你的elinux平台下能否运行这个hello world程序,因为freepascal的编译关系,程序很大,有14M,我压缩到3M,这里下载。 如果能够运行或者不能运行请告知linux平台和版本。谢谢。

hello world app under ubuntu

相关内容

2 Responses to “测试第一个linux下的hello world”


  • 可惜我现在用mac,不然就帮你测试下。
    另外,代码没有优化而且附带大量调试信息就会很大,在优化选项里选择优化等级2然后生成程序,再用lazarus本身附带的strip去掉生成的程序里所有调试信息和一些无关的内容就可以减肥到很小了。还可以继续用upx压缩。

    下面是官方的说明
    ---------------------------------

    Why are the generated binaries so big?

    The binaries are big because they include a lot of debug information necessary for using gdb (GNU Debugger).

    The compiler has an option to remove the debug information from the executable (-Xs), but due to a bug in the compiler (version 2.0.2 and earlier), this doesn’t work correctly. It has been fixed in version 2.0.4 and later of the compiler.

    You can use a program called “strip” to remove the debug symbols from the executable file. It is located under lazarus dir lazarus\pp\bin\i386-win32\.

    Just type “strip –strip-all ” on the command line.

    If you want to make your program even smaller, you should try UPX too. UPX is a very good exe compressor. It includes no memory overhead due to in-place decompression. It also has a very fast decompression (~10 MB/sec on an Pentium 133).

    To use upx just type “upx ” on the command line.

    after using both strip and upx a simple GUI Lazarus program gets:

    * ~ 700kb on Linux
    * ~ 420kb on Windows

    A more detailed answer with the drawbacks of using UPX is given on Size Matters.

    It’s also important to note that the hello world lazarus software already includes a huge amount of features. It includes:

    * XML handling library
    * Image handling library for png, xpm, bmp and ico files
    * Almost all widgets from the Lazarus Component Library
    * All of the Free Pascal Runtime Library

    So it’s very big, but it already includes almost everything a real world non-trivial app will need.

    Lazarus executable size starts big, but grows very slowly, because of the Free Pascal compiler and the way lazarus forms operate. A c++ project (just an example, but applies to other languages / tools too) starts very small on the hello world, but quickly grows exponentially when you need features to write a non-trivial application.

Leave a Reply