Why installed libtorrent shows Import Error? - c++

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. :)

Related

Conan: Unable to build libvpx msvc compiler

I am trying to use libvpx as one of my dependencies of a C++ project using conan.
Using Linux, everything works fine with my current conanfile.txt.
Under Windows, I get an error, which I tracked down to the installation of libvpx, which I then tried to run separately with my current compiler configuration:
When I try to execute
conan install "libvpx/1.11.0#" --build missing --env CC="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/
bin/Hostx64/x64/cl.exe" --env CXX="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe" --settings arch=x86_64 --settings build_type=Debug --settings compiler="Visual Studio" --settings compiler.version=16 --settings compiler.runtime=MDd --settings compiler.cppstd=20
I get
ERROR: libvpx/1.11.0: Error in build() method, line 171
autotools = self._configure_autotools()
while calling '_configure_autotools', line 165
autotools.configure(args=args, configure_dir=self._source_subfolder, host=False, build=False, target=False)
ConanException: Error 1 while executing /c/users/juliu/.conan/data/libvpx/1.11.0/_/_/build/92e954da5bf61eb674376096f10cb67d2ac6fffa/source_subfolder/configure --prefix=/c/users/juliu/.conan/data/libv
px/1.11.0/_/_/package/92e954da5bf61eb674376096f10cb67d2ac6fffa --disable-examples --disable-unit-tests --disable-tools --disable-docs --enable-vp9-highbitdepth --as=yasm --disable-shared --enable-static --enable-debug --target=x86_64-win64-vs16 --disable-avx --disable-avx2 --disable-avx512
When I then look into the build directory's config.log file, I see the following log output:
# /c/users/juliu/.conan/data/libvpx/1.11.0/_/_/build/92e954da5bf61eb674376096f10cb67d2ac6fffa/source_subfolder/configure --prefix=/c/users/juliu/.conan/data/libvpx/1.11.0/_/_/package/92e954da5bf61eb674376096f10cb67d2ac6fffa --disable-examples --disable-unit-tests --disable-tools --disable-docs --enable-vp9-highbitdepth --as=yasm --disable-shared --enable-static --enable-debug --target=x86_64-win64-vs16 --disable-avx --disable-avx2 --disable-avx512
enabling vp8_encoder
enabling vp8_decoder
enabling vp9_encoder
enabling vp9_decoder
Configuring for target 'x86_64-win64-vs16'
enabling x86_64
check_cpp
BEGIN /tmp/vpx-conf-1948-24757.c
1 #if !defined(__ILP32__) || !defined(__x86_64__)
2 #error "not x32"
3 #endif
END /tmp/vpx-conf-1948-24757.c
/c/program files (x86)/microsoft visual studio/2019/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe -E -o /tmp/vpx-conf-1948-24757.o /tmp/vpx-conf-1948-24757.c
/c/users/juliu/.conan/data/libvpx/1.11.0/_/_/build/92e954da5bf61eb674376096f10cb67d2ac6fffa/source_subfolder/build/make/configure.sh: line 295: /c/program: No such file or directory
And some other output, also indicating that the directory /c/program cannot be found.
I tried running conan with different compilers, and received different errors. Did I configure something incorrectly?
Conan version 1.57.0
edit: I saw that installing using C++14 standard works, because then it just downloads a pre-build binary, but it does not work for c++ >= 17
edit2: I edited the profile
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler="Visual Studio"
compiler.version=16
compiler.cppstd=20
#compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CXX="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe"
CC="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe"
and executed
conan install "libvpx/1.11.0#" --build missing
but I still encounter an error message:
Unable to invoke compiler: /c/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.29.30133/bin/hostx64/x64/cl.exe
Configuration failed. This could reflect a misconfiguration of your
toolchains, improper options selected, or another problem. If you
don't see any useful error messages above, the next step is to look
at the configure error log file (config.log) to determine what
configure was trying to do when it died.
libvpx/1.11.0:

SCons and Thrift building problems

I need to create C++ app using thrift and build it using SCons. In order to do so I've downloaded and installed all of the needed libs (and ensured that all of them are for x64 Windows) - boost, openssl, libevent.
I've built boost with command:
b2 -j4 toolset=msvc-14.1 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=complete stage --stagedir=stage/x64
Next, I've built Thrift libs in VS2017 (x64/Release).
But, when I try to build project with SCons, I encounter erros.
When I try with SConstruct file like this (run from Developer Command Prompt for VS2017):
import os
from os import path, listdir
gen_cpp = [path.join('gen-cpp', f) for f in listdir('gen-cpp') if
f.endswith('.cpp')]
client_source = [path.join('logic', folder, f) for folder in ['', 'parser',
'mars', 'view']
for f in listdir(path.join('logic', folder)) if
f.endswith('.cpp')]
server_source = [path.join('server', 'server.cpp')]
tests_source = [path.join('test_cases', f) for f in listdir('test_cases') if
f.endswith('.cpp')]
cpppath = ['.','c:\\Users\\Antek\\libs\\thrift-0.10.0\\thrift-
0.10.0\\lib\\cpp\\src\\','c:\\Users\\Antek\\libs\\boost_1_64_0\\boost\\']
libpath = ['C:\\Users\\Antek\\libs\\thrift-0.10.0\\thrift-
0.10.0\\lib\\cpp\\x64\\Release\\',
'c:\\Users\\Antek\\libs\\boost_1_64_0\\boost\\stage_x64\\lib\\',
'C:\\OpenSSL-Win64\\lib']
libs = ['libthrift']
env = Environment(
CPPPATH = cpppath,
LIBS = libs,
LIBPATH = libpath,
CPPFLAGS='/EHsc',
)
gen_cpp_o = env.Object(gen_cpp)
client_o = env.Object(client_source)
tests_o = env.Object(tests_source)
tests_files = gen_cpp_o + [f for f in client_o if str(f) !=
path.join('logic', 'main.obj')] + tests_o
env.Program('CoreWars', gen_cpp_o + client_o)
env.Program('Server', gen_cpp_o + server_source)
env.Program('tests', tests_files)
I get:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fogen-cpp\MARS.obj /c gen-cpp\MARS.cpp /TP /nologo /EHsc /I.
/IC:\Users\Antek\libs\thrift-0.10.0\thrift-0.10.0\lib\cpp\src
/IC:\Users\Antek\libs\boost_1_64_0\boost
'cl' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [gen-cpp\MARS.obj] Error 1
scons: building terminated because of errors.
When I add the following line to my SConstruct:
ENV = os.environ
I get an error :
Libthrift.lib (TOutput.obj): MSIL .netmodule module found or module compiled
with / GL; Consolidation will start again with the / LTCG option; Add the /
LTCG option to the consolidation command line to improve the performance of
the consolidator
Fatal error C1905: Frontend and backend are not compatible (must refer to
the same processor)
LINK: fatal error LNK1257: code generation failed
Scons: *** [CoreWars.exe] Error 1257
Scons: building terminated because of errors
I've spent too much time on this already, all ideas will be highly appreciated. Thank You.

Compile boost-python tutorial with VS-2015 CTP 5 and Python 3.5a on Windows 10 TP

I'm trying to get the boost-python extension module tutorial working on a modern C++14 compiler in Windows 10. I've downloaded the latest versions of boost 1.57 and python 3.5a source using vc-14 (VS 2015 CTP 5).
I compiled python from source using VS 2015 CTP 5 and these instructions: 1.1.3.3. Windows.
I've run the command
.\bootstrap.bat && .\b2 stage toolset=msvc --with-python
from the boost project folder c:\boost
This is the user-config.jam file in my home directory:
using msvc : 14.0 : C:\\Program\ Files\ (x86)\\Microsoft\ Visual\ Studio\ 14.0\\VC\\bin\\cl.exe ;
using python
: 3.5 # Version
: C:\\python35a3\\PCBuild\\win32\\python.exe # Python Path
: C:\\python35a3\\include # include path
: C:\\python35a3\\libs # lib path
: <define>BOOST_ALL_NO_LIB=1
;
Running bjam in the tutorial directory results in an incompatibility when creating the pdb file:
c:\boost\libs\python\example\tutorial>bjam --debug-configuration
notice: found boost-build.jam at C:/boost/libs/python/example/tutorial/boost-build.jam
notice: loading Boost.Build from C:/boost/tools/build/src
....
notice: Loading user-config configuration file 'user-config.jam' from 'C:/Users/marcel'.
notice: [msvc-cfg] msvc-14.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe'
notice: [msvc-cfg] msvc-12.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe'
notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe' 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe' for msvc, condition <toolset>msvc-14.0
notice: [msvc-cfg] condition: '<toolset>msvc-14.0/<architecture>/<address-model>', setup: 'call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
'
notice: [msvc-cfg] condition: '<toolset>msvc-14.0/<architecture>/<address-model>32', setup: 'call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
'
notice: [msvc-cfg] condition: '<toolset>msvc-14.0/<architecture>x86/<address-model>', setup: 'call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
'
notice: [msvc-cfg] condition: '<toolset>msvc-14.0/<architecture>x86/<address-model>32', setup: 'call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
'
notice: [python-cfg] Configuring python...
notice: [python-cfg] user-specified version: "3.5"
notice: [python-cfg] user-specified cmd-or-prefix: "C:\python35a3\PCBuild\amd64\python_d.exe"
notice: [python-cfg] user-specified includes: "C:\python35a3\include"
notice: [python-cfg] user-specified libraries: "C:\python35a3\libs"
notice: [python-cfg] user-specified condition: "<define>BOOST_ALL_NO_LIB=1"
notice: [python-cfg] Checking interpreter command "C:\python35a3\PCBuild\amd64\python_d.exe"...
notice: [python-cfg] running command 'DIR /-C /A:S "C:\Python35a3\PCbuild\amd64\python_d.exe" 2>&1'
notice: [python-cfg] running command 'C:\python35a3\PCBuild\amd64\python_d.exe -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'
notice: [python-cfg] ...requested configuration matched!
notice: [python-cfg] Details of this Python configuration:
notice: [python-cfg] interpreter command: "C:\python35a3\PCBuild\amd64\python_d.exe"
notice: [python-cfg] include path: "C:\python35a3\include"
notice: [python-cfg] library path: "C:\python35a3\libs"
notice: [python-cfg] DLL search path: "C:\python35a3"
notice: Searching '../../../..' for project-config configuration file 'project-config.jam'.
notice: Loading project-config configuration file 'project-config.jam' from '../../../..'.
....
...patience...
...patience...
...found 1893 targets...
...updating 6 targets...
msvc.link.dll bin\msvc-14.0\debug\threading-multi\hello_ext.dll
Creating library bin\msvc-14.0\debug\threading-multi\hello_ext.pdb and object bin\msvc-14.0\debug\threading-multi\hello_ext.exp
LINK : fatal error LNK1207: incompatible PDB format in 'c:\boost\libs\python\example\tutorial\bin\msvc-14.0\debug\threading-multi\hello_ext.pdb'; delete and rebuild
....
...removing bin\hello.test\msvc-14.0\debug\threading-multi\hello.py
...skipped <pbin\hello.test\msvc-14.0\debug\threading-multi>hello for lack of <pbin\hello.test\msvc-14.0\debug\threading-multi>hello.py...
...failed updating 3 targets...
...skipped 3 targets...
The command producing the error output is:
call "C:\Users\marcel\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" >nul
link /NOLOGO /INCREMENTAL:NO /DLL /NOENTRY /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"bin\msvc-14.0\debug\threading-multi\hello_ext.dll" /IMPLIB:"bin\msvc-14.0\debug\threading-multi\hello_ext.pdb" /LIBPATH:"C:\python35a3\libs" #"bin\msvc-14.0\debug\threading-multi\hello_ext.dll.rsp"
Creating library bin\msvc-14.0\debug\threading-multi\hello_ext.pdb and object bin\msvc-14.0\debug\threading-multi\hello_ext.exp
LINK : fatal error LNK1207: incompatible PDB format in 'c:\boost\libs\python\example\tutorial\bin\msvc-14.0\debug\threading-multi\hello_ext.pdb'; delete and rebuild
The link command seems to be consistent with the way python and boost are compiled (32 bit on the same compiler version).
Is there an way to diagnose where this error originated?
UPDATE: Compiling with VC9 (VS2010) and a prebuilt python 3.4 installation. I still get the same error:
link /NOLOGO /INCREMENTAL:NO /DLL /NOENTRY /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"bin\msvc-10.0\debug\threading-multi\hello_ext.pyd" /IMPLIB:"bin\msvc-10.0\debug\threading-multi\hello_ext.pdb" /LIBPATH:"C:\python34\libs" #"bin\msvc-10.0\debug\threading-multi\hello_ext.pyd.rsp"
Creating library bin\msvc-10.0\debug\threading-multi\hello_ext.pdb and object bin\msvc-10.0\debug\threading-multi\hello_ext.exp
LINK : fatal error LNK1207: incompatible PDB format in 'c:\boost\libs\python\example\tutorial\bin\msvc-10.0\debug\threading-multi\hello_ext.pdb'; delete and rebuild
Running the python interpreter to confirm the correct compiler version:
c:\Python34\python.exe
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Apparently this error has nothing to do with the "bleeding edge-ness" of the environment the build is running on. Rather its a direct result of a boost-build configuration issue.
UPDATE 2: Trying the same test with pre-built Python 2.7 and VS 2008 results in the same error.
UPDATE 3 SOLVED This builds correctly on boost v1.55 when the following steps are taken:
Download and build python 3.5 a3 and build boost 1.55 with VC14 by
modifying the user-config.jam file in the home directory and running
"bjam stage --use-python"
Move the resultant files in stage\lib from
libboost* to boost* run bjam from the tutorial directory
Change the errant link command by adding the following LIBPATH switch:
/LIBPATH:c:\boost_1_55_0\stage\lib
The problem of linking to python 3.5 alpha3 with VC14 is isolated to boost v1.57 builds.
The problem seems to have been introduced with 1.56. I've managed to get Boost.Build working again by editing the file:
D:\boost\boost_1_59_0\tools\build\src\tools\msvc.jam
I made two changes:
Change this (lines #1351-1355):
generators.register [ new msvc-linking-generator msvc.link.dll :
OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB :
<toolset>msvc <suppress-import-lib>false ] ;
generators.register [ new msvc-linking-generator msvc.link.dll :
OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB :
<toolset>msvc <suppress-import-lib>true ] ;
to:
generators.register [ new msvc-linking-generator msvc.link.dll :
OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB :
<toolset>msvc ] ;
Remove this line (#1472):
toolset.flags msvc.link.dll LINKFLAGS <suppress-import-lib>true : /NOENTRY ;
I've tested this on Win7 with VS2012 and Python 2.7.
Yes, I think Boost.Build 1.59 (and possibly 1.57 and 1.58) is broken on Windows. I gave up using Boost.Build and built it myself.

Unresolved symbols with boost_asio/example/ssl/client.cpp [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
boost::asio ssl linking error
I am having issues with undefined symbols. My boost installation is fine as I have used it for other projects. I understand that I need OpenSSL installed, So installed it in the following way.
I then ran the following commands with VS2010 command prompt with the extracted OpenSSL source (most recent from openssl site) as the working directory.
perl Configure VC-WIN64A no-shared no-idea // I don't trust this.
ms\do_win64a
nmake -f ms\ntdll.mak
nmake -f ms\ntdll.mak install
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
The source file is just the boost example. http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/ssl/client.cpp
My VS2010 project is setup as follows.
C/C++ > General > Addition Include Directories
E:\libraries\boost_1_49_0 //as used in past projects
E:\usr\local\ssl\include //just installed
Linker > General > Addition Library Directories
E:\libraries\boost_1_49_0\stage\lib
E:\usr\local\ssl\lib
Linker > Input > Addition Directories
libeay32.lib
I thought that it might must have been boost tripping out. So I tried an SSL crypto example and that had undefined symbols.
Errors in a text file
OS is Windows 7 64Bit
I was trying to build a 32bit program with the 64 bit libs.
I changed the following from above to build the 64 bit version
perl Configure VC-WIN64A no-asm --prefix=\Dir\for\64\bit\ssl -DUNICODE -D_UNICODE
ms\do_win64a.bat
then nmake as normal

Compile boost C++11 clang mac cannot find cstddef

I cannot compile boost with clang 3.1 on Mac os x 10.8.2.
This is what I did:
./bootstrap.sh --with-toolset=clang
./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++"
I also tried without chrono, test, wave and signals.
I tried a user-config.jam with
using clang-darwin
This is the error I have for almost every file:
/boost/config/select_stdlib_config.hpp:18:12: fatal error: 'cstddef' file not found
It is kind of similar to How to compile/link Boost with clang++/libc++?
Thank you :-)
Update:
I do have the latest Xcode 4.5.2 with the command line tools installed.
Here is part of the console output:
Kikohs:trunk kikohs$ ./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++"
Performing configuration checks
- 32-bit : no
- 64-bit : yes
- x86 : yes
- has_icu builds : no
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
- gcc visibility : yes
- long double support : no
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.
Building the Boost C++ Libraries.
- iconv (libc) : no
- iconv (separate) : yes
- icu : no
- icu (lib64) : no
Component configuration:
- atomic : building
- chrono : building
- context : building
- date_time : building
- exception : building
- filesystem : building
- graph : building
- graph_parallel : building
- iostreams : building
- locale : building
- math : building
- mpi : building
- program_options : building
- python : building
- random : building
- regex : building
- serialization : building
- signals : building
- system : building
- test : building
- thread : building
- timer : building
- wave : building
...patience...
...patience...
...patience...
...patience...
...found 8672 targets...
...updating 1127 targets...
common.mkdir bin.v2/libs/atomic
common.mkdir bin.v2/libs/atomic/build
common.mkdir bin.v2/libs/atomic/build/clang-darwin-4.2.1
common.mkdir bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug
clang-darwin.compile.c++ bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug/lockpool.o
In file included from libs/atomic/src/lockpool.cpp:1:
./boost/atomic.hpp:10:10: fatal error: 'cstddef' file not found
#include <cstddef>
^
1 error generated.
"clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -DBOOST_ATOMIC_DYN_LINK=1 -DBOOST_ATOMIC_SOURCE -I"." -c -o "bin.v2/libs/atomic/build/clang-darwin-4.2.1/debug/lockpool.o" "libs/atomic/src/lockpool.cpp"
It looks like you forgot to install the libc++ headers alongside clang.
If you don't want to mess with installing the headers, try the version of clang distributed by Apple as part of the Command Line Tools package; it's been through more testing, and it's already set up properly.
I finally fixed my problem after many hours.
Homebrew was messing with my path and for some reason my clang could not find the libc++ headers.
There is a bug is boost 1.52.
See Boost numeric limits bug
I had to edit the file :
boost/config/stdlib/libcpp.hpp
and patch it:
#if _LIBCPP_VERSION < 1002
# define BOOST_NO_CXX11_NUMERIC_LIMITS
#endif
Now boost is building properly ...
For Ubuntu 16.04, I'm able to build boost with c++11 using gcc:
cd /home/user/install/boost/boost_1_54/
./bootstrap.sh --with-toolset=gcc
./b2 toolset=gcc cxxflags="-std=c++11 -I/usr/include/c++/5/ -I/usr/include/x86_64-linux-gnu/c++/5/"
mkdir ../2
./b2 install --prefix=../2/
The command for building my program:
g++ -std=c++11 -O2 fprint.cpp -o fprint -I/home/user/install/boost/2/include/ -L/home/user/install/boost/2/lib/ -lboost_regex -lboost_program_options
Before that the command was:
g++ -std=c++11 fprint.cpp -o fprint -lboost_regex -lboost_program_options
, but this old command (that worked before well with older OS and boost/etc) doesn't work anymore saying errors
"
undefined reference to boost::re_detail_106501
"
(said by /tmp/cc0Zn8lo.o: In function `bool boost::regex_search...)
((also if I don't use "-I/usr/include/c++/5/ -I/usr/include/x86_64-linux-gnu/c++/5/" for ./b2, then the error is "cannot find cstddef" during building boost, so exactly the same like the subject of this ticket))