[solved]Standalone application,possible?

Forum for talking about anything else Ecere/eC related.
Post Reply
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

[solved]Standalone application,possible?

Post by samsam598 »

Greetings!

Just wanna know whether this is possible in eC,building a standalone application,eC sdk dlls and static libs are not required at all?

Thanks.
Last edited by samsam598 on Wed Sep 07, 2011 7:37 pm, edited 1 time in total.
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Standalone application,possible?

Post by jerome »

Hi Sam,

Yes it is possible! (Well, Ecere is Free Open Source Software, anything is possible -- Use the Source, Luke!)

But not only is it possible, it's even relatively easy.

I suggest you create a new Configuration for your project that you call 'Static'.

Then in that configuration you need to replace 'ecere' by the name of a statically built Ecere library. By default the 'make install' installs a 'Vanilla' static library under Ecere SDK/lib: ecereVanilla. This is a stripped down version of Ecere with the basic GUI functionality, but it doesn't include stuff like the 3D engine, networking, additional graphics file formats support (only supports bmp & pcx), to achieve a minimum file size. If you require additional functionality, you can build the 'Static' configuration of the Ecere runtime library, which includes everything (you can use the sdk/ecere/ecere.epj, and select the active configuration to build that from the IDE). Make sure you include e.g. C:\Program Files (x86)\Ecere SDK\lib in the Global Settings dialog's Compilers/Directories/Libraries paths, I'm not sure whether the installer only adds 'bin' by default (Where the Dynamic library ecere.dll resides).

You will also need to add all the additional libraries that Ecere requires on the link line.
On Windows, for Vanilla this will be: kernel32 user32 gdi32 winmm mpr imm32 z

To build your applications with the full-featured Ecere statically, you will need all the libraries.
On windows those are:
dxguid ddraw dinput winmm opengl32 ws2_32 kernel32 user32 gdi32 mpr advapi32 shell32 winspool imm32 ungif jpeg png z freetype
You will also need to add to the Additional libraries paths each library's path in the sdk/deps folder.

For any platform you can find the full list of libraries required in the ecere.epj Linker tab.

Now if you want the built-in graphics of the Ecere library to work (icons etc.), you will need to add those as well as resources in your application, inside your project's Resoures section, under a folder named 'ecere'. You can point those to the resources under sdk/ecere/res/vanilla/, the hierarchy should match exactly to that one. The vanilla resources are bmp files disguised as png because the Vanilla config doesn't include PNG support. If you use the full support version of the library, then you could include the real resources directly under sdk/ecere/res/.

Finally, in your application you need to replace 'import "ecere"' by 'import static "ecere"'.
When using multiple configurations, I usually add a ECERE_STATIC preprocessor definition (in the Project Settings/Compiler tab) for the Static configuration, and then in the code I write:

Code: Select all

#ifdef ECERE_STATIC
import static "ecere"
#else
import "ecere"
#endif
I am hoping to simplify this whole process in the future, e.g. by having a simple checkbox in the project settings to link statically, or even providing a Static configuration by default. I'm not sure if we have a Mantis issue for this yet, you could register one as a feature if we don't :D

For now I added a 'staticLink' sample in the sdk/samples/eC/staticLink/ folder, you should get it if you do a pull on the sdk. It should be useful as a starting point for a new project with a Static configuration or as a reference. For the Ecere resources, it expects the SDK source folder to be on the same drive in the \sdk\ folder.

Please let me know if you're having any problem setting this up :)

All the best,

Jerome
Attachments
staticLink.ec
(502 Bytes) Downloaded 1372 times
staticLink.epj
(4.45 KiB) Downloaded 1431 times
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Standalone application,possible?

Post by jerome »

I read your question again, and I was wondering what you meant by:
building a standalone application, eC sdk dlls and static libs
Was including the static library as part of your app OK with what you want to do?

If you do not make use of the GUI toolkit/graphics engine/networking, and really only require the very basic eC functionality, you can also use ecereCOM (which can be built statically as well, though it's been a while since I lasted tested it that way). ecereCOM is only the Core eC runtime functionality, so of course it's smaller than the Ecere library (it's built into the Ecere library). An eC application needs the ecereCOM runtime library at the minimum to run.

-Jerome
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Re: Standalone application,possible?

Post by samsam598 »

Hi Jerome,your first thread already answered my question,that is a 100% complete guideline for me.Thank you.
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Standalone application,possible?

Post by jerome »

If you tick the 'compress' checkbox in the Linker settings, it will compress the executable using UPX, and that simple form & button goes down to 628kb with GCC 4.4 on Windows. A typical stand-alone application with quite a bit of logic and forms might take up around 1mb that way.

It used to be smaller, under 1 mb even without UPX, but I guess we keep on adding functionality in the library so now it's a bit fatter :D Still ahead of a lot of the competition though, right? ;)

The only drawback with UPX is that it annoys some anti-virus programs which will report it as a trojan or what not. Avast was one of those complaining about UPX executables, I hope this does not happen anymore, I've filed an issue with the developers.
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Re: Standalone application,possible?

Post by samsam598 »

Hi Jerome,

As far as executable size is concerned,I think eC has already done a great job.wxWidgets/Qt/SWT etc,the exe size is more than 3M and the whole compiled SDK is about 1G or more.To be honest,I don't care the size is big,rather the simplicity of the SDK/language and the performance of the exe is vital :D

I just upgraded my snapshot the the latest,after that I tried to build the staticLink sample,maybe due to the sdk folder is different with yours,I failed to build.Please help with thanks.

Code: Select all

Default Compiler
Building project staticLink using the Static configuration...
Generating symbols...
staticLink.ec
Compiling...
staticLink.ec
staticLink.c
Writing symbol loader...
staticLink.main.ec
staticLink.main.ec
staticLink.main.c
Linking...
   ecere\lib\libecereVanilla.a(EARArchive.o):EARArchive.c:(.text+0x1504): error: undefined reference to `uncompress'

staticLink (Static) - 1 error, no warning                          
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Standalone application,possible?

Post by jerome »

Sam,

Looks like it's not linking or finding zlib...
If you built the SDK it should already be built in your sdk/deps/ folder, you just have to add the folder either to your Global settings/Compilers/Libraries, or in your project Linker's Additional Libraries:

\sdk\deps\zlib\obj\release.$(PLATFORM)

And make sure you have 'z' in your additional libraries for Static/Win32 config/platform.

https://github.com/ecere/sdk/commit/dab ... 40f3afe2ec

Hope this works! :D

Regards,

Jerome
samsam598
Posts: 212
Joined: Thu Apr 14, 2011 9:44 pm

Re: Standalone application,possible?

Post by samsam598 »

Thanks Jerome,it is fixed.Now I knew why there is a 'z' (which it seems so strange to me at the first glance so I deleted)in the additional lib path :D

One more question,just curious any special reason to include so many resource files into this project,it seems the project does not depend on them.
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Standalone application,possible?

Post by jerome »

The resources are the Ecere resources, normally bundled within ecere.dll.

They contain things like the bitmaps on the title bar's buttons, if the window does not use native decorations (child windows never do). They also contains icons for the FileDialog, radio buttons, etc. The runtime library expects those resources to be available.
Post Reply