Framework re-export of static library symbols

I'm building an open-source framework called OgreNextMain on macOS, and it statically links to an open-source library called FreeImage. When I run the nm -gU command on the binary within the resulting framework, I see lots of the symbols from FreeImage, but a couple that I wanted to use are missing. I thought, maybe they get stripped if they are not called by OgreNextMain, so I looked into stripping options. The "strip style" in the Xcode build settings for OgreNextMain is set to "debugging symbols". I tried setting the "additional strip flags" build setting to have the "-s" option and the path to a file containing the names of the symbols I want, but that didn't have any effect.

Answered by DTS Engineer in 850660022

When building a framework like this, it’s best to create an .exp file that lists the symbols you want to export and then supply that file to the framework link stage via the -exported_symbols_list option. This gives you complete control over what is or isn’t exported.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

When building a framework like this, it’s best to create an .exp file that lists the symbols you want to export and then supply that file to the framework link stage via the -exported_symbols_list option. This gives you complete control over what is or isn’t exported.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Adding an exported symbols file seems rather painful, since it's a large C++ framework that I don't maintain. And the maintainers have taken the trouble to mark things up with __attribute__( ( visibility( "default" ) ) ).

I found that Xcode has a build setting REEXPORTED_LIBRARY_PATHS that seems like it ought to do exactly what I want, but doesn't.

Also, in the man page for ld, I found -exported_symbol symbol, but when I tried adding -exported_symbol _FreeImage_Rescale to "other linker flags", I get an error

no such file or directory: '_FreeImage_Rescale'

Accepted Answer

I found a solution to my problem. In the OTHER_LDFLAGS build setting, I added:

-Xlinker -reexported_symbols_list -Xlinker /path/to/list_of_symbols_I_want
Framework re-export of static library symbols
 
 
Q