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.
Related
I have built libtorrent with boost with this commands in the boost root folder :
bootstrap.bat
b2 --hash cxxstd=14 release
and after I have added BOOST_ROOT and BOOST_BUILD_PATH to PATH variable.
I also have downloaded OpenSSL and build it then have copied to Visual studio 15 2017 compiler include and libs folder repectively.
Next in the libtorrent root folder I have run this commands:
b2 variant=release link=shared
b2 install --prefix=build
The build was successful and libtorrent c++ library has created.
and after that I have run these commands :
py setup.py build
py setup.py install
They executed with no errors and libtorrent installed in my python
libs/site-packages folder. But when I import it this error shows:
Python Import Error
[]
What build steps might I have done wrong?
Os : Windows 10 x64
Python : 3.9.5 x64
Libtorrent : 2.0.5
Boost : 1.78.0
I have followed from the libtorrent docs :
https://libtorrent.org/building.html
and
https://www.libtorrent.org/python_binding.html
What did I do ?
Basically following: https://github.com/arvidn/libtorrent/blob/master/docs/building.rst#downloading-and-building
Unzipping boost_1_78_0.zip into D:\boost_1_78_0, and running:
set BOOST_ROOT=D:\boost_1_78_0
set BOOST_BUILD_PATH=%BOOST_ROOT%\tools\build
(cd %BOOST_ROOT% && .\bootstrap.bat)
echo using msvc ; >>%HOMEDRIVE%%HOMEPATH%\user-config.jam
%BOOST_ROOT%\b2.exe --hash release
After this i got:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
D:\boost_1_78_0
The following directory should be added to linker library paths:
D:\boost_1_78_0\stage\lib
I think this is where i started to fail, I did not read this the first time, and now I am asking meself where/how should the "compiler include paths" and "linker library paths" be set .?
When trying to compile libtorrent, using the command-line you provided (b2 msvc-14.2 variant=release link=static runtime-link=static debug-symbols=on), i got:
CXXFLAGS =
LDFLAGS =
OS = NT
building boost from source directory: D:/boost_1_78_0
Performing configuration checks
- default address-model : 64-bit (cached) [1]
- default architecture : x86 (cached) [1]
[1] msvc-14.2
...patience...
...patience...
...patience...
...found 3888 targets...
...updating 78 targets...
compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj
hasher.cpp
D:\TEMP\libtorrent\libtorrent\include\libtorrent/hasher.hpp(66): fatal error C1083: Cannot open include file: 'openssl/sha.h': No such file or directory
call "bin\standalone\msvc\msvc-14.2\msvc-setup.bat" >nul
cl /Zm800 -nologo "src\hasher.cpp" -c -Fo"bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj" -TP /bigobj /wd4251 /wd4268 /wd4275 /wd4373 /wd4503 /wd4675 /EHs /std:c++14 /GR /Zc:throwingNew /O2 /Z7 /Ob2 /W4 /MT /Zc:forScope /Zc:wchar_t /Zc:inline /Gw /favor:blend -DBOOST_ALL_NO_LIB -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_HAS_STD_CHRONO -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_DEPRECATED -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DNDEBUG -DOPENSSL_NO_SSL2 -DTORRENT_BUILDING_LIBRARY -DTORRENT_SSL_PEERS -DTORRENT_USE_I2P=1 -DTORRENT_USE_LIBCRYPTO -DTORRENT_USE_OPENSSL -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_FILE_OFFSET_BITS=64 -D_SCL_SECURE_NO_DEPRECATE -D_WIN32 -D_WIN32_WINNT=0x0600 -D__USE_W32_SOCKETS "-ID:\boost_1_78_0" "-Ideps\try_signal" "-Iinclude" "-Iinclude\libtorrent"
...failed compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj...
compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\merkle.obj
merkle.cpp
D:\TEMP\libtorrent\libtorrent\include\libtorrent/hasher.hpp(66): fatal error C1083: Cannot open include file: 'openssl/sha.h': No such file or directory
..... (rest of logging removed)
I found the answer.
While building libtorrent python binding 2 factors are important:
1- openSSL version
2- linking type
python comes with openssl v.1.1 (or similar based on python version) , if building python binding with openssl v.1.1 (which is the latest version while I am writing) one dependency solved otherwise, if using openssl v.3 for building 2 dependency must add to python which they are:
// 32 or 64 bits library based on openssl build
libssl-3-x64.dll
libcrypto-3-x64.dll
2 ) in the time of building python binding 2 commands can be use:
a ) simple with default parameters :
py setup.py build
py setup.py install
In this case in default libtorrent and boost-python linking static.
b ) complex one with more control (I think) :
py setup.py build_ext --b2-args="VARS" install
In the VARS place we can write boost build options but these are the one we want:
libtorrent-link=TYPE boost-link= TYPE
TYPE can be static or shared but anyone that sets shared , it becomes dependency. two files which is in need are :
// 32 and 64 bits file may have different name
// files can have different names but they are similar to below
torrent-rastarbar.dll
boost_python(PYTHON-VERSION)(SOME-INFO).dll
boost python can be find in the boost root directory in the stage/lib .
pleae note that you must build boost and libtorrent SHARED for this solution.
Conclusion :
as mentioned above these dependency must add to based on the build setting you did:
1 - OpenSSL libraries
2 - Boost python
3 - libtorrent libraries
There is an optional file that mentioned in some forums and discussion msvcr90.dll which does not effect on my project but good to point.
Put those files to a directory which can be find by python interpreter or put in project your folder and add this piece of code before imporing libtorrent :
import os
current_path = os.path.abspath(".")
# do not pass relative path like ".", pass full path
os.add_dll_directory(current_path)
Sorry for any poor english. :)
I've been given a custom Yocto SDK so as to build a c++ app I've created and the third party libraries that the app depends on.
I've installed the SDK on a VM Ubuntu 16.04.
The first library I needed to build was boost. I use version. 1.64.
I follow the same steps I follow each time to build boost either on a Yocto SDK or a default arm compiler.
$ . /opt/environment-setup-poky-linux-gnueabi
$ ./bootstrap.sh --with-libraries=filesystem,iostreams,program_options,regex,system --prefix=/home/user/Libs
$ nano ~/user-config.jam where I place the following commands
$ using gcc : arm : /opt/sysroots/x86_64-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot= /opt/sysroots/arm-poky-linux-gnueabi ;
$ ./b2 install toolset=gcc-arm link=shared threading=multi
However I always get the following error :
gcc.compile.c++ bin.v2/libs/system/build/gcc-arm/release/threading-multi/error_code.o
In file included from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/gnu/stubs.h:55,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/features.h:452,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/c++/8.2.0/arm-poky-linux-gnueabi/bits/os_defines.h:39,
from /opt/sysroots/arm-poky-linux-gnueabi/usr/include/c++/8.2.0/arm-poky-linux-gnueabi/bits/c++config.h:508,
from /opt/sysroots/amr-poky-linux-gnueabi/usr/include/c++/8.2.0/cstddef:49,
from ./boost/config/compiler/gcc.hpp:165,
from ./boost/config.hpp:39,
from ./boost/system/config.hpp:13,
from ./boost/system/error_code.hpp:14,
from libs/system/src/error_code.cpp:16:
/opt/sysroots/arm-poky-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
# include <gnu/stubs-soft.h>
^~~~~~~~~~~~~~~~~~
I assume that the sysroot is not found correctly.
When I tried with a user-config.jam that does not contain --sysroot variable I get the error :
gcc.compile.c++ bin.v2/libs/system/build/gcc-arm/release/threading-multi/error_code.o
In file included from ./boost/config.hpp:39,
from ./boost/system/config.hpp:13,
from ./boost/system/error_code.hpp:14,
from libs/system/src/error_code.cpp:16:
./boost/config/compiler/gcc.hpp:165:10: fatal error: cstddef: No such file or directory
#include <cstddef>
^~~~~~~~~
compilation terminated.
The CC variable on the environment setup contains the follwoing:
export CC="arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT"
Is there something I can do to bypass these errors or the SDK is faulty and needs rebuilt ?
Thanks in advance
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
I am trying to install Boost.Python on my computer. (Windows7 64bit, Visual Studio 2012, Python 2.7 64bit and Boost 1.54)
Following the instruction, I've successfully installed the Boost Library, and then I have to separately install Boost.Python.
However, as I followed the instruction at here. I am stuck at step 3.1.4.
I input C:\boost_1_54_0\…\quickstart> bjam toolset=msvc --verbose-test test
Then there are 135 unresolved external errors pop out. One of them is:
exec.obj : error LNK2019: unresolved external symbol
__imp__PyEval_GetGlobals referenced in function "class boost::python::api::object __cdecl boost::python::eval(class
boost::python::str,class boost::python::api::object,class
boost::python::api::object)"
(?eval#python#boost##YA?AVobject#api#12#Vstr#12#V3412#1#Z)........\bin.v2\libs\python\build\msvc-11.0\debug\boost_python-vc110-gd-1_54.dll
May I know how can I work around this?
=========================================================
Edit:
Following #Kyle 's advice, I've uninstalled the 64bit Python and replace it with a 32bit Python (2.7.5).
Then I've wrote a very simple code, which is like follows:
#include <boost\python.hpp> // This header used to raise error before
#include <Python.h>
using namespace std;
void main()
{
return;
}
It works well. Then my curiosity pushed me one step further, and I tried the example in my first post. It turns out that those 135 unresolved external errors are gone. Instead, I've got this:
msvc.link.dll bin\msvc-11.0\debug\extending.pyd LINK : fatal error
LNK1104: cannot open file 'boost_python-vc110-mt-gd-1_54.lib'
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
nullink /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console
/out:"bin\msvc-11.0\debug\extending.pyd"
/IMPLIB:"bin\msvc-11.0\debug\extendi ng.lib"
/LIBPATH:"C:\Python2.7.5\libs"
#"bin\msvc-11.0\debug\extending.pyd.rsp "
if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
...failed msvc.link.dll bin\msvc-11.0\debug\extending.pyd
bin\msvc-11.0\debug\extending.lib bin\msvc-11.0\debug\extending.pdb...
...skipped test_ext for lack of extending.pyd...
msvc.link bin\test_embed.test\msvc-11.0\debug\test_embed.exe LINK : warning
LNK4001: no object files specified; libraries used LINK : error
LNK2001: unresolved external symbol _mainCRTStartup
bin\test_embed.test\msvc-11.0\debug\test_embed.exe : fatal error
LNK1120: 1 unresolved externals
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86 nul
link /NOLOGO /INCREMENTAL:NO /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console
/out:"bin\test_embed.test\msvc-11.0\debug\test_embed.exe"
/LIBPATH:"C:\Python2.7.5\libs"
#"bin\test_embed.test\msvc-11.0\debug\test_embed.exe.rsp"
if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
...failed msvc.link bin\test_embed.test\msvc-11.0\debug\test_embed.exe
bin\test_ embed.test\msvc-11.0\debug\test_embed.pdb...
...removing bin\test_embed.test\msvc-11.0\debug\test_embed.pdb
...skipped test_embed.run for lack of test_embed.exe...
...failed updating 5 targets...
...skipped 4 targets...
Sorry to bother you with a large chunk of error message, I just want to provide as more information as I can.
About this boost_python-vc110-gd-1_54.dll, I can find it at C:\local\boost_1_54_0_32bit\lib32-msvc-11.0, while the root of my Boost is C:\local\boost_1_54_0_32bit\.
Can anyone help me work around with this?
Like Kyle C mentioned, this is happening because it can't find the lib. If you want to use 64-bit, you need to specify address-model=64 on the command line, plus have the 64-bit version of python correctly specified in your user-config.jam file.
I documented what I had to do to get this running, see the bottom for 64-bit specific config.
This means that the linker can't properly link to the Python lib. I have run into this before when trying to link to 64bit Python. You should try installing 32bit python and see if that works.
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?