fuz
fuz

Reputation: 92976

How do I link with the IOKit framework on macOS 12.4?

I am working on a C project with its own make-based build system. The project tries to interact with the SCSI subsystem through the IOKit framework. I am developing for arm64 macOS 12.4. The IT staff at our institute has set up this computer for software development, though I don't know exactly what this entails. Compiling and executing simple C programs seems to work fine.

Now, when linking the project, I get an error that the IOKit framework is not found.

ld: framework not found IOKit
fatal error: /Library/Developer/CommandLineTools/usr/bin/libtool: internal link edit command failed
smake: *** Code 1 (Operation not permitted) from command line for target '../../../../../libs/arm64-darwin-clang/pic/libmakestate.dylib'.
smake: The following command caused the error:
echo "  ==> LINKING dynamic library \"../../../../../libs/arm64-darwin-clang/pic/libmakestate.dylib\""; libtool -dynamic -o ../../../../../libs/arm64-darwin-clang/pic/libmakestate.dylib -L../../../../../libs/arm64-darwin-clang/pic -L/usr/local/lib -framework IOKit -framework CoreFoundation -install_name /opt/schily/lib/libmakestate.dylib  `echo OBJ/arm64-darwin-clang/pic/ld_file.o OBJ/arm64-darwin-clang/pic/lock.o    | cat`  -lc  

Are there any additional options I have to supply to get access to the IOKit framework? A solution that is not specific to the particular macOS version in use would be best.

I have found an old question on a similar topic, but it seems to concern very old versions of macOS and I'm not sure if it is relevant. Also, I do not have permissions to move system files around on this computer.

Please bear with me, I'm not at all experienced in macOS development and am just trying to get this code to work. If you need any additional information, do not hesitate to ask.

Upvotes: 0

Views: 592

Answers (1)

fuz
fuz

Reputation: 92976

This appears to be a consequence of using libtool to link. I was able to produce a working shared library using clang -dynamiclib as indicated in the manual.

Upvotes: 2

Related Questions