static link library question

Login to reply to this topic.
Wed, 2004-06-09 13:05
Joined: 2004-06-09
Forum posts: 15
Hi group,
Let me ask a trivial linking question! I have a static link library which is
supposed to be use by others developers, my MMP file looks is as follows:

Code:
TARGET  mydll.dll
TARGETTYPE dll
UID  0x1000008d 0x01000218
SOURCEPATH .
SOURCE         mydll.cpp
SOURCE  ClassA.cpp
SOURCE  ClassB.cpp
USERINCLUDE     .
USERINCLUDE ..\inc
SYSTEMINCLUDE \Epoc32\include
LIBRARY  euser.lib insock.lib esock.lib

ClassA must be known to the user of the library, but I don't want to provide
it's
implementation (cpp)! How can i force compiled code for class ClassA to be
be
linked into the mydll.dll?? So the user can simple include mydll.h file.

cheers,
M.

Wed, 2004-06-09 23:26
Joined: 2004-05-28
Forum posts: 52
It will be
Describe ClassA in one of the header files that you export in your bld.inf. That will go into \epoc32\include so that others can use it from their source code. For each function which is to be used by the users of your library, mark it with IMPORT_C in the .h and EXPORT_C in the .cpp.

Then when you build the library (once you've frozen it) you will get a .lib file which others can link against - they will be able to use the functions of ClassA.

Think hard about the interface for ClassA, cos you're pretty much stuck with it once you've exported it that way (unless you break Binary Compatibility).

I'm not convinced that I understood your question properly but I thought I'd give it a go anyway...
Thu, 2004-06-10 12:52
Joined: 2004-06-09
Forum posts: 15
Re: It will be
Yes that's the answer, thank you! But how do i "export in bld.inf"? Thank you in advance!
My bld.inf is quite simple:

Code:
// BLD.INF ( mydll.mmp)
// Component description file
//

PRJ_MMPFILES

mydll.mmp
Thu, 2004-06-10 21:19
Joined: 2004-05-28
Forum posts: 52
Add
Code:
PRJ_EXPORTS
myheader.h \epoc32\include\myheader.h

I think you might even be able to abbreviate this to:

Code:
PRJ_EXPORTS
myheader.h
Fri, 2004-06-11 13:20
symbiote (not verified)
Forum posts: 2043
static link library question
What you are actually creating here is a DYNAMIC link library rather than a static link library. DLL = Dynamic Link Library. TARGETTYPE dll in the bld.inf indicates this.

A the code in the dynamic link library will not become part of the users executable, just the interface that is in the LIB that gets created for your DLL is linked into the user executable.
This is actually a Static Interface DLL, the lib is the import library, but the executable is loaded at run-time.

A static link library is not an executable, just code that gets statically linked into the user executable, i.e. the code becomes part of their executable.

I'm not entirely sure how you create a static link library in Symbian. My guess would be TARGETTYPE lib in the bld.inf.

You need to determine which is the best method for your needs. The usual way in Symbian is to use dynamic link libraries rather than statically liked libraries, to keep the code size to a minimum seen as were working with limited resources.

I hope this helps.
Fri, 2004-06-11 15:13
Joined: 2004-05-28
Forum posts: 52
DLLs
All libraries in Symbian OS are dynamic - there is no way to produce a statically linked library which will be loaded into your code at build-time.

So the word 'static' is used for something else in Symbian OS. You have either static DLLs or polymorphic DLLs.

minstn is trying to write a static DLL. That means it has a variety of exports which can be used by other apps. He's on the right lines.

The other type, polymorphic DLLs, are used for plug-in architectures. They generally have a single export which constructs a subclass of some type. For example, .APP files are polymorphic DLLs. They have a single export which creates a subclass of CEikApplication.
Sat, 2004-06-12 15:43
Joined: 2004-05-24
Forum posts: 23
Re: DLLs
Quote from: streetmentioner
All libraries in Symbian OS are dynamic - there is no way to produce a statically linked library which will be loaded into your code at build-time.

I'm not incredibly familiar with the low level details of Symbian, but...
How is a .o file that is a component of a build different from a statically linked library loaded into code at build time? If I provide a .o file and a header, somebody can link my code at build time and it'll all be one big happy executable...
I am using the UNIX/GCC toolchain, so it may be that I can do things using this toolchain that others can't do, but just about every build environment I've ever used works that way.
Sat, 2004-06-12 20:22
Joined: 2004-05-28
Forum posts: 52
Yes, I don't see why not
It's just an unusual thing to do.
Fri, 2004-06-18 17:11
symbiote (not verified)
Forum posts: 2043
static link library question
I don't mean to be pernikity streetmentioner, but I'm afraid you are slightly incorrect.

Firstly, what you refer to as a "static DLL" is correctly termed a "static interface DLL". To say "static DLL" is to say "static dynamic link library", clearly a contradiction of terms. Read the section titled "Frameworks, libraries and DLLs" in the Developer Library for more information.

Perhaps the version of Symbian you are working with differs to mine (7.0s), but I certainly can statically link. On my current project, I have a static link library (.lib) with no associated DLL that I statically link into my executable.

In fact, with a little modification I managed to build (against my better judgement, but rather as a proof-of-concept for a manager) that a third-party developed static interface DLL for which I had the source could in fact be built as a static link library, linked and executed successfully.

bhima is correct in drawing the comparison with the intermediate ".o" files. There really isn't any significant difference in the way these and static link libraries are linked. I agree also that every C/C++ environment I have worked with also behaves in this way: you compile, you link.

It seems Symbian don't go to any length to inform developers how to generate static link libraries, perhaps this is to promote the use of shared library DLLs.
Sat, 2004-06-19 14:39
Joined: 2004-05-28
Forum posts: 52
Interesting
You're right, I've never tried making a static library. Still unusual though Smiley
Fri, 2005-01-07 09:42
Anonymous (not verified)
Forum posts: 2043
static link library question
Hi symbiote,

can you give me some ideas on how to build a DLL into static link library? i badly need this.

tnx very much in advance.


Quote from: symbiote
I don't mean to be pernikity streetmentioner, but I'm afraid you are slightly incorrect.

Firstly, what you refer to as a "static DLL" is correctly termed a "static interface DLL". To say "static DLL" is to say "static dynamic link library", clearly a contradiction of terms. Read the section titled "Frameworks, libraries and DLLs" in the Developer Library for more information.

Perhaps the version of Symbian you are working with differs to mine (7.0s), but I certainly can statically link. On my current project, I have a static link library (.lib) with no associated DLL that I statically link into my executable.

In fact, with a little modification I managed to build (against my better judgement, but rather as a proof-of-concept for a manager) that a third-party developed static interface DLL for which I had the source could in fact be built as a static link library, linked and executed successfully.

bhima is correct in drawing the comparison with the intermediate ".o" files. There really isn't any significant difference in the way these and static link libraries are linked. I agree also that every C/C++ environment I have worked with also behaves in this way: you compile, you link.

It seems Symbian don't go to any length to inform developers how to generate static link libraries, perhaps this is to promote the use of shared library DLLs.
  • Login to reply to this topic.