Skip to content

Add c++ linking example #318

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

Merged
merged 2 commits into from
Oct 7, 2017
Merged

Conversation

thibaultbarbie
Copy link
Contributor

I added an example for the compilation and linking of a bundled C++ library (#296).

Copy link
Contributor

@j-haj j-haj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think this looks really good! Great work! I only have one nitpick on wording..


[![cc-badge]][cc] [![cat-development-tools-badge]][cat-development-tools]

Linking a bundled C++ library is almost the same as linking it with a C library. The main difference is the [`cpp`][cc-build-cpp] option that should be put to `true` and the addition of `extern "C"` in the foo.cpp file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nitpicks here. I think there is room to improve the clarity of these sentences.

Linking a bundled C++ library is almost the same as linking it with a C library.

I would reword this. I understand what you are saying here, but the use of "it" here technically refers to the bundled C++ library, although it seems you are using it to refer to the compiled binary. Something along the lines of "Linking a bundled C++ library is very similar to linking a bundled C library."

The main difference is the [cpp][cc-build-cpp] option that should be put to true and the addition of extern "C" in the foo.cpp file.

I would reword this as well. cpp(true) is a method used as part of the Builder pattern, not technically an option. I would reword to something along these lines:

"The two core differences when compiling and statically linking a bundled C++ library are specifying a C++ compiler via the builder method cpp(true) and preventing name mangling by the C++ compiler by adding the extern "C" section at the top of our C++ source file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion! I agree it is a far better explanation now.

@budziq budziq merged commit b844035 into rust-lang-nursery:master Oct 7, 2017
@budziq
Copy link
Collaborator

budziq commented Oct 7, 2017

Nicely done @thibaultbarbie !

Thanks for the great help @j-haj !

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

Successfully merging this pull request may close these issues.

3 participants