I’m having issues using C++ code with the Swift PM. Simple examples work fine as long as I don’t use anything in the C++ standard library, otherwise the programs don’t compile.
My guess is that the Swift PM internally uses clang (as opposed to clang++) to compile C++ code, and while clang can compile normal C++ code it can’t link against the C++ standard library. Is that it?
The second example on the link below shows working C++ code with Swift. If I try to add a simple call to std::cout, for instance, the program stops compiling.
Thanks for any help :)
link: Creating Objective-C and C++ packages using Swift Package Manager – ankit.im
ddunbar
(Daniel Dunbar)
2
This was just fixed on trunk:
[SR-3152] Linker errors when building C++ with Swift Package Manager · Issue #5176 · apple/swift-package-manager · GitHub
In the meantime, you can either use a recent snapshot from swift.org, or you can pass `-Xlinker -lc++` on the command line to work around the problem.
- Daniel
···
On Nov 12, 2016, at 1:42 PM, Vinicius Vendramini via swift-users <swift-users@swift.org> wrote:
I’m having issues using C++ code with the Swift PM. Simple examples work fine as long as I don’t use anything in the C++ standard library, otherwise the programs don’t compile.
My guess is that the Swift PM internally uses clang (as opposed to clang++) to compile C++ code, and while clang can compile normal C++ code it can’t link against the C++ standard library. Is that it?
The second example on the link below shows working C++ code with Swift. If I try to add a simple call to std::cout, for instance, the program stops compiling.
Thanks for any help :)
link: Creating Objective-C and C++ packages using Swift Package Manager – ankit.im
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users