i use CCurl (https://github.com/IBM-Swift/CCurl.git) in my project (Kitura https://github.com/IBM-Swift/Kitura) then i call func curlHelperSetOptString , compile "swift build" and get an error:
duplicate symbol _curlHelperSetOptString in: /Users/xxxx/Documents/server/ServerSwift/.build/debug/ServerSwift.build/UploadService.swift.o /Users/xxxx/Documents/server/ServerSwift/.build/debug/KituraNet.build/ClientRequest.swift.o 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
code:
import CCurl
var handle=curl_easy_init()
if (handle != nil) {
let url = "http: //example.com/"
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.