0

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

duck
  • 47
  • 5

5 Answers5

1

Actually it may be because we have defined the CCurl helper functions as extern inline, rather than as static inline. Apparently extern inline causes one of the references to the defined function to become an external name, which can cause problems if it is imported more than once.

We'll look into this.

skallner
  • 226
  • 1
  • 1
1

IBM-Swift/CCurl.git 0.2.2 has been tagged. It contains a fix for the problem mentioned here.

skallner
  • 226
  • 1
  • 1
0

Check that you don't have multiple entries under Build Phases/Compile Sources. If yes, remove them.

Also you could try cleaning your project or even run swift package generate-xcodeproj again.

Thanos
  • 844
  • 2
  • 11
  • 27
0

It's because you are importing ccurl which is already imported in the kitura-net package.

0

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.

Carl Brown
  • 26
  • 1
  • 3