Building Boost on Windows from https://github.com/boostorg/boost.git - c++

I have been trying to build boost Version 1.73 from its git repo https://github.com/boostorg/boost.git on Windows. And am able to build it, however when I try to use it in code, it is looking for boost 1.74 instead of 1.73.
Here are the steps I took to build it:
git clone --recursive https://github.com/boostorg/boost.git
cd boost
rm -rvf more
git checkout tags/boost-1.73.0
git submodule update --init --recursive
Once the cloning is done. I do the following:
bootstrap.bat
.\b2 --toolset=msvc-14.2 variant=release,debug threading=multi link=shared,static runtime-link=shared,static address-model=64,32 architecture=x86 --layout=versioned --stagedir=out\\release -j %NUMBER_OF_PROCESSORS% -q --hash
Boost gets built as expected, however when I use it in my code to be linked statically. The linker looks for boost version 1.74, which is the latest on master as of now. However if I download the sources from here and then build it, everthing works as expected.
Can anyone help me in pointing what I may be doing wrong?
TIA

You wrote:
Boost gets built as expected, however when I use it in my code to be
linked statically. The linker looks for boost version 1.74,
You can verify that the string 1.74 doesn't occur in the Boost source code at all, using git grep 1\\.74 (two backslashes are needed with a POSIX shell, perhaps only one needed with a Windows command line?). I did this, and 1.74 really isn't there in the source code except in one file doc/test/test.svg as part of a number unrelated to versioning.*
In addition to the Boost which you are building, it seems that there is, or was, another version of Boost on your system, and MSVC is trying to use that. In your project that tries to use Boost, you need to look closely at the project properties. Look at the paths that MSVC searches for libraries and headers, there must be something there which isn't using the Boost that you build.
It's not clear why you don't also see this problem when you download the source from dl.bintray.com - that source is not identical to what you get from github, but the differences appear to be insignificant.
*Sadly, it seems that git grep is not as reliable as I would have thought. Using grep --recursive 1\\.74 * finds many other instances of 1.74. However, I believe they are all in numerical constants unrelated to versioning.

Related

How to build boost with correct paths

I tried to build boost in a separate path on my Ubuntu 18 Linux system. I cloned the GIT repository since I want to have the latest version available (the package repositories provide an old version only). The library I want to use is boost::timer.
This is what I did:
git clone --recursive https://github.com/boostorg/boost.git
cd boost
./bootstrap.sh
./b2 headers
./b2
This kind of worked. However I expected the static library to be located in a different path. It was compiled into this path:
.../boost/bin.v2/libs/timer/build/gcc-9/release/link-static/threading-multi/visibility-hidden/libboost_timer.a
This path is very verbos and it contains the compiler and its version which means I would need to update the paths when updating GCC or changing the compiler.
I would have expected it here:
.../boost/libs/timer/libboost_timer.a
Did I do something wrong? Is the placement expected that way?
Ok, when reading the build output carefully even a fool like me could notice that the actual path is boost/stage/lib. All built libs can be found there.

How can I build an individual boost library forked cloned from git?

Boost using this build system I'm not otherwise familiar with, based on "Jam" files. Now, I've forked and cloned a specific Boost library (program_options), and I want to build it and perhaps also run the tests. I notice a build/Jamfile.v2 - what should I do with it?
I tried apt-get install jam on my distribution, but that did not get me very far:
$ jam -fbuild/Jamfile.v2
warning: unknown rule project
warning: unknown rule boost-lib
don't know how to make all
...found 2 target(s)...
...can't find 1 target(s)...
Also, do I have to get the absolute latest development version of all of Boost to build the cloned library against, or can I use a local boost release I already have?
Notes:
I'm on a recent GNU/Linux distribution (Mint 18.3 but this shouldn't matter).
What I've done, based on #SergeyA and others' advice, is:
Clone all of Boost, recursively (see this page (this will create a boost/ folder )
cd boost
in .git/modules/my_boost_lib/config, change the origin URL to your fork
in .gitmodules, under [submodule "my_boost_lib"], change the URL to your fork
execute git submodule update --init libs/my_boost_lib/ (perhaps after deleting that library; not sure if that's actually necessary)
cd libs/my_boost_lib/build
../../../b2
The latter works because b2 looks for a Jamfile.v2 in its current working directory, and that file exists and is intended to build just the library. The build results will be located outside of libs/my_boost_lib though.
Note: To build run the library tests, build the same way but from libs/my_boost_lib/test.
Essentially the build steps is
Run bootstrap to build the build tool b2
Build boost with b2 install or similar. You may want to provide options to it.
Read more in the boost getting started document:
http://www.boost.org/doc/libs/1_66_0/more/getting_started/index.html
(hint, look at lower right to go to next page..)
If you are on windows / VS2017, the use of vcpkg to get boost is very easy.

What's the difference between b2 and ./bootstrap.sh when building python

Sorry if this has already been asked? I've build boost from source but have always been confused about the build tools. Which tool should be used when building the boost libraries from scratch. To me it seems that bootstrap.sh is used to create the bjam executable and then bjam should be used to do the actual build. However, I've noticed that you can pass lots of parameters to bootstrap.sh such as the toolset (compiler) to use and the libraries to build, etc...and launch the build with bootstrap.sh
Also, there are at least three different ways of starting a build: ./bootstrap.sh, bjam, b2
Could someone summarize the purpose of each as the online docs don't seem to explain this
Thanks!
Anwar
b2 is just the second version of bjam. The bootstrap.sh script just builds the boost jam executable from the source code contained in the boost source, creates project-config.jam and executes the executable. You can see the shell script here

./Configure for non-boost ASIO

I take a look inside the asio folder there are
asio.manifest
autogen.sh
boost_asio.manifest
boostify.pl
configure.ac
include/
INSTALL
src/ (there are asio_ssl.cpp and asio.cpp)
I didn't see any configure script where I can execute. How do I build this asio?
I read asio is a header only library.
So, what I can make out of those files in the asio folder?
If you got it from a tarball, you should already have a configure script ready to be executed. If you checked from the repository, you probably need to run ./autogen.sh to generate the configure script for you, using configure.ac as input.
The convention is:
./bootstrap: it invokes autoconf to process configure.ac and spit out configure. Often it also invokes automake to process all Makefile.am files and turn them into Makefile.in. Many moons ago, the name autogen.sh was used instead of bootstrap. And configure.in was used instead of configure.ac.
./configure: detects everything on the system and creates config.status, then executes it.
./config.status: processes all *.in files into versions without the .in suffix. That includes Makefile.in -> Makefile. You don't have to run this script by hand.
INSTALL: this SHOULD contain build instructions, such as "run ./autogen.sh if you checked out a copy from the repository". Shame on the ASIO developers, they just point the user to look for a non-existing "doc" directory.
You need autoconf (and friends) installed to transform configure.ac into configure. Once that is done, the build system becomes self-contained. That is, you can do a make dist-gzip to pack all the sources (and the configure script), transfer the tar.gz it to another system, and follow from the ./configure step, even if autoconf is not installed there.
So, Here are the steps I've followed just now.
I went to http://think-async.com, which is the website that hosts the non-boost asio.
Their download link led me to sourceforge, and version 1.4.8 of the software.
I then extracted the folder, and looking inside, I see the usual layout.
So the following steps include ./configure, make, and probably sudo make install.

Building c++ project in Ubuntu Linux with Makefile.am/Makefile.in

I am new in Ubuntu/Linux and I've been working with java using the NetBeans IDE, so I don't have much experience with building c++ projects. But now I have to provide a proof of concept and I need to connect a C++ client with my ActiveMQ server. I downloaded The ActiveMQ-CPP API from this link, but I can't build/run it.
The download came with the files: Maklefile.am and Makefile.in. I searched it and I found that I need automake/autoconf to build it. I tried running ./configure but it says that it couldn't find such file or directory. I tried
sudo apt-get update
sudo apt-get install automake
sudo apt-get install autoconf
and a lot of other commands that I found on the Internet. None of then worked. I know that this question is really basic and it seems to be already answered somewhere else, but every attempt I've made failed. I think I'm missing something. I even tried the solution provided in the last message in this topic but it didn't work either.
Can anyone help me install autoconf/automake, or tell me how to use Makefile.am / Makefile.in to build the project I downloaded, or even suggest me some other way of building it?
Since you're open to other methods of building your project, I'm going to suggest CMake. It is a far better build system than autotools (at least from where I stand).
#CMakeLists.txt
project(MyProject CXX)
set_minimum_required(VERSION 2.8)
add_executable(foobar foo.cpp bar.cpp)
That example will build an executable called "foobar" by compiling and linking foo.cpp and bar.cpp. Put the above code in a file called CMakeLists.txt, then run the following commands:
cmake <path to project> #run in the folder you want to build in
make #this does the actual work
The really cool thing about CMake is that it generates a build system (Makefiles by default) but you can use it to generate project files for Eclipse, a Visual Studio solution, and a bunch of other things. If you want more information, I'd check out their documentation.
The "configure" script should be in your ActiveMQ-cpp source directory. From the Linux command line, you should be able to:
1) "cd" into your ActiveMQ* directory
2) "ls -l" to see the "configure" script
3) "./configure" to set things up for building the library\
4) "make" to actually build the library
This is mentioned in comments, but this particular point of confusion has been common for well over a decade and I think needs to be clarified as often as possible. You DO NOT need to have autoconf or automake installed to build a project that used those tools. The entire point of the autotools is to generate a build system that will build on a system using only the standard tools (make, a c compiler, sh, and few others.) Unfortunately, many developers release tarballs that do not build cleanly. If you unpack the tarball and it does not contain a configure script, or if the configure script is broken, that is a bug in the package. The solution is absolutely not to install autoconf/automake/libtool and try to produce a working configure script. The solution is to report the build error as a bug to the package maintainer.
The world would be a better place if Linux distributions stopped installing multiple versions of the autotools by default as less than .002% of the population needs those tools, and anyone who actually needs to have the tools should be capable of installing it themselves. Anyone incapable of acquiring and installing the tools has no business using them.