C-function not found by linker


(Rien) #1

My project uses openSSL and that works fine.

I needed one specific function that cannot be accessed from Swift directly, so I created a C-file for that. (both .h and .c file)

The function is found during compilation.

But is then reported as “unused” and the linker reports “missing function”.

Any idea’s how this can be caused?

More info:

The .h file:

static void sslCtxSetTlsExtServernameCallback(SSL_CTX *ctx, int (*cb)(SSL *, int *, void *), void *arg);

The .c file:

static void sslCtxSetTlsExtServernameCallback(SSL_CTX *ctx, int (*cb)(SSL *, int *, void *), void *arg) {
    SSL_CTX_set_tlsext_servername_arg(ctx, arg);
    SSL_CTX_set_tlsext_servername_callback(ctx, cb);
}

Regards,
Rien

Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl


(Rien) #2

Sometimes you just have to post a stupid question to see what you did wrong :frowning:

So please disregard….

PS: it was of course the “static” (I have no clue why I did put that in there… oh well)

Regards,
Rien

Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl

···

On 11 Jan 2017, at 10:28, Rien via swift-users <swift-users@swift.org> wrote:

My project uses openSSL and that works fine.

I needed one specific function that cannot be accessed from Swift directly, so I created a C-file for that. (both .h and .c file)

The function is found during compilation.

But is then reported as “unused” and the linker reports “missing function”.

Any idea’s how this can be caused?

More info:

The .h file:

static void sslCtxSetTlsExtServernameCallback(SSL_CTX *ctx, int (*cb)(SSL *, int *, void *), void *arg);

The .c file:

static void sslCtxSetTlsExtServernameCallback(SSL_CTX *ctx, int (*cb)(SSL *, int *, void *), void *arg) {
   SSL_CTX_set_tlsext_servername_arg(ctx, arg);
   SSL_CTX_set_tlsext_servername_callback(ctx, cb);
}

Regards,
Rien

Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users