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

Compile problems when trying to link to 1.67.0 python library #193

Closed
Silarn opened this Issue Apr 12, 2018 · 16 comments

Comments

Projects
None yet
6 participants
@Silarn

Silarn commented Apr 12, 2018

I decided to give the RC2 a spin and ran into just one issue in my project. We have a DLL which links with the python .lib in windows, and when the MSVC 2017 compiler attempted to parse the library name headers in detail/config.hpp at line 108:

#define BOOST_LIB_NAME boost_python##PY_MAJOR_VERSION##PY_MINOR_VERSION

...it resulted in a linker error looking for boost_pythonPY_MAJOR_VERSIONPY_MINOR_VERSION-vc141-mt-x64-1_67.lib.

I had to modify the header to something like this in order to link properly:

#define _BPYCONCAT(A, B) A ## B
#define BPYCONCAT(A, B) _BPYCONCAT(A, B)
#define BOOST_LIB_NAME BPYCONCAT(boost_python, BPYCONCAT(PY_MAJOR_VERSION, PY_MINOR_VERSION))
@stefanseefeld

This comment has been minimized.

Member

stefanseefeld commented Apr 13, 2018

Can you please try out this fix: 2431370 ?
With a bit of luck we can still get this into the release, but unfortunately I'm unable to test it myself.
Thanks !

@Silarn

This comment has been minimized.

Silarn commented Apr 13, 2018

It looks good. I built the project with this change without issue and just to be sure I rebuilt boost. Nothing went wrong.

@stefanseefeld

This comment has been minimized.

Member

stefanseefeld commented Apr 13, 2018

Thanks for the confirmation. I have asked the Boost release manager whether he could cherry-pick this fix into the release.
Since this is fixed on the develop branch, I'm closing this issue.

@stefanseefeld

This comment has been minimized.

Member

stefanseefeld commented Apr 19, 2018

For the record: this has been merged to master. Still waiting for a bugfix release.

@liuaifu

This comment has been minimized.

liuaifu commented Apr 20, 2018

Thank you, this fix is valid.

@anton-matosov

This comment has been minimized.

anton-matosov commented Apr 24, 2018

Hi @stefanseefeld, I am experiencing same issue while building a python extension and looking for a way to disable autolinking. Can you suggest a way to do that?

@stefanseefeld

This comment has been minimized.

Member

stefanseefeld commented Apr 24, 2018

@anton-matosov Apparently the way to achieve this is to define BOOST_ALL_NO_LIB, which will disable the autolink logic. For the rest, I suppose that depends on what build system you are using...

@anton-matosov

This comment has been minimized.

anton-matosov commented Apr 24, 2018

Appreciate your quick response! It worked. I am using setuptools for the build, so simple '-DBOOST_ALL_NO_LIB' compiler flag got the job done.

@JLVarjo

This comment has been minimized.

JLVarjo commented May 28, 2018

Please note that this issue seems to be in numpy module also, namely numpy/config.hpp on line 65. By applying this fix also to this file resolved the issue.

@stefanseefeld

This comment has been minimized.

Member

stefanseefeld commented Jun 4, 2018

Right, thanks for the reminder. Fixed with b4230e9.

@illera88

This comment has been minimized.

illera88 commented Jun 29, 2018

Any idea when Boost is gonna include this fix or if there are nightly builds to get boost with this fix?

thanks

@stefanseefeld

This comment has been minimized.

Member

stefanseefeld commented Jun 30, 2018

I don't understand the question: this is fixed in master, so the upcoming release should work as intended.

@illera88

This comment has been minimized.

illera88 commented Jul 2, 2018

I'm compiling python boost doing:

C:\boost_1_67_0>boostrap.exe
C:\boost_1_67_0>.\b2.exe address-model=64 --with-python runtime-link=static toolset=msvc variant=release link=static --layout=system

It builds fine and I add the generated libboost_python36.lib and the include path to my project. The problem is that as this issue states I'm getting:

LINK : fatal error LNK1104: cannot open file 'boost_pythonPY_MAJOR_VERSIONPY_MINOR_VERSION-vc120-mt-gd-x64-1_67.lib'

This happens because boost_1_67_0 still does not have b4230e9 fix.

I guess my question is, can boost python being compiled standalone or does it require boost too? If so, how can I build python boost from this repo instead of building it using the latest boost release (which still does not include mentioned fix).

Thank you

@stefanseefeld

This comment has been minimized.

Member

stefanseefeld commented Jul 2, 2018

@illera88 as I mentioned, the fix is in master, and will be included in the 1.68 release. There is no way to fix 1.67, as that was released a while ago, and no bug fix release is planned for that.

If you want to help make sure the upcoming 1.68 release works fine, please download boost master and build that.

The question of whether Boost.Python can be built stand-alone is entirely separate from this issue. The answer is: yes, depending on what build tool you are using, you should be able to grab the current master from Boost.Python and build it with an older Boost version pre-installed on your system. See for example the README.md for how to build using Faber...

@illera88

This comment has been minimized.

illera88 commented Jul 2, 2018

Thank you @stefanseefeld . Since it was an easy fix I just changed the necessary lines and I made it compile with a 1.67 build.

Just one more question: How can I chose the Python version (and architecture) I want to build python boost against? By default is using Python 3.6 but I have a Python 2.7 I would like to use it against. How can I set that?

Thanks again

@stefanseefeld

This comment has been minimized.

Member

stefanseefeld commented Jul 2, 2018

All that depends on what build tools you are using ? Boost.Build or Faber, or something else ?
In any case, this seems entirely unrelated to this issue. Please open a new one to discuss general build questions.

iFuSiiOnzZ added a commit to carla-simulator/carla that referenced this issue Jul 31, 2018

Improve user errors
Stop build if any error was found
Enable multiprocess compilation
Add BuildPythonAPI.bat to makefile
Add BOOST_ALL_NO_LIB as workaround for boostorg/python#193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment