linking pthreads to a kernel driver (com.apple.kec.pthread?)

Questions and Answers about all things *OS (macOS, iOS, tvOS, watchOS)

linking pthreads to a kernel driver (com.apple.kec.pthread?)

Postby broly » Wed Apr 01, 2020 12:59 am

hello all,

i am having trouble linking pthreads to my kernel driver that i am building inside of xcode.
project source is available here: https://github.com/i3roly/CMI8788

kextlibs reports the following
GagansMacPro:CMI8788 Gagan$ kextlibs -undef-symbols -c PCIAudioDriver.kext/
For all architectures:
com.apple.iokit.IOAudioFamily = 1.0
com.apple.iokit.IOPCIFamily = 1.0b1
com.apple.kpi.iokit = 7.0
com.apple.kpi.libkern = 8.0d0

For x86_64:
6 symbols not found in any library kext:
_pthread_cond_broadcast
_pthread_mutex_init
_pthread_cond_timedwait
_pthread_mutex_unlock
_pthread_cond_init
_pthread_mutex_lock



This is my OSBundleLibraries from my Info.plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.kec.pthread</key>
<string>11.2</string>
<key>com.apple.iokit.IOAudioFamily</key>
<string>203.3</string>
<key>com.apple.iokit.IOPCIFamily</key>
<string>2.9</string>
<key>com.apple.kpi.bsd</key>
<string>12.0</string>
<key>com.apple.kpi.iokit</key>
<string>14.5</string>
<key>com.apple.kpi.libkern</key>
<string>11.2</string>
<key>com.apple.kpi.mach</key>
<string>11.2</string>
<key>com.apple.kpi.unsupported</key>
<string>11.2</string>
</dict>
</plist>


for good measure, under the 'TARGETS->Build Phases->Link Binary With Libraries' for project settings, i have added both libsystem_pthread.tbd and libpthread.tbd
AND i have added
'-lsystem_pthread -lthread -pthread' to the linker flags, and '-pthread' to the preprocessor flags, but i still get unresolved symbols.

could someone share why this is the case? why is linking pthreads so bloody hard? it shouldn't be.
broly
 
Posts: 15
Joined: Wed Apr 25, 2018 4:30 pm

Re: linking pthreads to a kernel driver (com.apple.kec.pthre

Postby broly » Wed Apr 01, 2020 3:57 pm

ok, i don't know why i didn't remind myself YOU CANNOT USE PTHREADS FOR IN-KERNEL DEVELOPMENT (see linux as an easy example).

but i am hoping in non-kernel development situation, that the above issue will no longer be one.

i am so embarrassed.

thanks guys
broly
 
Posts: 15
Joined: Wed Apr 25, 2018 4:30 pm


Return to Questions and Answers

Who is online

Users browsing this forum: No registered users and 4 guests

cron