Questions tagged [weak-linking]

74 questions
6
votes
2 answers

Xcode 7: -weak_library and -bitcode_bundle cannot be used together

When deploying to iPhone & Apple Watch with Xcode7, I got this error: ld: -weak_library and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together Would like to ask how best to resolve this issue ? Follow-ups: Apple Watch…
Felix
  • 751
  • 5
  • 10
6
votes
2 answers

iOS Framework weak link: undefined symbols error

I'm building my own framework which proposed to be distributed to other developers for including to their projects. This framework links optionally certain frameworks (e.g. CoreLocation). The problem is that when I link my framework to real…
heximal
  • 10,327
  • 5
  • 46
  • 69
5
votes
1 answer

Checking at runtime for weakly linked symbols from third-party framework in Swift

On macOS, I use an external framework (written in C) that must be installed by the user. In Swift, I need to check at runtime if it exists, and I can't use #available() since it is for OS-related features, and I am trying to track down an external…
Daniel
  • 578
  • 4
  • 17
5
votes
2 answers

GCC -O2 and __attribute__((weak))

It looks like GCC with -O2 and __attribute__((weak)) produces different results depending on how you reference your weak symbols. Consider this: $ cat weak.c #include extern const int weaksym1; const int weaksym1 __attribute__(( weak )) =…
user3234859
  • 118
  • 1
  • 6
5
votes
1 answer

Weak-linking with static libraries

I have declared an external function with a GCC weak attribute in a .c file: extern int weakFunction( ) __attribute__ ((weak)); Compiled object file has weakFunction defined as a weak symbol. Output of nm: 1791: w weakFunction I am calling…
Jaakko L.
  • 125
  • 1
  • 5
4
votes
4 answers

How to access weak linked framework in iOS?

I want to use Twitter framework for iOS 5, but be able to run my app in older OS. I added weak referenced framework (i.e. set "optional" flag) in Xcode 4.2 Target settings. Base SDK is iOS 5, iOS deployment Target is iOS 3.2. Next, I try to use…
Mike Keskinov
  • 11,614
  • 6
  • 59
  • 87
4
votes
1 answer

How can I avoid dependency on GLIBC_X.Y when using weak symbols

While working on the signal implementation in Hurd, I have run into the following problem. Basically, I add a new function to glibc, which is used by libpthread (those are from separate sources on Hurd). In order for the new libpthread to still work…
Jérémie Koenig
  • 1,198
  • 6
  • 11
4
votes
2 answers

override a weak function A with a function B

For an embedded device, I have file containing an array with function pointers storing interrupt handlers, define like that (I can't modify it): typedef void (*const ISRFunction)(void); __attribute__((weak)) void ISR0(void){ for(;;);…
Garf365
  • 3,619
  • 5
  • 29
  • 41
4
votes
2 answers

Why cannot we use the negation operator when checking for the existence of a symbol?

The answers to this question state that if (x != nil) is the same as if (x). But Apple documentation reads: Note: When checking for the existence of a symbol, you must explicitly compare it to NULL or nil in your code. You cannot use the negation…
Cœur
  • 37,241
  • 25
  • 195
  • 267
4
votes
1 answer

Alternatives to weak linking in iPhone SDK?

I'm looking to make my app compatible with older versions of iPhone OS. I did see weak linking mentioned as an option. Can I use OS version detection code to avoid code blocks that the OS can't handle? (Say iAD?) if(OS >= 4.0){ //set up iADs using…
Moshe
  • 57,511
  • 78
  • 272
  • 425
4
votes
2 answers

Different behavior of override weak function in shared library between OS X and Android

I am encountering a different behavior between OS X and Android: There is a weak function foo in my shared library, I want to override it with strong function defined in my executable. I expect the the overridden also affect the calling inside the…
sycx
  • 891
  • 6
  • 8
4
votes
3 answers

How does Java solve this untyped generic Method?

Today I come across a Function that makes me really wondering. So lets assume this simple structure for clearification. public class Animal{ public String getName(){ return null; } } public class Dog extends Animal{ @Override public String…
Rafael T
  • 15,401
  • 15
  • 83
  • 144
3
votes
2 answers

Weak-linking multiple frameworks for iPhone Apps (-weak_framework)

How do I specify -weak_framework for multiple frameworks while compiling iPhone apps for older deployment targets?
Bijoy Thangaraj
  • 5,434
  • 4
  • 43
  • 70
3
votes
2 answers

Runtime API availability check (weak linking) -- incorrect behavior on 10.5

I'm building my application on 10.6 but targeting 10.5 for deployment. I want to take advantage of the Service Management SMJobBless api when the program will run on 10.6, but I obviously will still need to use a privileged installer tool when…
Richard
  • 3,316
  • 30
  • 41
3
votes
1 answer

How do I *prevent* "weak" linking of static library symbols in Visual-C++?

As far as my practical tests go, when linking a static library (.lib) into your executable in Visual-C++, if any executable .obj file defines a duplicate symbol to one in the static library, the symbol in the static library will be silently…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337