Howto share secondary dylib inside framework
Is it possible to publish/share secondary dylib inside framework (xxx.framework/Library/*.dylib) to external (visible when external app links)?
//
I am trying to encapsulate multiple libavXXX.dylib (from ffmpeg project) into single Framework (MElibrary.framework).
Currently I am stuck at "unable to make it visible - secondary dylib files inside Framework - to linker when link to Framework".
Is this feasible plan with Framework bundle?
Problem what I am stuck at for now
- When test app link with my framework, build is failed. Linker(ld) does not find my secondary dylib files inside framework/Libraries/ directory.
What I did till now
- Prepare MElibrary.framework/Versions/A/Libraries/ (and its symlink as MElibrary.framework/Libraries)
- Place every libavxxx.dylib (and its symlinks) into MElibrary.framework/Libraries/
- Update dylib id/lib paths using install_name_tool to @rpath/MElibrary.framework/Versions/A/Libraries/xxx.dylib
- Place libavxxx header files into xxx.framework/Headers/include/libavxxx/xxx.h
- Include major header files like #include "include/libavxxx/xxx.h" in MElibrary.h
- Make module.modulemap and define secondary dylib headers as submodules
- Link secondary dylib with MElibrary itself
- Confirms using otool -LX or otool -DX that MElibrary itself and every dylib files have @rpath/MElibrary.framework/Versions/A/... paths.
- Try to build test app with framework linked
- Confirmed compilation step is passed using libavxxx functions
- But build failed because link step failed every time
- I think this is because secondary dylib files are not visible by linker
Error messages
Undefined symbols for architecture x86_64:
"_avcodec_register_all", referenced from:
-[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My Framework structure is following:
MElibrary.framework
+ Headers (symlink)
+ Libraries (symlink)
+ MElibrary (symlink)
+ Modules (symlink)
+ Resources (symlink)
+ Versions
+ Current (symlink)
+ A
+ Headers
+ MElibrary.h
+ include
+ libavcodec/....h
+ :
+ Libraries
+ libavcodec.xxx.dylib .... I want these dylib visible when framework is linked
+ :
+ MElibrary .... framework dylib itself (dummy - no code)
+ Modules
+ module.modulemap
+ Resources
+ Info.plist
Update
Siguza, Thank you for your comment. I have been working with "Xcode10.1/Build Settings/Re-Exported Library Names" to verify the functionality - but no success till now.
ld: file not found: @rpath/MElibrary.framework/Versions/A/Libraries/libavcodec.58.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Referencing boonerhasit's comment "From here, it seems dyld doesn't resolve the @rpath for the LC_REEXPORT_DYLIB command, only LC_LOAD*_DYLIB commands.",
my framework with otool -l MElibrary.framework/MElibrary shows:
Load command 9
cmd LC_REEXPORT_DYLIB
cmdsize 96
name @rpath/MElibrary.framework/Versions/A/Libraries/libavcodec.58.dylib (offset 24)
time stamp 2 Thu Jan 1 09:00:02 1970
current version 58.33.102
compatibility version 58.0.0
Conclusion (Failed)
After multiple test, I have concluded my original plan is not feasible.
Linker does not understand @rpath based, re-exported dylib. I am not sure though I guess it would be of security reason.
- Framework itself can have secondary dylib(s) inside Framework though, it is dedicated for internal use only. They are inside Framework so should have "@rpath" relative path. "@rpath" based dylib is not "re-export-able".
- If you have to export symbols of secondary dylib(s) you may use ld's option -reexport-l (-reexport-lavcodec for example), but it does not work as intended in this case.
- Exported library is defined in LC_REEXPORT_DYLIB command. You can confirm that otool -l shows exported secondary library paths. But linker ld itself does not understand "@rpath" word, and linker always fails to link your framework because of "ld: file not found: @rpath/......dylib for architecture x86_64".
- Every binary in Framework will be relative path "@rpath" and only external dylib with full path is re-export-able.
macos frameworks dylib
add a comment |
Is it possible to publish/share secondary dylib inside framework (xxx.framework/Library/*.dylib) to external (visible when external app links)?
//
I am trying to encapsulate multiple libavXXX.dylib (from ffmpeg project) into single Framework (MElibrary.framework).
Currently I am stuck at "unable to make it visible - secondary dylib files inside Framework - to linker when link to Framework".
Is this feasible plan with Framework bundle?
Problem what I am stuck at for now
- When test app link with my framework, build is failed. Linker(ld) does not find my secondary dylib files inside framework/Libraries/ directory.
What I did till now
- Prepare MElibrary.framework/Versions/A/Libraries/ (and its symlink as MElibrary.framework/Libraries)
- Place every libavxxx.dylib (and its symlinks) into MElibrary.framework/Libraries/
- Update dylib id/lib paths using install_name_tool to @rpath/MElibrary.framework/Versions/A/Libraries/xxx.dylib
- Place libavxxx header files into xxx.framework/Headers/include/libavxxx/xxx.h
- Include major header files like #include "include/libavxxx/xxx.h" in MElibrary.h
- Make module.modulemap and define secondary dylib headers as submodules
- Link secondary dylib with MElibrary itself
- Confirms using otool -LX or otool -DX that MElibrary itself and every dylib files have @rpath/MElibrary.framework/Versions/A/... paths.
- Try to build test app with framework linked
- Confirmed compilation step is passed using libavxxx functions
- But build failed because link step failed every time
- I think this is because secondary dylib files are not visible by linker
Error messages
Undefined symbols for architecture x86_64:
"_avcodec_register_all", referenced from:
-[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My Framework structure is following:
MElibrary.framework
+ Headers (symlink)
+ Libraries (symlink)
+ MElibrary (symlink)
+ Modules (symlink)
+ Resources (symlink)
+ Versions
+ Current (symlink)
+ A
+ Headers
+ MElibrary.h
+ include
+ libavcodec/....h
+ :
+ Libraries
+ libavcodec.xxx.dylib .... I want these dylib visible when framework is linked
+ :
+ MElibrary .... framework dylib itself (dummy - no code)
+ Modules
+ module.modulemap
+ Resources
+ Info.plist
Update
Siguza, Thank you for your comment. I have been working with "Xcode10.1/Build Settings/Re-Exported Library Names" to verify the functionality - but no success till now.
ld: file not found: @rpath/MElibrary.framework/Versions/A/Libraries/libavcodec.58.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Referencing boonerhasit's comment "From here, it seems dyld doesn't resolve the @rpath for the LC_REEXPORT_DYLIB command, only LC_LOAD*_DYLIB commands.",
my framework with otool -l MElibrary.framework/MElibrary shows:
Load command 9
cmd LC_REEXPORT_DYLIB
cmdsize 96
name @rpath/MElibrary.framework/Versions/A/Libraries/libavcodec.58.dylib (offset 24)
time stamp 2 Thu Jan 1 09:00:02 1970
current version 58.33.102
compatibility version 58.0.0
Conclusion (Failed)
After multiple test, I have concluded my original plan is not feasible.
Linker does not understand @rpath based, re-exported dylib. I am not sure though I guess it would be of security reason.
- Framework itself can have secondary dylib(s) inside Framework though, it is dedicated for internal use only. They are inside Framework so should have "@rpath" relative path. "@rpath" based dylib is not "re-export-able".
- If you have to export symbols of secondary dylib(s) you may use ld's option -reexport-l (-reexport-lavcodec for example), but it does not work as intended in this case.
- Exported library is defined in LC_REEXPORT_DYLIB command. You can confirm that otool -l shows exported secondary library paths. But linker ld itself does not understand "@rpath" word, and linker always fails to link your framework because of "ld: file not found: @rpath/......dylib for architecture x86_64".
- Every binary in Framework will be relative path "@rpath" and only external dylib with full path is re-export-able.
macos frameworks dylib
1
I've never personally used this, but when building your framework, the ld flag-reexport-l<x>(seeman ld) should allow you to re-export all symbols of the libraries it links against. This is a different fix than you seem to have in mind, but should make symbols resolve correctly nonetheless.
– Siguza
Nov 18 at 23:16
add a comment |
Is it possible to publish/share secondary dylib inside framework (xxx.framework/Library/*.dylib) to external (visible when external app links)?
//
I am trying to encapsulate multiple libavXXX.dylib (from ffmpeg project) into single Framework (MElibrary.framework).
Currently I am stuck at "unable to make it visible - secondary dylib files inside Framework - to linker when link to Framework".
Is this feasible plan with Framework bundle?
Problem what I am stuck at for now
- When test app link with my framework, build is failed. Linker(ld) does not find my secondary dylib files inside framework/Libraries/ directory.
What I did till now
- Prepare MElibrary.framework/Versions/A/Libraries/ (and its symlink as MElibrary.framework/Libraries)
- Place every libavxxx.dylib (and its symlinks) into MElibrary.framework/Libraries/
- Update dylib id/lib paths using install_name_tool to @rpath/MElibrary.framework/Versions/A/Libraries/xxx.dylib
- Place libavxxx header files into xxx.framework/Headers/include/libavxxx/xxx.h
- Include major header files like #include "include/libavxxx/xxx.h" in MElibrary.h
- Make module.modulemap and define secondary dylib headers as submodules
- Link secondary dylib with MElibrary itself
- Confirms using otool -LX or otool -DX that MElibrary itself and every dylib files have @rpath/MElibrary.framework/Versions/A/... paths.
- Try to build test app with framework linked
- Confirmed compilation step is passed using libavxxx functions
- But build failed because link step failed every time
- I think this is because secondary dylib files are not visible by linker
Error messages
Undefined symbols for architecture x86_64:
"_avcodec_register_all", referenced from:
-[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My Framework structure is following:
MElibrary.framework
+ Headers (symlink)
+ Libraries (symlink)
+ MElibrary (symlink)
+ Modules (symlink)
+ Resources (symlink)
+ Versions
+ Current (symlink)
+ A
+ Headers
+ MElibrary.h
+ include
+ libavcodec/....h
+ :
+ Libraries
+ libavcodec.xxx.dylib .... I want these dylib visible when framework is linked
+ :
+ MElibrary .... framework dylib itself (dummy - no code)
+ Modules
+ module.modulemap
+ Resources
+ Info.plist
Update
Siguza, Thank you for your comment. I have been working with "Xcode10.1/Build Settings/Re-Exported Library Names" to verify the functionality - but no success till now.
ld: file not found: @rpath/MElibrary.framework/Versions/A/Libraries/libavcodec.58.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Referencing boonerhasit's comment "From here, it seems dyld doesn't resolve the @rpath for the LC_REEXPORT_DYLIB command, only LC_LOAD*_DYLIB commands.",
my framework with otool -l MElibrary.framework/MElibrary shows:
Load command 9
cmd LC_REEXPORT_DYLIB
cmdsize 96
name @rpath/MElibrary.framework/Versions/A/Libraries/libavcodec.58.dylib (offset 24)
time stamp 2 Thu Jan 1 09:00:02 1970
current version 58.33.102
compatibility version 58.0.0
Conclusion (Failed)
After multiple test, I have concluded my original plan is not feasible.
Linker does not understand @rpath based, re-exported dylib. I am not sure though I guess it would be of security reason.
- Framework itself can have secondary dylib(s) inside Framework though, it is dedicated for internal use only. They are inside Framework so should have "@rpath" relative path. "@rpath" based dylib is not "re-export-able".
- If you have to export symbols of secondary dylib(s) you may use ld's option -reexport-l (-reexport-lavcodec for example), but it does not work as intended in this case.
- Exported library is defined in LC_REEXPORT_DYLIB command. You can confirm that otool -l shows exported secondary library paths. But linker ld itself does not understand "@rpath" word, and linker always fails to link your framework because of "ld: file not found: @rpath/......dylib for architecture x86_64".
- Every binary in Framework will be relative path "@rpath" and only external dylib with full path is re-export-able.
macos frameworks dylib
Is it possible to publish/share secondary dylib inside framework (xxx.framework/Library/*.dylib) to external (visible when external app links)?
//
I am trying to encapsulate multiple libavXXX.dylib (from ffmpeg project) into single Framework (MElibrary.framework).
Currently I am stuck at "unable to make it visible - secondary dylib files inside Framework - to linker when link to Framework".
Is this feasible plan with Framework bundle?
Problem what I am stuck at for now
- When test app link with my framework, build is failed. Linker(ld) does not find my secondary dylib files inside framework/Libraries/ directory.
What I did till now
- Prepare MElibrary.framework/Versions/A/Libraries/ (and its symlink as MElibrary.framework/Libraries)
- Place every libavxxx.dylib (and its symlinks) into MElibrary.framework/Libraries/
- Update dylib id/lib paths using install_name_tool to @rpath/MElibrary.framework/Versions/A/Libraries/xxx.dylib
- Place libavxxx header files into xxx.framework/Headers/include/libavxxx/xxx.h
- Include major header files like #include "include/libavxxx/xxx.h" in MElibrary.h
- Make module.modulemap and define secondary dylib headers as submodules
- Link secondary dylib with MElibrary itself
- Confirms using otool -LX or otool -DX that MElibrary itself and every dylib files have @rpath/MElibrary.framework/Versions/A/... paths.
- Try to build test app with framework linked
- Confirmed compilation step is passed using libavxxx functions
- But build failed because link step failed every time
- I think this is because secondary dylib files are not visible by linker
Error messages
Undefined symbols for architecture x86_64:
"_avcodec_register_all", referenced from:
-[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My Framework structure is following:
MElibrary.framework
+ Headers (symlink)
+ Libraries (symlink)
+ MElibrary (symlink)
+ Modules (symlink)
+ Resources (symlink)
+ Versions
+ Current (symlink)
+ A
+ Headers
+ MElibrary.h
+ include
+ libavcodec/....h
+ :
+ Libraries
+ libavcodec.xxx.dylib .... I want these dylib visible when framework is linked
+ :
+ MElibrary .... framework dylib itself (dummy - no code)
+ Modules
+ module.modulemap
+ Resources
+ Info.plist
Update
Siguza, Thank you for your comment. I have been working with "Xcode10.1/Build Settings/Re-Exported Library Names" to verify the functionality - but no success till now.
ld: file not found: @rpath/MElibrary.framework/Versions/A/Libraries/libavcodec.58.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Referencing boonerhasit's comment "From here, it seems dyld doesn't resolve the @rpath for the LC_REEXPORT_DYLIB command, only LC_LOAD*_DYLIB commands.",
my framework with otool -l MElibrary.framework/MElibrary shows:
Load command 9
cmd LC_REEXPORT_DYLIB
cmdsize 96
name @rpath/MElibrary.framework/Versions/A/Libraries/libavcodec.58.dylib (offset 24)
time stamp 2 Thu Jan 1 09:00:02 1970
current version 58.33.102
compatibility version 58.0.0
Conclusion (Failed)
After multiple test, I have concluded my original plan is not feasible.
Linker does not understand @rpath based, re-exported dylib. I am not sure though I guess it would be of security reason.
- Framework itself can have secondary dylib(s) inside Framework though, it is dedicated for internal use only. They are inside Framework so should have "@rpath" relative path. "@rpath" based dylib is not "re-export-able".
- If you have to export symbols of secondary dylib(s) you may use ld's option -reexport-l (-reexport-lavcodec for example), but it does not work as intended in this case.
- Exported library is defined in LC_REEXPORT_DYLIB command. You can confirm that otool -l shows exported secondary library paths. But linker ld itself does not understand "@rpath" word, and linker always fails to link your framework because of "ld: file not found: @rpath/......dylib for architecture x86_64".
- Every binary in Framework will be relative path "@rpath" and only external dylib with full path is re-export-able.
macos frameworks dylib
macos frameworks dylib
edited Nov 23 at 8:47
asked Nov 18 at 20:49
MyCometG3
5717
5717
1
I've never personally used this, but when building your framework, the ld flag-reexport-l<x>(seeman ld) should allow you to re-export all symbols of the libraries it links against. This is a different fix than you seem to have in mind, but should make symbols resolve correctly nonetheless.
– Siguza
Nov 18 at 23:16
add a comment |
1
I've never personally used this, but when building your framework, the ld flag-reexport-l<x>(seeman ld) should allow you to re-export all symbols of the libraries it links against. This is a different fix than you seem to have in mind, but should make symbols resolve correctly nonetheless.
– Siguza
Nov 18 at 23:16
1
1
I've never personally used this, but when building your framework, the ld flag
-reexport-l<x> (see man ld) should allow you to re-export all symbols of the libraries it links against. This is a different fix than you seem to have in mind, but should make symbols resolve correctly nonetheless.– Siguza
Nov 18 at 23:16
I've never personally used this, but when building your framework, the ld flag
-reexport-l<x> (see man ld) should allow you to re-export all symbols of the libraries it links against. This is a different fix than you seem to have in mind, but should make symbols resolve correctly nonetheless.– Siguza
Nov 18 at 23:16
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53365323%2fhowto-share-secondary-dylib-inside-framework%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53365323%2fhowto-share-secondary-dylib-inside-framework%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I've never personally used this, but when building your framework, the ld flag
-reexport-l<x>(seeman ld) should allow you to re-export all symbols of the libraries it links against. This is a different fix than you seem to have in mind, but should make symbols resolve correctly nonetheless.– Siguza
Nov 18 at 23:16