Boost.Python dll being skipped on compile - c++

I am new to python programming and am looking to incorporate some C++ dll's into python. I found boost.python to be the most common answer to this issue and have been trying to test it with a simple 'hello world' application that comes with the boost.python package. Following the tutorial at http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/python/hello.html
I am running Windows 7 using Microsoft Visual Studio 10.0.
My python directory is 'C:\Python27', Boost is 'C:\Boost\boost_1_54_0'
I have set the user-config.jam file to using msvc : 10.0 ; and using python : 2.7 : C:\\Python27 ;
When I invoke bjam I get the following..
...failed msvc.link.dll C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.dll C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.lib C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.pdb...
...removing C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.lib
...removing C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.pdb
...skipped <pbin\msvc-10.0\debug>hello_ext.pyd for lack of <pC:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug>boost_python-vc100-gd-1_54.lib...
...skipped <pbin\msvc-10.0\debug>hello_ext.lib for lack of <pC:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug>boost_python-vc100-gd-1_54.lib...
...skipped <pbin\msvc-10.0\debug>hello_ext.pdb for lack of <pC:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug>boost_python-vc100-gd-1_54.lib...
...skipped <p.>boost_python-vc100-gd-1_54.dll for lack of <pC:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug>boost_python-vc100-gd-1_54.dll...
...skipped <p.>hello_ext.pyd for lack of <pbin\msvc-10.0\debug>hello_ext.pyd...
...skipped <pbin\hello.test\msvc-10.0\debug>hello for lack of <pbin\msvc-10.0\debug>hello_ext.pyd...
...failed updating 3 targets...
...skipped 7 targets...
All that is created is an .obj file in:
C:\Boost\boost_1_54_0\libs\python\example\tutorial\bin\msvc-10.0\debug
From my basic limited knowledge it appears the files that are relied upon are being removed just before compilation. I have searched long and hard for a solution but to no avail. It feels like I am missing something very elementary.
Thank you.
EDIT: Updating to python 3.3 seems to have gotten me closer. It is no longer removing the two files from bin.v2, but it is still not compiling a .dll or .pyb file.
PS C:\Boost\boost_1_54_0\libs\python\example\tutorial> .\bjam
...patience...
...patience...
...found 1681 targets...
...updating 7 targets...
msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd
LINK : fatal error LNK1104: cannot open file 'boost_python-vc100-mt-gd-1_54.lib'
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 >nul
link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console/out:"bin\msvc-10.0\debug\hello_ext.pyd"
/IMPLIB:"bin\msvc-10.0\debug\hello_ext.lib" /LIBPATH:"C:\Python33\libs" #"bin\msvc-10.0\debug\hello_ext.pyd.rsp"
if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
...failed msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd bin\msvc-10.0\debug\hello_ext.lib bin\msvc-10.0\debug\hello_ext.pdb bin\msvc-10.0\debug\hello_ext.pdb...
...skipped <p.>hello_ext.pyd for lack of <pbin\msvc-10.0\debug>hello_ext.pyd...
...failed updating 3 targets...
...skipped 1 target...

SOLVED: First I rebuilt boost.python by running b2 toolset=msvc-10.0 --with-python --user-config=user-config.jam --build-type=complete stage in C:\Boost\boost_1_54_0 then I copied the boost_python-vc100-mt-gd-1_54.lib file into the tutorial folder. Not sure this is the best solution but it seems to now be working.

I suggest to mention python installation path in your configuration file:
using python : 2.7 : C:\Python27\;
Did you cd into the same directory where jamroot and hello.cpp is located?

Related

"Cannot open input file 'libcrypto.lib'" while installing libtorrent C++ library

I am attempting to install the libtorrent C++ library (cloned from GitHub repository) on Windows 11 with OpenSSL 1.1.1i installed and Visual Studio 2022.
Invoking b2 in my libtorrent source folder is returning the error LINK : fatal error LNK1181: cannot open input file 'libcrypto.lib'.
The file libcrypto.lib definitely exists in C:\Users\Me\openssl and C:\Users\Me\openssl is in my PATH. Installation was running fine until this point.
My steps were:
$ set LIB="C:\Users\Me\openssl";%LIB%
$ set INCLUDE="C:\Users\Me\openssl\include";%INCLUDE%
$ set BOOST_ROOT=c:\boost_1_80_0
$ set BOOST_BUILD_PATH=%BOOST_ROOT%\tools\build
$ cd "C:\Users\Me\libtorrent"
$ b2
The last step returns:
...updating 3 targets... msvc.link.dll
bin\msvc-14.3\debug\cxxstd-14-iso\threading-multi\torrent-rasterbar.dll
LINK : fatal error LNK1181: cannot open input file 'libcrypto.lib'
call "bin\standalone\msvc\msvc-14.3\msvc-setup.bat" >nul link /NOLOGO /INCREMENTAL:NO
#"bin\msvc-14.3\debug\cxxstd-14-iso\threading-multi\torrent-rasterbar.dll.rsp"
...failed msvc.link.dll
bin\msvc-14.3\debug\cxxstd-14-iso\threading-multi\torrent-rasterbar.dll
bin\msvc-14.3\debug\cxxstd-14-iso\threading-multi\torrent.lib
bin\msvc-14.3\debug\cxxstd-14-iso\threading-multi\torrent-rasterbar.pdb...
...removing
bin\msvc-14.3\debug\cxxstd-14-iso\threading-multi\torrent-rasterbar.pdb
...failed updating 3 targets...
Edit: Fixed a typo
Solved by copying libcrypto.lib to LIB path specified in user-config.jam.

Boost build fails with "failed common.mkdir build"

I am trying to build Boost 1.77 using Visual Studio Enterprise 2017 on Windows 10:
I download file boost_1_77_0.zip and uncompress it.
I open an "x86 Native Tools Command Prompt" and cd to the boost_1_77_0 directory.
I run bootstrap.
I run b2...
.\b2 --build-dir=build/x86 address-model=32 architecture=x86 toolset=msvc-14.1 --build-type=complete stage
...this fails and in file boost_1_77_0\build\x86\boost\bin.v2\config.log I have:
...found 20 targets...
...updating 16 targets...
if not exist "build\\" mkdir "build"
...failed common.mkdir build...
...skipped build\x86 for lack of build...
...skipped build\x86\boost for lack of build\x86...
[snip]
...skipped build\x86\boost\bin.v2\check\predef\msvc-14.1\release\address-model-32\architecture-x86\runtime-link-static\threading-multi for lack of build\x86\boost\bin.v2\check\predef\msvc-14.1\release\address-model-32\architecture-x86\runtime-link-static...
...skipped <pbuild\x86\boost\bin.v2\check\predef\msvc-14.1\release\address-model-32\architecture-x86\runtime-link-static\threading-multi>predef_check_cc_09a06289f4560e2f553bb0cbbec71436.obj for lack of build\x86\boost\bin.v2\check\predef\msvc-14.1\release\address-model-32\architecture-x86\runtime-link-static\threading-multi...
...skipped 3 targets...
...found 1 target...
...updating 1 target...
config-cache.write build\x86\boost\bin.v2\project-cache.jam
This program is blocked by group policy. For more information, contact your system administrator.
type "C:\Users\my_username\AppData\Local\Temp\jam5298fccb.000" > "build\x86\boost\bin.v2\project-cache.jam"
...failed config-cache.write build\x86\boost\bin.v2\project-cache.jam...
...failed updating 1 target...
Any idea what I'm doing wrong? I see that error about group policy but I can't find the root cause of it. When I execute that "type" command at the command line it completes successfully.
Edit: I found a solution which I posted below as an answer. Stackoverflow forbids me from marking that answer as accepted because my account is not old enough.
Something within the bowels of the boost build system is attempting to do something for which I lack the necessary permissions. The workaround was to launch a command window from within Visual Studio (rather than from the windows start menu) and invoke the build from there. The organization is forced to allow VS to run with elevated permissions, and these are inherited by the command window, which then allows the boost build to succeed.

boost - adding path to 'corecrt.h'

I have a hello.cpp file and I used a tutorial about boost installation from here.
I did everything like they said and I have a problem trying to run it.
I get:
...found 9 targets...
...updating 3 targets...
compile-c-c++ bin\msvc-14.0\debug\hello.obj
hello.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\crtdefs.h(10): fatal error C1083: Cannot open include file: 'corecrt.h': No such file or directory
call "C:\Users\Paula\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
cl /Zm800 -nologo #"bin\msvc-14.0\debug\hello.obj.rsp"
...failed compile-c-c++ bin\msvc-14.0\debug\hello.obj...
...skipped <pbin\msvc-14.0\debug>hello.exe for lack of <pbin\msvc-14.0\debug>hello.obj...
...skipped <pbin\msvc-14.0\debug>hello.pdb for lack of <pbin\msvc-14.0\debug>hello.obj...
...failed updating 1 target...
...skipped 2 targets...
I have corecrt.h in:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt
and in:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
I tried setting includes and libraries like here Unable to compile and link simple C++ program with Visual Studio 2015 command line tools but it doesn't work for me. I tried to find help here: Introducing the Universal CRT, but I'm not creating any project in VS, just trying to run one with a Command Prompt and I'm not sure what to do in my case. I'm totally new in this topic and I know my question may be stupid, but I really need it. I spent many hours trying to solve it and I have nothing.
Found solution here: https://svn.boost.org/trac/boost/ticket/11487
1) Go to %TEMP% folder
2) Remove all b2_*.cmd files

Skipped <dir> for lack of ... error while trying to install Boost 1.49 on Ubuntu 11.04

While trying to install Boost 1.49, I keep getting a persistent issue when I reach the stage where I use the bjam script. For reference, I am following the install instructions linked here, but I've also referenced the boost.org install page too. The procedures are essentially identical and both give the same issue.
I downloaded the tar file into the directory where I keep all of the software that I install: /home/ely/Software/Boost/boost_1_49_0/
I want the Boost stuff to install into the directory /usr/include/boost_1_49/ so I use the following commands:
$ ./bootstrap.sh --prefix=/usr/include/boost_1_49 --libdir=/usr/include/boost_1_49/lib
$ ./bjam variant=release link=shared install
The first command takes a bit of time, but seems to succeed and yields no errors. The second command takes much longer and then consistently outputs stuff like this:
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/stdexcept for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/iomanip for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/new for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/fstream for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/set for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/locale for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/string for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/limits for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/complex for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/queue for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/stack for lack of /usr/include/boost_1_49/include/boost...
...skipped <p/usr/include/boost_1_49/include/boost>tr1/tr1/unordered_set for lack of /usr/include/boost_1_49/include/boost...
And at the bottom of all these skips, it always says:
...failed updating 28 targets...
...skipped 9778 targets...
I have repeatedly checked the generated project file, project-config.jam and it lists the correct path names for the variables prefix, exec-prefix, libdir, and includedir, so I don't think that the .jam file is the issue.
I also thought maybe it was a permissions issue with creating folders in /usr/include. So I chmoded /usr/include/boost_1_49 to 777, tried the commands again, and get the same result.
Does anyone have an idea about how to fix this problem, and ultimately how to get Boost installed so that the files can be found in /usr/include/boost_1_49/?
Added
If I just directly put the tar file into the directory I want, /usr/include.boost_1_49, then the install process finishes successfully without all of the skips, and it tells me the following:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/usr/include/boost_1_49
The following directory should be added to linker library paths:
/usr/include/boost_1_49/stage/lib
But even after adding these to the appropriate .conf files that I use, and issuing sudo ldconfig to refresh the paths, I get errors when trying to include Boost things. For example, if I try to include the file boost/math/distributions.hpp, then I get the error:
/usr/include/boost_1_49/boost/math/distributions.hpp:25: fatal error: boost/math/distributions/geometric.hpp: No such file or directory
I manually verified that the geometric.hpp file is located in the correct place, it just cannot see it. I'm guessing that all of the #include <boost...> lines in distributions.hpp are not correctly identifying the version in /usr/include/boost_1_49, but I have no clue why they aren't or how to change it so they are.
I was having the same issue until I realize the username I was using to run the bjam command did not have permission to write to the /usr/include directory.
You need to run the bjam command as:
sudo ./bjam --your-options--

Trouble building boost 1.48

I am having trouble building boost 1.48 using my normal build command line, which in a Visual Studio x64 Win64 command prompt consists of:
bjam -j 8 --without-mpi --without-python --build-dir=vc100-bld-64-bit
--build-type=complete --toolset=msvc-10.0 architecture=x86
address-model=64 --stagedir=64-bit-vc100 debug-symbols=on
debug-store=database stage
The errors I get are ...failed compile lines towards the bottom of the following output excerpt which complain about precompiled header inconsistencies:
...patience...
...patience...
...patience...
...patience...
...found 9190 targets...
...updating 3251 targets...
common.mkdir 64-bit-vc100
common.mkdir 64-bit-vc100\lib
common.mkdir vc100-bld-64-bit\boost\bin.v2\libs\math\build
common.mkdir vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0
common.mkdir vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug
common.mkdir vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64
common.mkdir vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86
common.mkdir vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database
common.mkdir vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database\link-static
common.mkdir vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database\link-static\runtime-link-static
compile-c-c++-pch vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database\link-static\runtime-link-static\pch.pch
pch.pch.cpp
compile-c-c++ vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database\link-static\runtime-link-static\assoc_laguerre.obj
assoc_laguerre.cpp
libs\math\build\..\src\tr1\assoc_laguerre.cpp(6) : error C2858: command-line option 'program database name (/Fde:\dev\devel\libs\boost\boost_1_48_0\vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store
-database\link-static\runtime-link-static\libboost_math_tr1-vc100-sgd-1_48.pdb)' inconsistent with precompiled header, which used '/Fde:\dev\devel\libs\boost\boost_1_48_0\vc100.pdb'
libs\math\build\..\src\tr1\assoc_laguerre.cpp(6) : error C2859: e:\dev\devel\libs\boost\boost_1_48_0\vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database\link-static\runtime-link-static\libbo
ost_math_tr1-vc100-sgd-1_48.pdb is not the pdb file that was used when this precompiled header was created, recreate the precompiled header.
call "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 >nul
cl /Zm800 -nologo #"vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database\link-static\runtime-link-static\assoc_laguerre.obj.rsp"
...failed compile-c-c++ vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database\link-static\runtime-link-static\assoc_laguerre.obj...
compile-c-c++ vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store-database\link-static\runtime-link-static\assoc_legendre.obj
assoc_legendre.cpp
libs\math\build\..\src\tr1\assoc_legendre.cpp(6) : error C2858: command-line option 'program database name (/Fde:\dev\devel\libs\boost\boost_1_48_0\vc100-bld-64-bit\boost\bin.v2\libs\math\build\msvc-10.0\debug\address-model-64\architecture-x86\debug-store
-database\link-static\runtime-link-static\libboost_math_tr1-vc100-sgd-1_48.pdb)' inconsistent with precompiled header, which used '/Fde:\dev\devel\libs\boost\boost_1_48_0\vc100.pdb'
Is there something about my build command that makes the build fail?
Update: The problems occur due to the debug-store=database command line option to bjam. Is this option's syntax incorrect or did it change in 1.48?
Update 2: If you turn off precompiled headers by adding the pch=off option to the command, this problem goes away, but the build is probably slower, because precompiled headers are disabled.