Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using CCurl in a Kitura based app produces linker errors on Linux only #5

Closed
dsperling opened this issue Jun 30, 2016 · 2 comments
Closed

Comments

@dsperling
Copy link
Contributor

In an attempt to use CCurl to develop an SMTP client in Swift, I ran into this problem where the inline functions in shim.h produce linker errors on Linux. macOS works fine.

Functions such as curlHelperSetOptString and curlHelperSetOptInt work fine inside Kitura, but when they are used in an app, a multiple definition of 'curlHelperSetOptString' error occurs.

The functions are defined as inline in shim.h so I am not sure why the compiler is creating a symbol.

Attached is a HelloWorld Kitura based sample app that demonstrates the problem. Tun run execute:

HelloWorld.zip

docker-compose up

I have tried a few changes such as changing "extern inline" to "inline", or moving the declarations to a 'C' file but these cause different issues.

Error output:

test_1  | Compile Swift Module 'LoggerAPI' (1 sources)
test_1  | Compile Swift Module 'Socket' (3 sources)
test_1  | Compile Swift Module 'SwiftyJSON' (2 sources)
test_1  | Compile Swift Module 'KituraTemplateEngine' (1 sources)
test_1  | Compile CHttpParser utils.c
test_1  | clang: warning: argument unused during compilation: '-Xcc'
test_1  | Compile CHttpParser http_parser.c
test_1  | Compile Swift Module 'KituraSys' (3 sources)
test_1  | clang: warning: argument unused during compilation: '-Xcc'
test_1  | Linking CHttpParser
test_1  | Compile Swift Module 'KituraNet' (12 sources)
test_1  | Compile Swift Module 'Kitura' (35 sources)
test_1  | Compile Swift Module 'HelloWorld' (1 sources)
test_1  | Linking .build/debug/HelloWorld
test_1  | /usr/bin/ld.gold: error: /test/.build/debug/KituraNet.build/ClientRequest.swift.o: multiple definition of 'curlHelperSetOptInt'
test_1  | /usr/bin/ld.gold: /test/.build/debug/HelloWorld.build/main.swift.o: previous definition here
test_1  | /usr/bin/ld.gold: error: /test/.build/debug/KituraNet.build/ClientRequest.swift.o: multiple definition of 'curlHelperSetOptList'
test_1  | /usr/bin/ld.gold: /test/.build/debug/HelloWorld.build/main.swift.o: previous definition here
test_1  | /usr/bin/ld.gold: error: /test/.build/debug/KituraNet.build/ClientRequest.swift.o: multiple definition of 'curlHelperSetOptReadFunc'
test_1  | /usr/bin/ld.gold: /test/.build/debug/HelloWorld.build/main.swift.o: previous definition here
test_1  | /usr/bin/ld.gold: error: /test/.build/debug/KituraNet.build/ClientRequest.swift.o: multiple definition of 'curlHelperSetOptString'
test_1  | /usr/bin/ld.gold: /test/.build/debug/HelloWorld.build/main.swift.o: previous definition here
test_1  | clang: error: linker command failed with exit code 1 (use -v to see invocation)
test_1  | <unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
test_1  | <unknown>:0: error: build had 1 command failures
test_1  | swift-build: error: exit(1): /root/swift-DEVELOPMENT-SNAPSHOT-2016-06-06-a-ubuntu15.10/usr/bin/swift-build-tool -f /test/.build/debug.yaml
helloworld_test_1 exited with code 1
@dsperling
Copy link
Contributor Author

PR #8 should fix this. I will retest and close.

@dsperling
Copy link
Contributor Author

Fixed in PR #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant