Boost.Python not the .lib - c++

I think I have built it properly. I have other boost libraries working. I am getting the following error
Error: SNK1104 cannot open file 'boost_pythonPY_MAJOR_VERSIONPY_MINOR_VERSION-vc141-mt-x32-1_67.lib'.
I'm on windows using Visual Studios, with boost 1.67

boost-python is notoriously hard to install. Make sure you specify with-python when building from source. Something like this:
Download and configure boost
cd boost_1_55_0\tools\build\v2\engine
build.bat mingw
Add this to your path
C:\boost_1_55_0\tools\build\v2\engine\bin.ntx86
Build from source
bjam toolset=gcc --with-python link=shared
Add this to your path
C:\boost_1_55_0\stage\lib

Related

Boost with Qt Creator

I was trying to use boost/filesystem in my C++ project made with QtCreator.
The problem was that when building, I got the following error:
"error: undefined reference to `boost::system::generic_category()'"
To use boost, I had performed the following actions:
download boost library boost_1_73_0.7z file
unzip it in my computer (under D:\Development\Boost)
in .pro file, I have added the following option
INCLUDEPATH += D:/Development/Boost
in my .cpp file, I have added the following include
#include "boost/filesystem.hpp"
At this point, when compiling, I had the following error in Qt creator IDE
"error: undefined reference to `boost::system::generic_category()'"
The root cause is the following : FileSystem needs to be built. Therefore, I have built this boost library by :
adding gcc and g++ to the path variable (it is succesful as I could call 'g++' and 'gcc' from the command prompt).
opening Qt command prompt (I used Qt 5.15.0 (MinGW 73.0 64-bit) ) and by navigating to the repository where boost is installed.
executing the following command in the command prompt in the directory (D:\Development\Boost): bootstrap gcc
executing the following command in the command prompt in the directory where I had unzipped Boost: b2 toolset=gcc link=shared threading=multi --build-type=complete stage. This action has created a the directory D:\develoment\Boost\Stage\lib with all the dll, including 'libboost_filesystem-mgw8-mt-d-x64-1_73.dll'.
Now it's time to link the library in Qt creator. I have thus added the following in my .pro file:
LIBS += -LD:/Development/Boost/stage/lib libboost_filesystem-mgw8-mt-d-x64-1_73
When compiling, the error is gone.
Thanks for your help.
Gatien
As #drescherjm commented, you need to build the boost libraries.
They are not in the D:/Development/Boost/libs directory.
You appear to be using Windows and have boost installed on your "D:" drive.
I assume your using the MinGw compiler that comes with Qt Creator, not Visual Studio.
To build boost with MinGw, first open the relevant Qt Command prompt, e.g. Qt 5.12.3 (MinGW 7.3.0 64-bit) and type the following:
D:
cd \Development\Boost
bootstrap.bat gcc
b2 toolset=gcc link=shared threading=multi --build-type=complete stage
This will build the MinGw boost libraries in your directory: D:\Development\Boost\stage\lib.
Then change the link command to:
LIBS += -LD:/Development/Boost/stage/lib -l boost_system-mgw73-mt-x64-d-1_66
Note: the precise name of the boost_system library depends upon how boost named it in your version.
See Boost Getting Started on Windows: library naming. the answer here: mingw-w64 cannot find -lboost_filesystem and the filenames you built in the D:\Development\Boost\stage\lib directory.

CLion Boost library

I have installed Boost library following these commands:
I have extracted downloaded boost_1_67_0.7zfile
Then I have executed command bootstrap.bat gcc
Then I executed command b2 install --prefix=c:/Boost toolset=gcc
Then I restared my computer, just in case
Then I have opened CLion (newest version) and tried to include boost library in my program with find_package(Boost), but that doesn't work for me. Am I doing something wrong here or there is some other problem?
CMake file
Source code for my program
Folder hierarchy
Also I tried to say CMake whereis Boost installed with command
set(BOOST_ROOT C:/Boost/include/boost-1_67)
Then CMake can detect Boost, but it doesn't want to compile because it
can't find any file, for example boost/thread.hpp.

Building PoDoFo library using CMake and MinGW

I am trying to build PoDoFo Library on my Windows Platform (for use as an API). It is done using CMake. The ReadMe file says the following. Unfortunately I am new to CMake and I can't make out much from it.
Building PoDoFo on Windows
CMake 2.6.x is required for Windows. You can download it from
cmake.org .
On Windows, PoDoFo may be built as either a shared or static library.
Building both is not supported. By default only the shared library
will be built. If you want a static library, just disable generation
of the shared library with the extra argument to cmake:
-DPODOFO_BUILD_SHARED=FALSE
Handling library naming on win32
Especially on Windows it is also common for custom built libraries to
have different names to those you might download as pre-built copies.
CMake won't be able to find them if they're called something else
unless you tell it. Use these variables to tell CMake what names to
look for a library under:
•FREETYPE_LIBRARY_NAMES_DEBUG, FREETYPE_LIBRARY_NAMES_RELEASE and FREETYPE_LIBRARY_NAMES
•TIFF_LIBRARY_NAMES_DEBUG, TIFF_LIBRARY_NAMES_RELEASE and TIFF_LIBRARY_NAMES
•LIBJPEG_LIBRARY_NAMES_DEBUG, LIBJPEG_LIBRARY_NAMES_RELEASE and LIBJPEG_LIBRARY_NAMES
•ZLIB_LIBRARY_NAMES_DEBUG, ZLIB_LIBRARY_NAMES_RELEASE,ZLIB_LIBRARY_NAMES
CMake builds on Windows with MinGW
Once MinGW is set up, make sure that the MinGW "bin" directory is on
your PATH, and be sure to set CMAKE_INCLUDE_PATH and
CMAKE_LIBRARY_PATH such that CMake can find the headers and .lib files
for the libraries PoDoFo requires. The GnuWin32 library packages from
http://gnuwin32.sf.net/ are known to work with PoDoFo, so installing
zlib, freetype, and libjpeg from there should do the trick.
To configure and build PoDoFo with a default GnuWin32 install and with
MinGW already on your PATH:
md ..\podofo-debug
cd ..\podofo-debug
cmake -G "MinGW Makefiles" ..\podofo-src -DCMAKE_INCLUDE_PATH=c:\progra~1\gnuwin32\include -DCMAKE_LIBRARY_PATH=c:\progra~1\gnuwin32\lib -DPODOFO_BUILD_SHARED:BOOL=FALSE mingw32-make
I have installed CMake and downloaded the other libraries mentioned like freetype, zlib, libjpeg. Their header and binary files are in their respective folders.
Now what should DCMAKE_INCLUDE_PATH and DCMAKE_LIBRARY_PATH be? Also what is "MinGW Makefiles"? Do I have to supply any extra parameters?
I'll be grateful if someone can explain in simple steps how I can go about it.
EDIT: error while executing CMAKE:
-- Ensure you cppunit installed version is at least 1.12.0
Cppunit not found. No unit tests will be built.
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPack
ageHandleStandardArgs.cmake:97 (message):
Could NOT find FREETYPE (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStan
dardArgs.cmake:291 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindFREETYPE.cmake:75 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:372 (FIND_PACKAGE)
To build PoDoFo you need installed GnuWin32, CMake, MinGW32 and PoDoFo sources
download GetGnuWin32
install to c:\getgnuwin32
open cmd.exe
cd c:\getgnuwin32
download.bat
install.bat
Then as suggested in #ibizaman answer
cmake -G "MinGW Makefiles" -DCMAKE_INCLUDE_PATH="C:\gnuwin32\include" -DCMAKE_LIBRARY_PATH="C:\gnuwin32\lib" -DPODOFO_BUILD_STATIC=TRUE ..
FreeType should be installed with GnuWin32 packages
If you followed all the instructions, to compile it should normally be enough to do:
cd <podofo root directory (where CMakeLists.txt is)>
mkdir build
cd build
cmake -G "MinGW Makefiles" -DCMAKE_INCLUDE_PATH=<path to headers> -DCMAKE_LIBRARY_PATH=<path to libraries> -DPODOFO_BUILD_SHARED:BOOL=FALSE ..
mingw32-make
Step by step:
First, go to the directory where your podofo sources are. You should see a CMakeLists.txt file lying around.
Second (and third), create (and go into) a directory where the compilation will be done. I call it build but it can be any name. This is a best practice since you can simply delete the build directory and come back to a clean state.
Fourth, ask cmake to create the makefile(s) for mingw:
Specify the PODOFO_BUILD_SHARED like advertised in the manual: build shared or static version.
CMAKE_INCLUDE_PATH and CMAKE_LIBRAY_PATH are used to reference to the packages needed to build podofo. If you downloaded the precompiled packages like you did since you have de headers and the binaries, then you need to give to cmake the path to those headers and binaries. You can specify the variables multiple times if needed, e.g.:
cmake -G "MinGW Makefiles" -DCMAKE_INCLUDE_PATH=/path/to/freetype/include -DCMAKE_LIBRARY_PATH=/path/to/freetype/lib -DCMAKE_INCLUDE_PATH=/path/to/zlib/include -DCMAKE_LIBRARY_PATH=/path/to/zlib/lib -DPODOFO_BUILD_SHARED:BOOL=FALSE ..
The "MinGW Makefiles" tells cmake to create makefiles specific to mingw. Else, by default on windows, it creates makefiles specific to Microsoft Visual Studio.
Finaly reference the CMakeLists.txt in the parent directory with .. at the end.
Last, but not least, compile with the mingw version of make.

Boost on windows with codeblocks - error: undefined reference to boost

Tons of these errors are popping up whenever I try to use boost in windows with codeblocks. On linux it works fine.
Even though I did add the boost .lib files and the include path to the GCC compiler in codeblocks.
I first compiled using bootstrap.bat + b2.exe but apperently that's wrong. A user in another forum said he fixed it but when I try his method I get:
So to clarify; what I did was:
. Add "C:\Program Files (x86)\CodeBlocks\MinGW\bin" to PATH
. Run bootstrap.bat which makes bjam.exe
. Run cmd.exe, cd to boost folder, enter bjam --build-dir=C:\boost --build-type=complete gcc stage
But then I get that error.
Why does compiling/using C++ libraries on windows always net these kind of errors that take hours to solve, while on linux it's nearly always flawless -.-
Who knows how to fix this one?
The technique that I use is as follows:
Set up the PATH environmental variable to include the bin directory of your GCC installation.
Extract boost somewhere.
Open a comand prompt and cd into the root of boost (the folder named boost_x_xx_x which has boost, doc, libs etc... subdirectories).
To compile boost, run:
bootstrap.bat
b2 toolset=gcc variant=release link=static threading=multi install
This will install boost to C:\Boost. If you want to install it elsewhere use the --build-dir= option when running b2.

Compiling boost with zlib

I'm compiling boost with bjam under Windows 7 (64bit-should be irrelevant)
D:\development\boost\boost_1_44\libs\iostreams\build>bjam stage ^
--toolset=msvc-10.0 link=static ^
--build-type=complete ^
-s ZLIB_SOURCE=C:\zlib125-dll ^
-s ZLIB_LIBPATH=C:\zlib125-dll\lib ^
-s ZLIB_INCLUDE=C:\zlib125-dll\include ^
-s ZLIB_BINARY=C:\zlib125-dll
But I only get
stage/libboost_iostreams-vc100-mt-gd-1_44.lib
bin.v2/libs/iostreams/build/msvc-10.0/debug/threading-multi/boost_iostreams-vc100-mt-gd-1_44.dll
bin.v2/libs/iostreams/build/msvc-10.0/debug/threading-multi/boost_iostreams-vc100-mt-gd-1_44.lib
bin.v2/libs/iostreams/build/zlib/msvc-10.0/debug/threading-multi/boost_zlib-vc100-mt-gd-1_44.dll
bin.v2/libs/iostreams/build/zlib/msvc-10.0/debug/threading-multi/boost_zlib-vc100-mt-gd-1_44.lib
but stage/libboost_zlib-vc100-mt-gd-1_44.lib is missing.
Am I compiling something wrong?
when I try running my project that worked well with boost and self-compiled boost/thread libraries I get the following error when I include the boost zlib stuff
6>LINK : fatal error LNK1104: cannot open file 'libboost_zlib-vc100-mt-gd-1_44.lib'
Does anyone know what I'm doing wrong?
I did manage to build them using the option
-sZLIB_SOURCE="C:\zlib-1.2.5"
Note there is no space after the -s and the quotes around the path.
It took me a while to get Boost to build correctly with zlib support.
The problem I ran into was that at some point zlib no longer included a gzio.c source file. The jamfile for the Boost build system (jamfile.v2) had a reference to the gzio module which caused it fail. The solution was to remove that reference before building.
I'm not sure this answer is relevant any longer, unless you're trying to build an old version of Boost. I believe the original build issue has been fixed in more recent versions of Boost.
I had the same problem (Windows 7 Visual Studio) and I believe the issue is not in how you build boost.
1) As ecotax, there should not be a space after the -s
2) When running bjam, add the flag --debug-configuration. If in the output you do not see errors and it prints out something like
notice: iostreams: using prebuilt zlib
then it has found your zlib copy, which it is good.
3) Notice that the library libboost_zlib-vc100-mt-gd-1_44.lib should not be produced.
4) When you compile your application in Visual Studio, seems that Boost.Iostreams auto-linking still wants libboost_zlib-vc100-mt-gd-1_44.lib and reports a link error.
What it worked for me (I founded googling) was to add to the preprocessor definitions the flag
BOOST_IOSTREAMS_NO_LIB
I was trying all sorts of things and had a hard time finding the correct solution for newer versions of boost (1.75.0).
All the -sZLIB_xxx switches seem to be not working anymore.
Boost Documentation just states
On Windows the zlib, bzip2, zstd and/or LZMA binaries need to be in the PATH, else they will not ordinarily be found by default, so it is always a good idea under Windows to setup the zlib, bzip2, zstd and/or LZMA toolsets in your own jamfile.
Setting path did not lead to any success, so I dig through more documentation. Boost provided jam documentation and examples are not the most helpful, so through analysis of the Conan Recipe for the Conan boost package I finally came up with this minimal user-config.jam file that does the trick for me:
using zlib : your.zlib.version :
<include>"path/to/zlib/include/headers"
<search>"path/to/zlib/library/file" ;
The minimal b2 command to execute this for me is:
.\b2.exe --user-config="path/to/user-config.jam"
Hope this can be of help to others so they don't need to waste a lot of time as I did.
For guys, who compiling, using prebuilt 'zlib'.
These steps needs to be done:
Download and build 'zlib'
Run b2.exe --with-iostreams -s ZLIB_BINARY=zlib -s ZLIB_INCLUDE=C:/Sys/zlib-1.2.7/Include -s ZLIB_LIBPATH=C:/Sys/zlib-1.2.7/Lib release
Update paths to your local installation zlib folder. This way, Boost will embed into libboost_iostreams the gzip.cpp, zlib.cpp files. No libboost_zlib will be generated.
At your source file add this lines (somewhere in stdafx.h, before including Boost.Iostream headers):
--
#ifdef _DEBUG
#define BOOST_ZLIB_BINARY zlibd
#else
#define BOOST_ZLIB_BINARY zlib
#endif
This tells that you don't want to link against libboost_zlib, but you provide precompiled zlib library instead.
At your project settings provide path to zlib.lib file.
It should compile and link now.
I took a combination of advice from other answers here and this is what I did:
Extract zlib to C:\zlib\zlib-1.2.11.
Use CMake to configure and generate MS Visual Studio 2017 project and use MS Visual Studio 2017 to build the project. I built it in place so that C:\zlib\zlib-1.2.11 now contains (in addition to previous contents) directories lib and include.
Extract Boost 1.67.0 to C:\Boost\boost_1_67_0.
(Be on drive C:)
cd \Boost\boost_1_67_0
bootstrap.bat
set ZLIB_SOURCE="C:\zlib\zlib-1.2.11"
set ZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include"
set ZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
The following line built libboost_iostreams and it did put libboost_zlib files in C:\Boost\boost_1_67_0\stage\lib:
b2 --debug-configuration --with-iostreams -sZLIB_SOURCE="C:\zlib\zlib-1.2.11" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
The following line built the rest of Boost:
b2 -sZLIB_SOURCE="C:\zlib\zlib-1.2.11" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"
Don't know if this is the most optimal way to do it, but it did build the libboost_zlib lib files.
set ZLIB_SOURCE="c:\zlib"
set ZLIB_INCLUDE="c:\zlib"
.\b2
.\bjam will not build but .\b2 will build the library: stage/libboost_zlib-vc100-mt-gd-1_44.lib