Hi there, I want to build my kotlin multiplatform ...
# multiplatform
p
Hi there, I want to build my kotlin multiplatform project as shared library on windows, and call it from cpp code. I have such classes:
Copy code
// common main
abstract class PeerConnectionClientFactory() {
    data class Config(
        val videoCaptureImpl: Int,
        val videoCaptureWidth: Int,
        val videoCaptureHeight: Int,
        val videoCaptureFps: Int,
        val initCameraFace: Int,
        val privateConfig: PrivateConfig,
    )

    open class PrivateConfig
}

// mingw main
data class WinPrivateConfig(
    internal val hwnd: COpaquePointer,
) : PeerConnectionClientFactory.PrivateConfig()
It seems impossible to create
PeerConnectionClientFactory.Config
with
WinPrivateConfig
, because the generated header file looks like this:
Copy code
struct {
  struct {
    .....
  } Companion;
  kmp_webrtc_KType* (*_type)(void);
  kmp_webrtc_kref_com_piasy_kmp_webrtc_PeerConnectionClientFactory_Config (*Config)(kmp_webrtc_KInt videoCaptureImpl, kmp_webrtc_KInt videoCaptureWidth, kmp_webrtc_KInt videoCaptureHeight, kmp_webrtc_KInt videoCaptureFps, kmp_webrtc_KInt initCameraFace, kmp_webrtc_kref_com_piasy_kmp_webrtc_PeerConnectionClientFactory_PrivateConfig privateConfig);
  kmp_webrtc_KInt (*get_initCameraFace)(kmp_webrtc_kref_com_piasy_kmp_webrtc_PeerConnectionClientFactory_Config thiz);
  kmp_webrtc_kref_com_piasy_kmp_webrtc_PeerConnectionClientFactory_PrivateConfig (*get_privateConfig)
  .......
  const char* (*toString)(kmp_webrtc_kref_com_piasy_kmp_webrtc_PeerConnectionClientFactory_Config thiz);
} Config;
struct {
  kmp_webrtc_KType* (*_type)(void);
  kmp_webrtc_kref_com_piasy_kmp_webrtc_PeerConnectionClientFactory_PrivateConfig (*PrivateConfig)();
} PrivateConfig;

struct {
  kmp_webrtc_KType* (*_type)(void);
  kmp_webrtc_kref_com_piasy_kmp_webrtc_WinPrivateConfig (*WinPrivateConfig)(void* hwnd);
  kmp_webrtc_kref_com_piasy_kmp_webrtc_WinPrivateConfig (*copy)(kmp_webrtc_kref_com_piasy_kmp_webrtc_WinPrivateConfig thiz, void* hwnd);
  kmp_webrtc_KBoolean (*equals)(kmp_webrtc_kref_com_piasy_kmp_webrtc_WinPrivateConfig thiz, kmp_webrtc_kref_kotlin_Any other);
  kmp_webrtc_KInt (*hashCode)(kmp_webrtc_kref_com_piasy_kmp_webrtc_WinPrivateConfig thiz);
  const char* (*toString)(kmp_webrtc_kref_com_piasy_kmp_webrtc_WinPrivateConfig thiz);
} WinPrivateConfig;
The “constructor”
Config
method accept a
kmp_webrtc_kref_com_piasy_kmp_webrtc_PeerConnectionClientFactory_PrivateConfig
, but
kmp_webrtc_kref_com_piasy_kmp_webrtc_WinPrivateConfig
doesn’t have any relationship with it. Although I can work around this with a kotlin method like this:
Copy code
fun createPcClientFactoryConfig(
    config: PeerConnectionClientFactory.Config, privateConfig: WinPrivateConfig
): PeerConnectionClientFactory.Config {
    return PeerConnectionClientFactory.Config(
        config.videoCaptureImpl, config.videoCaptureWidth, config.videoCaptureHeight, config.videoCaptureFps,
        config.initCameraFace, privateConfig
    )
}
Is this a designed behavior?
And is it possible to build a shared library with release configuration but also produce symbol file for Windows target? (similar to cmake RelWithDebInfo)
Hi guys, could somebody help me to take a look at this? thank you!