开发者

Mac OS X: Extending a shared library by adding a function

开发者 https://www.devze.com 2023-03-16 18:23 出处:网络
I would like to extend a shared c library (dylib) on Mac OS X by adding a function. Let\'s call the function const char *get_string(void). Here is my approach:

I would like to extend a shared c library (dylib) on Mac OS X by adding a function. Let's call the function const char *get_string(void). Here is my approach:

I created a new shared library containing the get_string(void) function and liked it against the library I wanted to extend. A library wrapper so to speak. So far so good. The next step would be to link an application against my new extended library but the problem is that the extended library does only export the symbol _get_string but not those symbols of the original library. That's why linking against the "extended" library (instead of the original library) produces a lot of unresolved symbol warnings/error.

Is there any way to export all those symbols of the original library (there are a lot) or is there a better approach to solve the problem. Basically I just want to extend an existing library. BTW I have access to the original library's source but I can't just recompile it.

Thanks in开发者_JS百科 advance!


How about this option to ld:

     -reexport-lx
             This is the same as the -lx but specifies that the all symbols in library x should
             be available to clients linking to the library being created.  This was previously
             done with a separate -sub_library option.
0

精彩评论

暂无评论...
验证码 换一张
取 消