duck duck - 22 days ago 9x
Swift Question

Error when Call curlHelperSetOptString from module CCurl - swift -Kitura

i use CCurl ( in my project (Kitura then i call func curlHelperSetOptString , compile "swift build" and get an error:

duplicate symbol _curlHelperSetOptString in:
/Users/xxxx/Documents/server/ServerSwift/.build/debug/ /Users/xxxx/Documents/server/ServerSwift/.build/debug/
ld: 1 duplicate symbol for architecture x86_64 :0: error:
link command failed with exit code 1 (use -v to see invocation)
:0: error: build had 1 command failures


import CCurl
var handle=curl_easy_init()
if (handle != nil) {
let url = "http: //"
let buffer=url.cString(using: .utf8)
curlHelperSetOptString(handle, CURLOPT_URL, buffer)

Help me ,plz


You're probably including CCurl directly in your Package.swift when it's already included in Kitura-Net/Package.swift.

With most Swift modules, this wouldn't be a problem, but CCurl has to have a hack in it because libCurl contains mostly variadic functions and Swift doesn't import variadic functions from C libraries. The hack creates static functions in the C header file to create non-variadic version of the libCurl functions. It's those static functions that are being duplicated here (and each module is compiled separately, so you can't #ifndef around them because they can't see each other).

Try removing the CCurl dependency from your Package.swift file and just depend on the fact that it's being included for you, and hopefully you'll be okay.