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

[SR-3152] Linker errors when building C++ with Swift Package Manager #5176

Closed
jpsim opened this issue Nov 7, 2016 · 3 comments
Closed

[SR-3152] Linker errors when building C++ with Swift Package Manager #5176

jpsim opened this issue Nov 7, 2016 · 3 comments
Assignees
Labels

Comments

@jpsim
Copy link
Contributor

jpsim commented Nov 7, 2016

Previous ID SR-3152
Radar None
Original Reporter @jpsim
Type Bug
Status Resolved
Resolution Done
Environment

Tested with Swift 3.0 and 3.0.1 on Darwin and Linux.

Additional Detail from JIRA
Votes 1
Component/s Package Manager
Labels Bug
Assignee @aciidb0mb3r
Priority Medium

md5: 850e64042f6694e1a10e9735daaf75a4

Issue Description:

With the minimal C++ fixture from https://github.com/aciidb0mb3r/SPM-Cpp-Fixture, `swift build` fails with the following output:

Compile cpplib cpplib.cpp
Linking cpplib
Compile cwrapper cwapper.cpp
Compile cpp-exec main.cpp
Linking cwrapper
Compile Swift Module 'swift_exec' (1 sources)
Linking ./.build/debug/swift-exec
Linking cpp-exec
Undefined symbols for architecture x86_64:
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(int)", referenced from:
      _main in main.cpp.o
  "std::__1::cout", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
@ankitspd
Copy link
Member

ankitspd commented Nov 7, 2016

Looks like SwiftPM is not detecting C++ files for some reason. A simple workaround for now is:

swift build -Xlinker -lc++

@ankitspd
Copy link
Member

ankitspd commented Nov 8, 2016

#784

@jpsim
Copy link
Contributor Author

jpsim commented Nov 9, 2016

PR was just closed. Thanks Ankit! #784

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants