Issue with Boost libraries cross compilation - linux

I am trying to cross compile Boost, but I ended up with the following errors.
I have done the following steps:
Unzipped boost_1_68_0.tar.bz2
Executed Bootstrap
Edited user-config.jam using
gcc:arm:arm-fslc-linux-gnueabi-g++
Executed ./b2 --prefix=install toolset=gcc-arm --user-config=./user-config.jam
also exceuted ./bjam --prefix=install toolset=gcc-arm --user-config=./user-config.jam
But I ended up with the following error:
"arm-fslc-linux-gnueabi-g++" -fPIC -pthread -O3 -finline-functions -Wno-inline -Wall -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DNDEBUG -I"." -c -o "bin.v2/libs/wave/build/gcc-arm/release/threading-multi/cpplexer/re2clex/aq.o" "libs/wave/src/cpplexer/re2clex/aq.cpp"
...failed gcc.compile.c++ bin.v2/libs/wave/build/gcc-arm/release/threading-multi/cpplexer/re2clex/aq.o...
gcc.compile.c++ bin.v2/libs/wave/build/gcc-arm/release/threading-multi/cpplexer/re2clex/cpp_re.o
libs/wave/src/cpplexer/re2clex/cpp_re.cpp:20:10: fatal error: ctime: No such file or directory
#include <ctime>
^~~~~~~
compilation terminated.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are a lot of errors like these.

The problem is with the sysroot. We have to pass sysroot also with the compiler:
gcc : arm : arm-fslc-linux-gnueabi-g++ -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/opt/iotgw-sdk-prod/sysroots/armv7at2hf-neon-fslc-linux-gnueabi
Note: The blank spaces should tabs, not spaces.

Related

gcc cannot find standard libraries on mac (when installing python packages from requirements)

I am having an issue due to my gcc missing standard libraries.
copying blpapi/schema.py -> build/lib.macosx-10.7-x86_64-3.7/blpapi
running build_ext
building 'blpapi._internals' extension
creating build/temp.macosx-10.7-x86_64-3.7
creating build/temp.macosx-10.7-x86_64-3.7/blpapi
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/anaconda3/envs/invtools/include -arch x86_64 -I/anaconda3/envs/invtools/include -arch x86_64 -I/usr/local/lib/blpapi_cpp_3.8.1.1/include -I/anaconda3/envs/invtools/include/python3.7m -c blpapi/internals_wrap.cxx -o build/temp.macosx-10.7-x86_64-3.7/blpapi/internals_wrap.o
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
blpapi/internals_wrap.cxx:3101:10: fatal error: 'stdexcept' file not found
#include <stdexcept>
^~~~~~~~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
I had a different issue initially. It was something about cannot find type uint8_t. And someone suggested to delete files in: /usr/local/include/. And that causes the above now. It is because there are no standard libraries now. I installed this /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg and now I have standard lib in /usr/include. Which I copied to /usr/local/indclude/ to no avail. brew link gcc tells me:
Warning: Already linked: /usr/local/Cellar/gcc/8.2.0
To relink: brew unlink gcc && brew link gcc
How do I resolve this issue?

Could not determine size of CHARACTER while installing openmpi

I am trying to install openmpi on Amazon ec2 instance. I have uninstalled the openmpi installations present in the system using -
yum remove -y openmpi.x86_64 openmpi-devel.x86_64
This removes 2.1.1-1.31.amzn1 version of openmpi and openmpi devel.
I have downloaded the tar file from official openmpi site. When I try running configure, I get the following error -
checking if C and Fortran are link compatible... yes
checking to see if Fortran compiler likes the C++ exception flags... skipped (no C++ exceptions flags)
checking to see if mpifort compiler needs additional linker flags... none
checking if Fortran compiler supports CHARACTER... yes
checking size of Fortran CHARACTER... configure: WARNING: Could not determine size of CHARACTER
configure: WARNING: See config.log for details
configure: error: Cannot continue
Errors in config.log file -
configure:37098: $? = 0
configure:37111: result: yes
configure:37146: checking size of Fortran CHARACTER
configure:37214: /usr/lib/a-4.2.0-py-3.5.3-dl-gpu-full/bin/x86_64-conda_cos6-linux-gnu-cc -DNDEBUG -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -finline-functions -fno-strict-aliasing -I. -c conftest.c
configure:37221: $? = 0
configure:37231: gfortran conftestf.f90 conftest.o -o conftest -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now
/usr/bin/ld: conftest.o: unrecognized relocation (0x29) in section .text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
configure:37238: $? = 1
configure:37259: here is the Fortran program:
program fsize
I have tried with ./configure —disable-fortran as well but I am getting the same error.
Any help will be appreciated.

Use only local library with cross compiler

I'm trying to build one application with cross compiler on linux. Application is based on OpenEmbedded project. Compiler and all cross compiled libraries are located in build folder. But for one package build script is trying to use a library from my linux environment.
Command which is called from make script at the end:
/bin/sh ./arm-ABC-linux-gnueabi-libtool --tag=CXX --mode=link
arm-ABC-linux-gnueabi-g++ -march=armv7-a -mtune=cortex-a8
-mfpu=neon -mfloat-abi=softfp -g --std=c++0x -pthread -L/home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/opt/my/lib
-Wl,-rpath-link,/home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/opt/my/lib
-Wl,-O1 -Wl,--hash-style=gnu -L/opt/my/lib -o modbus_server_test modbus_server_test.o Serial.o SerialUtil.o Crc.o RtuFramer.o Pdu.o
SerialMaster.o
/home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/usr/local/apr/lib/libapr-2.la
-lcrypt -luuid -lrt -lcrypt -lpthread -ldl -lexpat -lstdc++
Most important from here that is use -lexpat flag for libexpat.so.1.5.2 library. This library is cross compiled and located in the build folder, and at the same time, we have one in my linux environment.
As result I recieve the next error:
| arm-ABC-linux-gnueabi-libtool: link:
arm-ABC-linux-gnueabi-g++ -march=armv7-a -mtune=cortex-a8
-mfpu=neon -mfloat-abi=softfp -g --std=c++0x -pthread -Wl,-rpath-link -Wl,/home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/opt/my/lib
-Wl,-O1 -Wl,--hash-style=gnu -o .libs/modbus_server_test modbus_server_test.o Serial.o SerialUtil.o Crc.o RtuFramer.o Pdu.o
SerialMaster.o
-L/home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/opt/my/lib
-L/opt/my/lib /usr/local/apr/lib/libapr-2.so -L/home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/usr/lib
/usr/lib/x86_64-linux-gnu/libexpat.so
/home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/usr/lib/libuuid.so
-lrt -lcrypt -lpthread -ldl /home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/usr/lib/libexpat.so
/home/ABC/build/build/sysroots/armv7a-ABC-linux-gnueabi/usr/lib/libstdc++.so
-lm -pthread -Wl,-rpath -Wl,/usr/local/apr/lib -Wl,-rpath -Wl,/home/ABC/build/sysroots/armv7a-ABC-linux-gnueabi/usr/lib
| /usr/lib/x86_64-linux-gnu/libexpat.so: file not recognized: File
format not recognized
| collect2: ld returned 1 exit status
| make[2]: *** [modbus_server_test] Error 1
From output I can see that it include two libraries: one from linux environment (/usr/lib/x86_64-linux-gnu/libexpat.so which is x86) and one from the build folder (build/sysroots/armv7a-ABC-linux-gnueabi/usr/lib/libexpat.so which is for ARM).At the end it complains about x86 type.
How can I exclude this library from searching in global environment? Why it even trying to use both of them?

Unable to compile C program on Mac, but able to compile on Linux

I facing some trouble compiling my programming assignment on my local machine. The program is distribute to us with makefiles and compilation commands that are known to work on the school's Scientific Linux servers. My local machine is Mac OS X El Capitan.
When I compile my program running make on my Mac, I get the following error that prevents compilation from proceeding:
myid-MacBook-Pro:mp6 myid$ make
gcc -g -lm -std=c99 -Wall -Werror -c lodepng.c
clang: error: -lm: 'linker' input unused
make: *** [lodepng.o] Error 1
But when I push that very same code as work in progress to the Linux servers and compile there, everything works fine. The linux servers use gcc and not clang:
[netid#linux-a2 mp6]$ make
gcc -g -lm -std=c99 -Wall -Werror -c functions.c
gcc -g -lm -std=c99 -Wall -Werror main.o lodepng.o imageData.o functions.o -o mp6 -lm
gcc -g -lm -std=c99 -Wall -Werror -c test.c
gcc -g -lm -std=c99 -Wall -Werror test.o lodepng.o imageData.o functions.o solution.o -o test -lm
In the makefile, these are the variable definitions:
CC=gcc
CFLAGS=-g -lm -std=c99 -Wall -Werror
and the target definition for loadpng.o
lodepng.o: lodepng.c
$(CC) $(CFLAGS) -c lodepng.c
I would appreciate any help on understanding this error and overcoming it.
Thank you very much.
Also, on this note, I thought I would say that I've noticed a subtle difference between Clang and GCC. It seems to me that even warnings generated by Clang would prevent the compilation to proceed so the warnings behaves like errors. But for GCC, if it generates warnings, it still compiles the object file. Please correct me if I'm mistaken.
Right now you're getting a compilation error on your Mac because you're trying to pass linker commands (i.e. -lm) into a compilation(i.e. -c). Do not give link flags when you compile (-c flag) your source files.
In the other compilation snippet you provided, the unused linker command seems to pass by unnoticed which isn't a good thing.
For your last question, the flag -Werror should force all compilation warnings to become errors -- which is exactly what you are describing.

Can't make node.js ubuntu 13.10

I'm trying to install node.js, so I've cloned the repo and ./configure it. However, when I run make I get this ridiculous infinite loop of errors:
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory `/home/ubuntu/nodejs/node/out'
g++ '-DOPENSSL_NO_SSL2=1' '-DV8_TARGET_ARCH_X64' '-DENABLE_DEBUGGER_SUPPORT' -I../deps/v8/src -pthread -Wall -Wextra -Wno-unused-parameter -m64 -fno-strict-aliasing -m64 -O3 -ffunction-sections -fdata-sections -fno-tree-vrp -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -MMD -MF /home/ubuntu/nodejs/node/out/Release/.deps//home/ubuntu/nodejs/node/out/Release/obj.target/v8_base.x64/deps/v8/src/runtime.o.d.raw -c -o /home/ubuntu/nodejs/node/out/Release/obj.target/v8_base.x64/deps/v8/src/runtime.o ../deps/v8/src/runtime.cc
In file included from ../deps/v8/src/v8.h:52:0,
from ../deps/v8/src/runtime.cc:31:
../deps/v8/src/../include/v8.h: In member function ‘void v8::ReturnValue<T>::Set(uint32_t)’:
../deps/v8/src/../include/v8.h:5816:31: warning: typedef ‘I’ locally defined but not used [-Wunused-local-typedefs]
typedef internal::Internals I;
^
In file included from ../deps/v8/src/v8globals.h:32:0,
from ../deps/v8/src/v8.h:53,
from ../deps/v8/src/runtime.cc:31:
../deps/v8/src/v8utils.h: In function ‘void v8::internal::CopyWords(T*, const T*, size_t)’:
../deps/v8/src/checks.h:271:22: warning: typedef ‘__StaticAssertTypedef__131’ locally defined but not used [-Wunused-local-typedefs]
SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
^
../deps/v8/src/checks.h:261:39: note: in definition of macro ‘SEMI_STATIC_JOIN_HELPER’
#define SEMI_STATIC_JOIN_HELPER(a, b) a##b
^
../deps/v8/src/checks.h:271:5: note: in expansion of macro ‘SEMI_STATIC_JOIN’
SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
^
../deps/v8/src/checks.h:319:30: note: in expansion of macro ‘STATIC_CHECK’
#define STATIC_ASSERT(test) STATIC_CHECK(test)
This seems to be a bug but I have g++4.8.1 gcc-4.8.1 which are the latest versions that I know of. Please let me know how I can fix this. Thanks.
There is an easier way than bringing old g++, as mentioned in V8 bug report discussion:
http://code.google.com/p/v8/issues/detail?id=2149
You could set additional flag for g++ before using make:
export CXX="g++ -Wno-unused-local-typedefs"
I've had problems with g++ 4.8 compiling v8 (which Node uses), and a bunch of other stuff, so I use 4.7. First install g++-4.7 using apt-get (which I trust you know how to do), and then:
CXX=g++-4.7 make [... etc...]

Resources