动态加载静态C库(编译器建议?) [英] Dynamically loading a static C library (compiler suggestion?)

查看:53
本文介绍了动态加载静态C库(编译器建议?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在编写一个嵌入式控制器,它有一个C库,用于使用它的系统功能(I / O) ,定时器,所有特定设备)。

提供的库有.LIB和.H文件。


如何动态加载LIB文件并访问其所有功能?

肯定有人解决了类似的任务吗?


我的目的是使用Forth系统对控制器进行编程,

从中调用库函数。


问候,

Nickolai Leschov

解决方案

Nickolai Leschov写道:


我正在编写一个嵌入式控制器,它有一个C库,用于使用

系统功能(I / O,定时器,全部具体设备)。

提供的库有.LIB和.H文件。


如何动态加载LIB文件并访问其所有功能?

肯定有人解决了类似的任务吗?


我的目的是使用Forth系统对控制器进行编程,

从中调用库函数。



通常你不能加载一个lib文件,它用于链接到C程序(或者用于
使它更容易使用DLL for Windows)。但你可以使用
http://ficl.sourceforge.net/并为所有库编写C包装器

你需要的功能。


-

Frank Buss, fb@frank-buss.de
http://www.frank-buss.de http ://www.it4-systems.de


Frank Buss写道:


> ;

通常你不能加载一个lib文件,它用于链接到C程序(或者用于
使得更容易使用Windows的DLL)。



我看到,加载一个lib(或obj)文件是你通常不会做的事情

构建一个''C''程序。这不是通常的方法,但是它可能是b $ b吗?怎么样?

http://ficl.sourceforge.net / 并为所有库编写C包装器

您需要的功能。



谢谢,我会仔细研究一下。

它会编译并在i186上运行吗?


Nickolai Leschov写道:


大家好,


我正在编程一个嵌入式控制器有一个C库用于使用

系统功能(I / O,定时器,所有特定设备)。

提供的库有.LIB和.H文件。


如何动态加载LIB文件并访问其所有功能?

肯定有人解决了类似的任务吗?


我的目的是使用Forth系统对控制器进行编程,

从中调用库函数。


问候,

Nickolai Leschov



这很容易:

您提取所有目标文件,然后查看内部的重定位

。如果你可以解决所有的符号,那么你就可以在一个malloced内存缓冲区中进行重定位,然后跳入它。


lcc-win提出了一个在windows系统下执行此操作的软件。


对于你的系统,它需要调整一下,具体取决于你的
对象格式

-

jacob navia

jacob at jacob point remcomp point fr

logiciels / informatique http://www.cs.virginia.edu/~lcc-win32


Hello all,

I am programming an embedded controller that has a ''C'' library for using
its system functions (I/O, timers, all the specific devices). The
supplied library has .LIB and .H files.

How can I dynamically load a LIB file and access all its functions?
Surely someone has solved similar task?

My intention is to use a Forth system for programming the controller,
calling library functions from it.

Regards,
Nickolai Leschov

解决方案

Nickolai Leschov wrote:

I am programming an embedded controller that has a ''C'' library for using
its system functions (I/O, timers, all the specific devices). The
supplied library has .LIB and .H files.

How can I dynamically load a LIB file and access all its functions?
Surely someone has solved similar task?

My intention is to use a Forth system for programming the controller,
calling library functions from it.

Usually you can''t load a lib file, it is used to link to C programs (or to
make it easier to use DLLs for Windows). But you could use something like
http://ficl.sourceforge.net/ and write C wrappers for all the library
functions you need.

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de


Frank Buss wrote:

>
Usually you can''t load a lib file, it is used to link to C programs (or to
make it easier to use DLLs for Windows).

I see, loading a lib (or obj) file is something you normally not do when
building a ''C'' program. It is not the usual approach, but is it
possible? How?

http://ficl.sourceforge.net/ and write C wrappers for all the library
functions you need.

Thanks, I''ll examine this closer.
Will it compile to and run on i186 ?


Nickolai Leschov wrote:

Hello all,

I am programming an embedded controller that has a ''C'' library for using
its system functions (I/O, timers, all the specific devices). The
supplied library has .LIB and .H files.

How can I dynamically load a LIB file and access all its functions?
Surely someone has solved similar task?

My intention is to use a Forth system for programming the controller,
calling library functions from it.

Regards,
Nickolai Leschov

It is easy:

You extract all the object files, then look the relocations
inside. If you can resolve all the symbols then you
do the relocations within a malloced memory buffer and
jump into it.

lcc-win proposes a software that does that under the windows system.

For your system it would need to be adapted a bit, depending on your
object format
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32


这篇关于动态加载静态C库(编译器建议?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆