boost built project on i386 fails to link - c++

I am using a project named "GenericMod" which internally uses boost library 1.58.0.
Previously the boost 1.58 was compiled on a Red Hat Enterprise Linux Server release 5.8 (Tikanga)
whose gcc -v output was as follows
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-55)
It was compiled using the following command
./b2 install -a --includedir=testbuild/include --libdir=testbuild/lib --layout=system variant=release target-os=linux link=static runtime-link=static address-model=32 cxxflags=-fPIC
Now, when the project "GenericMod" was build, on the same machine, build was successful and there was no error.
But recently the build environment was changed. The project is being built in a new machine now which is Red Hat Enterprise Linux Server release 5.9 (Tikanga)
and its gcc -v output
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)
When the project is built in this machine now, i was getting linker errors (probably as the boost libraries were built on a different environment).
So i built the boost 1.58.0 in this machine again with the same build command.
./b2 install -a --includedir=testbuild/include --libdir=testbuild/lib --layout=system variant=release target-os=linux link=static runtime-link=static address-model=32 cxxflags=-fPIC
Now when the project is built in this machine, my understanding is that there shouldnt be any error and the build should go through link phase.
But the linker error still occurs.
libboost_thread.a(thread.o): In function `boost::thread::physical_concurrency()':
thread.cpp:(.text+0x2084): undefined reference to `std::ctype<char>::_M_widen_init() const'
Can someone please explain why is this happening ? I have been breaking my head past week for this and couldn;t get enough explanation in other places.
Should i include some flag to specify the build for i386?
Thanks in advance

Related

conflicting declaration error when making ACE 7.0.0 with Cygwin64

My operating system is Windows x64
When I try to make ACE using Cygwin I get the following compilation error:
In file included from /cygdrive/c/resources/ACE_wrappers/ace/OS_NS_Thread.h:30,
from /cygdrive/c/resources/ACE_wrappers/ace/Thread_Mutex.h:29,
from /cygdrive/c/resources/ACE_wrappers/ace/Log_Category.h:18,
from /cygdrive/c/resources/ACE_wrappers/ace/ACE.cpp:9:
/cygdrive/c/resources/ACE_wrappers/ace/os_include/os_sched.h:45:6: error: conflicting declaration ‘typedef struct cpu_set_t cpu_set_t’
45 | } cpu_set_t;
| ^~~~~~~~~
In file included from /usr/include/sys/_pthreadtypes.h:12,
from /usr/include/sys/types.h:223,
from /cygdrive/c/resources/ACE_wrappers/ace/os_include/sys/os_types.h:28,
from /cygdrive/c/resources/ACE_wrappers/ace/os_include/os_unistd.h:25,
from /cygdrive/c/resources/ACE_wrappers/ace/os_include/os_limits.h:25,
from /cygdrive/c/resources/ACE_wrappers/ace/Basic_Types.h:52,
from /cygdrive/c/resources/ACE_wrappers/ace/ACE.h:29,
from /cygdrive/c/resources/ACE_wrappers/ace/ACE.cpp:1:
/usr/include/sys/cpuset.h:27:3: note: previous declaration as ‘typedef struct cpu_set_t cpu_set_t’
27 | } cpu_set_t;
Steps I have done before trying to make:
1- I installed Cygwin64 using the installer and I installed the gcc-g++, gcc-core, make, perl and binutils packages.
2- I ran the cygserver-config script and it finished successfully.
3- I downloaded ACE from https://download.dre.vanderbilt.edu/, I chose the "Full" ACE.zip (7.0.0) from the Micro releases
4- I created the config.h file with #include "ace/config-cygwin32.h" in it and placed it in ACE_wrappers/ace/
5- I created the platform_macros.GNU with "include $(ACE_ROOT)/include/makeinclude/platform_cygwin32.GNU" in it and placed it in ACE_wrappers/include/makeinclude/
6- I opened the Cygwin64 shell and did this:
export PATH=/cygdrive/c/cygwin64/bin:$PATH
export ACE_ROOT=/cygdrive/c/resources/ACE_wrappers
7- I did "cd $ACE_ROOT/ace" then I "make".
For the gcc version (from Cygwin shell gcc -v):
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/cygdrive/c/cygwin64/bin/../lib/gcc/x86_64-pc-cygwin/10/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-10.2.0/configure --srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-10.2.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --with-gcc-major-version-only --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)
The cygwin64 port isn't actively maintained so you need to update the ace/config-win32.h for this. You need to try which defines should be added to that file, when you have done that and it works, contribute your changes upstream at https://github.com/DOCGroup/ACE_TAO
The issues section at https://github.com/DOCGroup/ACE_TAO is a better place for any ACE questions.

Specify thread model on ubuntu mingw (if possible)

Im running a program on linux with g++ and everything works fine. If i compile using x86_64-w64-mingw32-g++ it crashes with error: ‘std::thread’ has not been declared.
The part where my code crashed is fairly simple:
#include <thread>
int main()
{
int cores = std::thread::hardware_concurrency();
}
I figured out that mingw uses win32 threads, i want it to use posix threads. Version is:
:~$ x86_64-w64-mingw32-g++ -v
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/9.3-win32/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --with-headers=/usr/x86_64-w64-mingw32/include --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --enable-threads=win32 --program-suffix=-win32 --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld --enable-libatomic --enable-libstdcxx-filesystem-ts=yes --enable-dependency-tracking
Thread model: win32
gcc version 9.3-win32 20200320 (GCC)
As you can see thread model is win32, (how) can i change it? In the mingw include paths there is a 9.3-posix folder, but it seems it isnt used so far.
As you can see here you can:
I'm installing mingw-w64 on Windows and there are two options: win32 threads and posix threads.
Is that possible on linux aswell?
It seems that the package g++-mingw-w64-x86-64 provides two executables:
x86_64-w64-mingw32-g++-posix: which uses posix
x86_64-w64-mingw32-g++-win32: which uses win32
Using the first executable should solve your issue.

Cannot Build Boost 1.47.0 IOStreams on Ubuntu

I am working on a legacy project for my company that requires me to use a specific version of boost and that version is 1.47.0. I have downloaded and run:
./b2 --toolset=gcc variant=debug
and it compiled the majority of the static libraries I needed with the exception of a few. One being libboost_iostreams. I did some research and found that it appeared i was missing some dependencies.
whereis bzip2
bzip2: /bin/bzip2 /usr/share/man/man1/bzip2.1.gz
whereis zlib
zlib: /usr/include/zlib.h /usr/share/man/man3/zlib.3.gz
However when I attempt to run:
./b2 --with-iostreams -s BZIP2_SOURCE=/bin -s ZLIB_SOURCE=/usr/include
I am getting the following error:
Building the Boost C++ Libraries.
error: Unable to find file or target named
error: '/bin/libbz2.def'
error: referred from project at
error: 'libs/iostreams/build'
Update:
Linux Version: 16.04
Gcc Version Info:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-
6ubuntu1~16.04.9' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --
enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --
program-suffix=-5 --enable-shared --enable-linker-build-id --
libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --
libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-
libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-
plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --
enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --
enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --
with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-
directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-
objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-
abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-
tune=generic --enable-checking=release --build=x86_64-linux-gnu --
host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)

How to install TBB on Windows and get it work with Eclipse

I want to install Intel's Thread Building Blocks on Windows and get it to work with the Eclipse IDE and C++. I've been new to the whole C, build from source, make, cmake, cygwin and other stuff.
What I've tried so far:
Load the TBB packages and source and try to include it in Eclipse
Try to 'make' TBB from source but only got Error 2 from GNUWin32make
Tried many tutorials, tips and much more that I don't remember any more
How can I do this?
Win 10 - 64bit, Eclipse Oxygen 4.7.0, cygwin 2.8.2, Compiler: mingw
As you can see in Release_Notes.txt, a library doesn't have a Cygwin support. However you have several cases:
Use Visual Studio and binary package
Use Linux (if you really need GCC)
Use Mingw without(!) Cygwin (difference). Building library from source code should work perfect in this case.
Port library to cygwin (it's a non-trivial but real solution)
lost the space by copiying here.
where g++
C:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev0\mingw64\bin\g++.exe
C:\MinGW\bin\g++.exe
g++ -v
Using built-in specs. COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\
Files/mingw-w64/x86_64-7.1.0-posix-seh-rt_v5-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/7.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32 Configured with:
../../../src/gcc-7.1.0/configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw710/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident
-I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS='
-I/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/include -I/c/mingw710/prerequisites/x86_64-zlib-static/include -I/c/mingw710/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident
-L/c/mingw710/x86_64-710-posix-seh-rt_v5-rev0/mingw64/opt/lib -L/c/mingw710/prerequisites/x86_64-zlib-static/lib -L/c/mingw710/prerequisites/x86_64-w64-mingw32-static/lib ' Thread model: posix gcc version 7.1.0 (x86_64-posix-seh-rev0, Built by
MinGW-W64 project)

GCC -v returns GCC 4.7.3 even though I unpacked 4.8.1?

so I went to this link Source Forge MinGW to download and install MinGW 4.8.1. (rev 5). I unpack it into C:\MinGW\mingw32. So I open command prompt (win 32 system) and run gcc -v and I get GCC is 4.7.3. This is the full output of gcc -v:
C:\MinGW\mingw32>gcc -v Using built-in specs. COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.7.3/lto-wrapper.exe
Target: i686-pc-cygwin Configured with:
/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src/gcc-4.7.3
/configure
--srcdir=/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src/gcc-4.
7.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --lib execdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --d atarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=i686-pc-cygwin --ho st=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix
--without-li bintl-prefix --enable-shared --enable-shared-libgcc --enable-static --enable-ver sion-specific-runtime-libs --enable-bootstrap --disable-__cxa_atexit --with-dwar f2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --enable-langu ages=ada,c,c++,fortran,java,lto,objc,obj-c++ --enable-graphite --enable-threads= posix --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmat h-support --enable-libssp --enable-libada --enable-libjava --enable-libgcj-subli bs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java/ecj.jar -
-with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-ppl --with-sy stem-zlib : (reconfigured) /cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/src
/gcc-4.7.3/configure
--srcdir=/cygdrive/i/szsz/git/cygwin-ports-gcc/gcc-4.7.3-1/ src/gcc-4.7.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin
--sbindir=/usr/ sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdi r=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=i686-pc-c ygwin --host=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix -- without-libintl-prefix --enable-shared --enable-shared-libgcc --enable-static -- enable-version-specific-runtime-libs --enable-bootstrap
--disable-__cxa_atexit -
-with-dwarf2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --en able-languages=ada,c,c++,fortran,java,lto,objc,obj-c++
--enable-graphite --enabl e-threads=posix --enable-libgomp --disable-libitm --enable-libquadmath --enable- libquadmath-support --enable-libssp --enable-libada --enable-libjava --enable-li bgcj-sublibs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java /ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-ppl --with-system-zlib Thread model: posix gcc version 4.7.3 (GCC)
C:\MinGW\mingw32>
I would like to know why it unpacked an earlier version and how to fix this. Apparently C::B see's it as an earlier build too! It really baffles me O.o
Also, the prompt returns that threads use Posix when it should be Win32, again really rattling my brain here.
If any one can point to some links, or clear any of this up it would be greatly appreciated!
What you unpacked, and what the OS presents when you call the program, need not be the same thing. Did you do a rehash? Confirm that the path is the same? Or is the new version at a later point in the path? You might want to alias the gcc command to the version you want. Type which gcc to see where the OS thinks the "current version" is located - that should help. EDIT I realize the which command may not work in windows (just noticed the C: drive letter) but the main point about paths is still valid.