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

Fix examples for Windows. #14

Merged
merged 1 commit into from
Jun 29, 2015

Conversation

DanielKeep
Copy link
Contributor

This fixes a linking issue with integers, and updates the Python code
to run the correct interpreter and use the proper DLL names.

integers

The problem here is that, on Windows, if you don't use any symbols from
the standard library and create a dynamic library, linking will fail.
This is a known issue (rust-lang/rust#18807) and the only half-way decent
solution is to include a dead function that does use something from the
standard library.

Python

Two changes. First, I've added a hashbang to invoke the correct Python
interpreter. On Windows, it's common to execute scripts directly without
specifying the interpreter. In addition, it is not common to have
multiple versions of Python accessible on the PATH at one time. As such,
Python on Windows comes with a "launcher" that reads the hashbang and
executes the appropriate version of Python.

Anyone with Python 3.x installed will almost certainly have that as the
default, so indicating that the script needs Python 2.x specifically is
a really good idea.

Also, the existing examples do not correctly determine the name of the
Windows libraries being loaded. Two things: they end in .dll and they
do not start with lib.

Miscellaneous

I have made no attempt to get these working on Windows, as the examples just immediately segfault for no apparent reason and, to be honest, I don't care enough about Ruby to work out why. :P

I'm also working on doc changes separately.

This fixes a linking issue with integers, and updates the Python code
to run the correct interpreter and use the proper DLL names.

# `integers`

The problem here is that, on Windows, if you don't use any symbols from
the standard library *and* create a dynamic library, linking will fail.
This is a known issue (rust-lang/rust#18807) and the only half-way decent
solution is to include a dead function that *does* use something from the
standard library.

# Python

Two changes.  First, I've added a hashbang to invoke the correct Python
interpreter.  On Windows, it's common to execute scripts directly without
specifying the interpreter.  In addition, it is *not* common to have
multiple versions of Python accessible on the PATH at one time.  As such,
Python on Windows comes with a "launcher" that reads the hashbang and
executes the appropriate version of Python.

Anyone with Python 3.x installed will almost certainly have *that* as the
default, so indicating that the script needs Python 2.x specifically is
a really good idea.

Also, the existing examples do not correctly determine the name of the
Windows libraries being loaded.  Two things: they end in `.dll` and they
*do not* start with `lib`.
@shepmaster
Copy link
Owner

Thanks for the updates! The Rust issue is an interesting one, and I might need to start a "gotchas" page to catalog items like that.

I have made no attempt to get these working on Windows, as the examples just immediately segfault for no apparent reason

Maybe a word went missing here? I'm not sure what you are referring to with "these". I'll merge these after I have a better understanding of what's broken 😃

@DanielKeep
Copy link
Contributor Author

Oh, whoops; the "Miscellaneous" header used to be "Ruby", but then I added the stuff about doc changes, so I changed it and forgot to adjust the existing paragraph. To be clear: the Ruby examples segfault. The C and Python ones work fine. :P

@shepmaster
Copy link
Owner

OK. Since I don't have much ability of automated testing on Windows, I'm afraid those will always be second-class citizens. Having some Windows knowledge is hopefully better than none, thanks!

shepmaster added a commit that referenced this pull request Jun 29, 2015
@shepmaster shepmaster merged commit 4e31a4c into shepmaster:master Jun 29, 2015
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.

2 participants