meson gcc path configuration - gcc

Hi in my project I configure the gcc to be used by the option
meson build --cross-file mygcc.txt
in the file mygcc.txt I set the gcc commands needed:
[binaries]
c = '/usr/bin/gcc'
cc = '/usr/bin/gcc'
cpp = '/usr/bin/g++'
ar = '/usr/bin/gcc-ar'
strip = '/usr/bin/strip'
ld = '/usr/bin/ld'
....
I wonder if it is possible to set dynamically the root where the gcc is installed.
for example if I use gcc-toolset I can switch the default gcc installed under
/user/bin
to
/opt/rh/gcc-toolset-9/root/usr/bin
and in order to use the new gcc I need to change the path in mygcc.txt , remove the build dir and reconfigure meson.
but is it possible to configure meson in order to pick the gcc set in the bash used?
devel#lnx+ which gcc
/opt/rh/gcc-toolset-9/root/usr/bin/gcc

In order to solve the problem I have modified the mygcc.txt file in
[binaries]
c = 'gcc'
cc = 'gcc'
cpp = 'g++'
ar = 'gcc-ar'
strip = 'strip'
ld = 'ld'
pkgconfig = 'pkg-config'
.......
then in the .bashrc I have added
#source gcc
source /opt/rh/gcc-toolset-9/enable

Related

Linker script fails in Yocto build

I am trying to use Bitbake tool for the cross-compilation of a Git project from x86 architecture to aarm64 architecture, but I am getting ld errors during the do_compile stage. I already checked d/tmp/work/aarch64-xilinx-linux/commandlinetool/1.0+gitAUTOINC+ce84868f3c-r0/recipe-sysroot/ and those missing files are actually exist! I don't know why bitbake complains about missing files. I also tried to add related paths to my custom recipe using FILES_${PN} = "" but this didn't help.
Also, I have glibc as a dependency in my recipe but this doesn't help:
# dependencies DEPENDS += "glibc" RDEPENDS_${PN} = "glibc"
Errors I am getting are as the following:
| ~/bin/build/tmp/work/aarch64-xilinx-linux/commandlinetool/1.0+gitAUTOINC+ce84868f3c-r0/recipe-sysroot-native/usr/bin/aarch64-xilinx-linux/../../libexec/aarch64-xilinx-linux/gcc/aarch64-xilinx-linux/9.2.0/ld: cannot find /lib/libc.so.6
| ~/bin/build/tmp/work/aarch64-xilinx-linux/commandlinetool/1.0+gitAUTOINC+ce84868f3c-r0/recipe-sysroot-native/usr/bin/aarch64-xilinx-linux/../../libexec/aarch64-xilinx-linux/gcc/aarch64-xilinx-linux/9.2.0/ld: cannot find /usr/lib/libc_nonshared.a
| ~/bin/build/tmp/work/aarch64-xilinx-linux/commandlinetool/1.0+gitAUTOINC+ce84868f3c-r0/recipe-sysroot-native/usr/bin/aarch64-xilinx-linux/../../libexec/aarch64-xilinx-linux/gcc/aarch64-xilinx-linux/9.2.0/ld: cannot find /lib/ld-linux-aarch64.so.1
Edit: Here is the recipe I am using. It depends on another Git project named "deviceaccess" (which my recipe for that project cross-compiled successfully):
LICENSE = "GPLv3 & Unknown"
LIC_FILES_CHKSUM = "file://LICENSE;md5=84dcc94da3adb52b53ae4fa38fe49e5d \
file://cmake/debian_package_templates/copyright;md5=0630bd8af87d19e6a57f9d1f9c5cf11f"
SRC_URI = "git://github.com/ChimeraTK/CommandLineTools.git;protocol=https"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "ce84868f3c86f3f0790772a31fb5202a14f38fb8"
S = "${WORKDIR}/git"
# dependencies
DEPENDS += "glibc deviceaccess"
RDEPENDS_${PN} = "glibc deviceaccess"
# cmake
inherit pkgconfig cmake
FILES_${PN} = ""
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OEMAKE = ""

Compilation error (ld: cannot find libmvec_nonshared.a,libmvec.so.1) while using Installed GCC-4.5.3

Unable to print traceback or stackdump using GCC-4.8.5 as starting with GCC version 4.6, the default setting has been changed to -fomit-frame-pointer. Read in the internet like the default can be reverted to -fno-omit-frame-pointer by configuring GCC with the --enable-frame-pointer configure option. So I installed GCC-4.5.3 in my home directory with below configure options.
Configure options:
../gcc-4.5.3/configure -v --prefix=/home/GCC1-4.5.3/usr --infodir=/home/GCC1-4.5.3/usr/build/share/info --mandir=/home/GCC1-4.5.3/usr/build/share/man --libdir=/home/GCC1-4.5.3/usr/build/lib64 --libexecdir=/home/GCC1-4.5.3/usr/build/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java --with-gxx-include-dir=/home/GCC1-4.5.3/usr/build/include --enable-ssp --enable-frame-pointer --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/home/GCC1-4.5.3/usr/build/lib64 --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --enable-linux-futex --program-suffix=-4.5.3 --without-system-libunwind --with-arch-32=i686 --with-tune=generic --build=x86_64-suse-linux --host=x86_64-suse-linux
Before including my installed GCC compiler my Makefile.common looks as below:
CROSS_COMPILER_PREFIX = x86_64-dx-linux-gnu
ADDR2LINE = $(CROSS_COMPILER_PREFIX)-addr2line
AR = $(CROSS_COMPILER_PREFIX)-ar
AS = $(CROSS_COMPILER_PREFIX)-as
CXX = $(CROSS_COMPILER_PREFIX)-c++
CXXFILT = $(CROSS_COMPILER_PREFIX)-c++filt
CPP = $(CROSS_COMPILER_PREFIX)-cpp
GXX = $(CROSS_COMPILER_PREFIX)-g++
GCC = $(CROSS_COMPILER_PREFIX)-gcc
GCCBUG = $(CROSS_COMPILER_PREFIX)-gccbug
GCOV = $(CROSS_COMPILER_PREFIX)-gcov
LD = $(CROSS_COMPILER_PREFIX)-ld
After installing, I have included the compiler in my Makefile.common as below:
CROSS_COMPILER_PREFIX = x86_64-dx-linux-gnu (GCC-4.8.5 Prefix)
CROSS_COMPILER_PREFIX = x86_64-suse-linux(My installed GCC-4.5.3 Prefix)
ADDR2LINE = $(CROSS_COMPILER_PREFIX)-addr2line
CXX = $(CROSS_COMPILER_PREFIX)-c++-4.5.3
CXXFILT = $(CROSS_COMPILER_PREFIX)-c++filt
CPP = $(CROSS_COMPILER_PREFIX)-cpp-4.5.3
GXX = $(CROSS_COMPILER_PREFIX)-g++-4.5.3
GCC = $(CROSS_COMPILER_PREFIX)-gcc-4.5.3
GCCBUG = $(CROSS_COMPILER_PREFIX)-gccbug
GCOV = $(CROSS_COMPILER_PREFIX)-gcov-4.5.3
LD = $(CROSS_COMPILER_PREFIX)-ld
After including when I try to give make command it fails with below error
/usr/bin/ld: cannot find /usr/lib64/libmvec_nonshared.a
/usr/bin/ld: cannot find /lib64/libmvec.so.1
collect2: ld returned 1 exit status
Also I observed that these both libraries are present in another path and not present in the above mentioned (/usr/lib64/, /lib64) path. I don't have permissions to run sudo command or to create link or make any changes in /usr/ path. The below is the output when I run ld -lmvec --verbose.
attempt to open /usr/x86_64-suse-linux/lib64/libmvec.so failed
attempt to open /usr/x86_64-suse-linux/lib64/libmvec.a failed
attempt to open /usr/lib64/libmvec.so failed
ld: cannot find -lmvec
Note:
The make is successfull with GCC_4.8.5 where as the make is failing with my installed GCC_4.5.3.
Can anyone please help me to resolve this issue? Do I need to change anything in Makefile.common? why the make is successfull with GCC_4.8.5 and it is failing for GCC_4.5.3 ?
How to make changes in Makefile to make ld search in the library present path ?
In addition to this query can any one pls help me to check whether frame-pointer is omitted or not?
Thanks in Advance.
If you are compiling gcc try with --with-glibc-version=xxx. I use my own toolchain where I added glibc version specified in gcc compiler which solve the problem.

how can i edit my opencv flags on windows?

A line in the README says :
manually specify the OpenCV flags in the Makefile as following:
INCS = -I/usr/local/include/opencv
LIBS = -L/usr/local/lib -lcxcore -lcv -lhighgui -lcvaux -lml
I'm using Windows(OpenCV version 3.3.1). Can you guess what should I use instead to make it work on Windows?
Here's a link to the Makefile https://github.com/npinto/fddb-evaluation/blob/master/Makefile

Compiling library in g++ using C++11

I'm been attempting to compile an open-source C++ library (QuantLib-1.7) on my mac for several days but I seem to be encountering some kind of C++11 compatibility issue.
When I run make && sudo make install from the terminal the compilation seems to work except for a bunch of errors of the form
Making all in BermudanSwaption
g++ -DHAVE_CONFIG_H -I. -I../../ql -I../.. -I../.. -I/opt/local/include -g -O2 -MT BermudanSwaption.o -MD -MP -MF .deps/BermudanSwaption.Tpo -c -o BermudanSwaption.o BermudanSwaption.cpp
In file included from BermudanSwaption.cpp:22:
In file included from ../../ql/quantlib.hpp:43:
In file included from ../../ql/experimental/all.hpp:25:
In file included from ../../ql/experimental/volatility/all.hpp:21:
In file included from ../../ql/experimental/volatility/zabr.hpp:31:
In file included from ../../ql/math/statistics/incrementalstatistics.hpp:35:
In file included from /opt/local/include/boost/accumulators/statistics/stats.hpp:14:
In file included from /opt/local/include/boost/accumulators/statistics_fwd.hpp:12:
/opt/local/include/boost/mpl/print.hpp:50:19: warning: in-class initialization
of non-static data member is a C++11 extension [-Wc++11-extensions]
const int m_x = 1 / (sizeof(T) - sizeof(T));
^
1 warning generated.
I'm guessing this has something to do with g++ not being correctly configured for C++11. I'm familiar with the fact that C++11 can be invoked by compiling with g++ -std=c++11. However, despite a lot of googling I can't find a way to modify the makefile such that -std=c++11 is called when I run make && sudo make install.
Any help would be greatly appreciated.
Here is the section of the makefile which I believe is relevant:
BOOST_INCLUDE = -I/opt/local/include
BOOST_LIB = -L/opt/local/lib
BOOST_THREAD_LIB =
BOOST_UNIT_TEST_DEFINE = -DQL_WORKING_BOOST_STREAMS
BOOST_UNIT_TEST_LIB = boost_unit_test_framework-mt
BOOST_UNIT_TEST_MAIN_CXXFLAGS = -DBOOST_TEST_DYN_LINK
CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2
CPP = gcc -E
CPPFLAGS = -I/opt/local/include
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
CXXFLAGS = -g -O2
Here is the output from running "g++ -v":
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
Makefile.am: https://www.dropbox.com/s/v5j7qohwfup81od/Makefile.am?dl=0
Makefile.in: https://www.dropbox.com/s/t92hft9ea2ar1zw/Makefile.in?dl=0
QuantLib-1.7 directory: https://www.dropbox.com/sh/ulj0y68m8x35zg8/AAA-w7L2_YWIP8_KnwURErzYa?dl=0
Full error log: https://www.dropbox.com/s/g09lcnma8skipv7/errors.txt?dl=0
Add something like
CXXFLAGS += -std=c++11
to your Makefile. This will work regardless of the Darwin-specific munging of the g++ executable---it's really clang++.
References:
https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc/C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options
https://gcc.gnu.org/projects/cxx0x.html
http://clang.llvm.org/cxx_status.html
https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
As you already have, and are familiar with homebrew, my suggestion would be to use that to install and manage quantlib like this:
brew install quantlib
That will then build and put all the files in /usr/local/Cellar/quantlib under some version number that is not of importance. The important thing is the the tools are then linked into /usr/local/bin so all you need to do is make sure that /usr/local/bin is in your PATH.
That gives you access to the tool quantlib-config which is always linked to the latest version and it knows which version that is. So, if you run:
quantlib-config --cflags
it will tell you what the correct path is for your includes like this:
-I/usr/local/Cellar/quantlib/1.6.1/include
Likewise, if you run:
quantlib-config --libs
it will tell you the correct linking directories and libraries for your latest version.
In short, all you need to do to compile is:
g++ $(quantlib-config --cflags --libs)
and it will always pull in the version you are using.
Note that if you use a Makefile, you will need to double the dollar signs.
This is how I eventually managed to compile the Quantlib library for future reference. It is probably not the most efficient/elegant method but it appears to work.
I followed the steps given in http://quantlib.org/install/macosx.shtml and found that running make && sudo make install led to the error reported in the OP.
Create a new static library C++ project in Eclipse called 'Quantlib'
Copy the ql directory located in the .tar file to the Quantlib Eclipse workspace
Right-click Quantlib > Properties > C/C++ Build > Settings > Cross G++ Compiler: Change the Language standard to ISO C++ 11 (-std=c++0x)
Right-click Quantlib > C/C++ General > Paths and Symbols: Add the following include directories for GNU C++
opt/local/include
/Quantlib (check "Is a workspace directory")
/opt/local/include/boost.
Build the Quantlib project (around 34 min on MacBook Air 1.8 GHz Intel Core i7)
Create a new C++ executable project (e.g. BermudanSwaption) and copy the BermudanSwaption.cpp into the BermudanSwaption Eclipse workspace
Repeat steps 4. and 5. for the BermudanSwaption Eclipse project
Right-click BermudanSwaption > Properties > C/C++ General > Paths and Symbols > References: check Quantlib (the Library Paths tab should now contain the entry '/Quantlib/Debug')
Build and run the BermudanSwaption executable project
QuantLib-1.7
OSX Yosemite 10.10.5
Eclipse C/C++ Development Tools Version: 8.8.0.201509131935
Xcode Version 7.1 (7B91b)
xcode-select version 2339.

Understanding LD options in make file

I recently downloaded the graclus software. While trying to install it I had to be complete the makefile.in with some options.I figured out other options but I couldn't find what do we write for the LDOPTIONS.
Can anybody help me out in figuring what do I fill in the options used by the compiler?
Help will be truly appreciated.
//Here is the makefile.in
# Which compiler to use
CC = g++
# What optimization level to use
OPTFLAGS = -O2 -fPIC
# What options to be used by the compiler
COPTIONS = -DNUMBITS=32
# What options to be used by the loader
LDOPTIONS =
# What archiving to use
AR = ar rv
# What to use for indexing the archive
RANLIB = ranlib
ARCH = P4SSE2
LAPACK = -llapack_$(ARCH)
ARPACK = -lcarpack_$(ARCH)
ATLAS = -latlas_$(ARCH)
CBLAS = -lcblaswr -lcblas -lblas -lmyf2c
GSL = -lgslcblas -lgsl
SPARSE = -lsparse
UTIL = -lmyutil
Since the Makefile you provided is just an excerpt and you've not mentioned what package or library you're compiling it with, I'm just making a wild-guess here.
LDOPTIONS could serve a similar puprose as the commonly used variable LDFLAGS which provides a way to specify extra flags to the linker. It depends on the linker you use. If you're using gcc, then you can run man ld to see the list of linker options.

Resources