[ECOS] how to build a driver to a single library
Tianjun - zdk
Tianjun@zcom.unimis.com
Tue Jul 19 01:01:00 GMT 2005
Hi,Andrew
so i should not to linked the library to extras.o?
and just to generate a libarery mylib.a use my favourite name?
and then use this command to link it in my Application
compile -lmylib mylib.a application.c
can this working?
Sincerely yours,
Tian-Jun
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>On Mon, Jul 18, 2005 at 04:19:06PM +0800, ZDC 0616 tianjun wrote:
>> hi, all
>>
>> how to build a driver to a single library ,and can link it as : ecos + driver + app ?
>> and now i have built it in the ecos library ,i want to then separate .
>
>Just so i understand you correctly:
>
>You have written a device driver which is currently part of the eCos
>tree. You now want to seperate it from the eCos tree into a library of
>its own. You then want to link this library with your application.
>
>OK. Nothing impossible here, but there is one thing to be careful of.
>
>Anyway, build your device driver library just like an eCos
>application, but instead of linking it to eCos just use ar to create a
>library from the object file. There is nothing special needed, so just
>look at normal examples for building libraries.
>
>To link the libarary to the application and eCos just add -lmylib to
>the command line when linking. ie nothing special or magical needed.
>
>OK, now the thing to be careful of. When building a device driver
>within the eCos tree there is normally a cdl option:
>
> compile -library=libextras.a foobar.c
>
>ie the object file is put into the library libextras.a not the normal
>libtarget.a. At the end of the build process libextras.a is linked to
>extras.o and this is then linked to your application, not
>libextras.a. This is becasue the linker throws away any symbols not
>referenced in libraries. Normally there is no reference to a device
>driver because of the use of linker tables. So if the device driver
>was inside a library it would not be pulled into the final application
>executable.
>
>For your device driver in your library you cannot use the same
>trick. So instead your application must reference something in the
>device driver so that it is pulled in. Typically a device driver has a
>DEVTAB_ENTRY, eg
>
>DEVTAB_ENTRY(ebsa285_serial_io,
> CYGDAT_IO_SERIAL_ARM_EBSA285_SERIAL_NAME,
> 0, // Does not depend on a lower level interface
> &cyg_io_serial_devio,
> ebsa285_serial_init,
> ebsa285_serial_lookup, // Serial driver may need initializing
> &ebsa285_serial_channel
> );
>
>Doing something like:
>
> extern cyg_devtab_entry_t *ebsa285_serial_io;
> ebsa285_serial_io = ebsa285_serial_io;
>
>will probably be enought.
>
> Andrew
>
>--
>Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list