Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Skwint

macrumors newbie
Original poster
Oct 20, 2011
4
0
Hi,
I have some C++ code which is built on snow leopard and runs on Tiger, Leopard, Snow Leopard and Lion. I am using calls from the 10.6 SDK and successfully avoiding them on Tiger at run time, so I'm pretty sure I've got my environment set up more or less right.

One call I need is fcntl. If I build on Tiger it works on Tiger. If I build on snow leopard it crashes on Tiger. It crashes at run time on the call to fcntl and the error is that _fcntl@unix2003 can't be found in libSystem.B.dylib.

I'm not sure how to go about fixing this - weak linking deals with an API that doesn't exist, but I don't understand how to deal with an API that seems to have changed? moved? something? I know it exists somewhere on Tiger because the code compiles and runs there...

Does anyone know how to call fcntl on Tiger when build against the 10.6 SDK?

Thanks,
Andy
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
One call I need is fcntl. If I build on Tiger it works on Tiger. If I build on snow leopard it crashes on Tiger. It crashes at run time on the call to fcntl and the error is that _fcntl@unix2003 can't be found in libSystem.B.dylib.

Have a look how fcntl is defined. Follow the macros back. That should tell you how to fix it. (Hint: When you use a new SDK, the compiler assumes you want to be Posix compatible. And Tiger apparently doesn't have a Posix compatible fcntl. So you need to override Posix 2003 compatibility).
 

Skwint

macrumors newbie
Original poster
Oct 20, 2011
4
0
thanks

Thanks! Google failed me - all I ever got was forum posts by other people with the same problem, and they were all solving it by linking against the 10.4 sdk.
 

Skwint

macrumors newbie
Original poster
Oct 20, 2011
4
0
hmf

This hasn't helped quite enough - the Paul Beach solution (link with 10.4) doesn't cut it - I need 10.6 calls to run on Lion. I've tried messing with the macros and they don't seem to have any impact - the $UNIX2003 is still being appended to the function name. The header file itself is even less clear than the documentation.

At the moment I am thinking my best bet is to write my own library for the sole purpose of calling fcntl and building just that library on Tiger. That seems ridiculous :(
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
This hasn't helped quite enough - the Paul Beach solution (link with 10.4) doesn't cut it - I need 10.6 calls to run on Lion. I've tried messing with the macros and they don't seem to have any impact - the $UNIX2003 is still being appended to the function name. The header file itself is even less clear than the documentation.

At the moment I am thinking my best bet is to write my own library for the sole purpose of calling fcntl and building just that library on Tiger. That seems ridiculous :(

Instead of calling fcntl (arguments) just call (fcntl) (arguments). That prevents macro evaluation.
And defining __DARWIN_ONLY_UNIX_CONFORMANCE 1 should fix the problem (after reading the header file).
 
Last edited:

Skwint

macrumors newbie
Original poster
Oct 20, 2011
4
0
ah!

so so close!

the ()s didn't have any effect, but the __DARWIN_ONLY_UNIX_CONFORMANCE did - my code now builds and runs and ... dies somewhere else. It seems that setting that flag in my main executable prevents it loading plugins compiled without it.

Thankyou though! That counts as progress in my book! :rolleyes:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.