简体   繁体   中英

Cannot resolve osx compile error

I am trying to use IOKit library example for retrieving osx related system information as described here: https://developer.apple.com/library/mac/technotes/tn1103/_index.html

Undefined symbols for architecture x86_64:

"_IOObjectRelease", referenced from: ...

"_IORegistryEntryCreateCFProperty", referenced from: ...

"_IOServiceGetMatchingService", referenced from: ...

"_IOServiceMatching", referenced from: ...

"_kIOMasterPortDefault", referenced from: ...

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am using both "-framework CoreFoundation" and "-framework IOKit".

It is not duplicate because I had not linked it against wrong target, but I had typo :(

Are you using -framework IOKit in the link command for your final executable file, or when linking a static library which you then link into your executable? Static libraries cannot link against dynamic libraries and frameworks themselves, you must do this at the executable or dylib (incl. bundles or frameworks) stage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM