0-1-0 / lightblue-0.4

LightBlue python module that compiles successful on OS X 10.8 (Mountain Lion)
GNU General Public License v3.0
96 stars 92 forks source link

Implicit declaration of function 'IOBluetooth*' is invalid in C99 on macos 11.1 #15

Open jsotogaviard opened 3 years ago

jsotogaviard commented 3 years ago

Project is not building because of those three errors:

/Users/isoto/dev/lightblue-0.4/src/mac/LightAquaBlue/BBServiceAdvertiser.m:128:20: Implicit declaration of function 'IOBluetoothAddServiceDict' is invalid in C99

/Users/isoto/dev/lightblue-0.4/src/mac/LightAquaBlue/BBServiceAdvertiser.m:142:3: Implicit declaration of function 'IOBluetoothObjectRelease' is invalid in C99

/Users/isoto/dev/lightblue-0.4/src/mac/LightAquaBlue/BBServiceAdvertiser.m:151:9: Implicit declaration of function 'IOBluetoothRemoveServiceWithRecordHandle' is invalid in C99

jloi commented 3 years ago

I got it to compile by changing line 66 in setup.py to

os.system("xcodebuild install -arch 'x86_64' -target LightAquaBlue -configuration Release DSTROOT=/ INSTALL_PATH=/Library/Frameworks DEPLOYMENT_LOCATION=YES ALWAYS_SEARCH_USER_PATHS=NO GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS=NO OTHER_CFLAGS='-Wno-implicit-function-declaration'")

The key here is OTHER_CFLAGS='-Wno-implicit-function-declaration'.

But after that I got a linking error.

"_IOBluetoothLocalDeviceReadAddress", referenced from:
      +[BBLocalDevice getAddressString] in BBLocalDevice.o
  "_IOBluetoothLocalDeviceReadClassOfDevice", referenced from:
      +[BBLocalDevice getClassOfDevice] in BBLocalDevice.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1
jloi commented 3 years ago

Apple removed the IOBluetoothLocalDeviceReadAddress and IOBluetoothLocalDeviceReadClassOfDevice, among others from IOBluetoothUserLib.h since MacOS 10.8 (see API diff). I don't know what to replace those methods with. Using LightBlue may be a dead end for MacOS 11.

JuliusNmn commented 3 years ago

I have replaced the deprecated function references. The framework builds without errors and seems to be working for my use cases (PyBluez), but I don't know how to properly test it. I have opened a pull request anyway.

burricks commented 2 years ago

Can you please add the link to the PR? I'd like to modify my code in the same way @JuliusNmn

JuliusNmn commented 1 year ago

Here you go: Pull request 19