compile aosp 32 bit linux - c++

looking to compile 4.4.2 aosp source following the guide https://groups.google.com/forum/#!topic/android-building/xFtX6K42BDE. why is host not compiling properly?
Install: /home/brandonabandon/sn/out/host/linux-x86/bin/acp
host StaticLib: libbz (/home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/libbz.a)
prebuilts/tools/gcc-sdk/ar crsP /home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/libbz.a /home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/blocksort.o /home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/huffman.o /home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/crctable.o /home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/randtable.o /home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/compress.o /home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/decompress.o /home/brandonabandon/sn/out/host/linux-x86/obj/STATIC_LIBRARIES/libbz_intermediates/bzlib.o
cp -fp /home/brandonabandon/sn/out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp /home/brandonabandon/sn/out/host/linux-x86/bin/acp
cp: cannot stat `/home/brandonabandon/sn/out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp': No such file or directory
make: *** [/home/brandonabandon/sn/out/host/linux-x86/bin/acp] Error 1
=make -j4 otapackage showcommands.
so earlier, cp cannot stat: /brandonabandon/host/blah/blah_intermediates blah.d: no such file or directory is occuring many times. i compiled 32 bit arm toolchains for building android with gcc 4.8, and kernel compilation with 4.9. my assumption is the host toolchain needs pointed accurately. if so, i dont know how to do it. any help?

gcc=
#!/bin/bash
*PROGNAME=`basename $0`
PREFIX32=../../gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/i686-linux
options=" ${#} "
# sentinel prefix/suffix space to simplify pattern match below
suffix_m32=${options##* -m32 } # suffix after the last -m32
len_m32=${#suffix_m32} # length of suffix after the last -m32
# Always choose 32-bit
MY_TOOL=`dirname $0`/${PREFIX32}-${PROGNAME}
*$MY_TOOL "$#"
i did a star before the required changes

Related

Configuring compilers on Mac M1 (Big Sur, Monterey) for Rcpp and other tools

I'm trying to use packages that require Rcpp in R on my M1 Mac, which I was never able to get up and running after purchasing this computer. I updated it to Monterey in the hope that this would fix some installation issues but it hasn't. I tried running the Rcpp check from this page but I get the following error:
> Rcpp::sourceCpp("~/github/helloworld.cpp")
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0'
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_4.so] Error 1
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I"/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/RcppArmadillo/include" -I"/Users/afredston/github" -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c helloworld.cpp -o helloworld.o
clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o sourceCpp_4.so helloworld.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
Error in Rcpp::sourceCpp("~/github/helloworld.cpp") :
Error 1 occurred building shared library.
I get that it can't "find" gfortran. I installed this release of gfortran for Monterey. When I type which gfortran into Terminal, it returns /opt/homebrew/bin/gfortran. (Maybe this version of gfortran requires Xcode tools that are too new—it says something about 13.2 and when I run clang --version it says 13.0—but I don't see another release of gfortran for Monterey?)
I also appended /opt/homebrew/bin: to PATH in R so it looks like this now:
> Sys.getenv("PATH")
[1] "/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/Applications/RStudio.app/Contents/MacOS/postback"
Other things I checked:
Xcode command line tools is installed (which clang returns /usr/bin/clang).
Files ~/.R/Makevars and ~/.Renviron don't exist.
Here's my session info:
R version 4.1.1 (2021-08-10)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.1 tools_4.1.1 RcppArmadillo_0.10.7.5.0
[4] Rcpp_1.0.7
Background
Currently (2023-02-20), CRAN builds R 4.2 binaries for Apple silicon using Apple Clang from Command Line Tools for Xcode 13.1 and using an experimental fork of GNU Fortran 12.
If you obtain R from CRAN (i.e., here), then you need to replicate CRAN's compiler setup on your system before building R packages that contain C/C++/Fortran code from their sources (and before using Rcpp, etc.). This requirement ensures that your package builds are compatible with R itself.
A further complication is the fact that Apple Clang doesn't support OpenMP, so you need to do even more work to compile programs that make use of multithreading. You could circumvent the issue by building R itself, all R packages, and all external libraries from sources with LLVM Clang, which does support OpenMP, but that approach is onerous and "for experts only".
There is another approach that has been tested by a few people, including Simon Urbanek, the maintainer of R for macOS. It is experimental and also "for experts only", but it works on my machine and is much simpler than learning to build R and other libraries yourself.
Instructions for obtaining a working toolchain
Warning: These come with no warranty and could break at any time. Some level of familiarity with C/C++/Fortran program compilation, Makefile syntax, and Unix shells is assumed. Everyone is encouraged to consult official documentation, which is more likely to be maintained than answers on SO. As usual, sudo at your own risk.
I will try to address compilers and OpenMP support at the same time. I am going to assume that you are starting from nothing. Feel free to skip steps you've already taken, though you might find a fresh start helpful.
I've tested these instructions on a machine running Big Sur, but they should also work on Monterey and Ventura.
Download an R 4.2 binary from CRAN here and install. Be sure to select the binary built for Apple silicon.
Run
$ sudo xcode-select --install
in Terminal to install the latest release version of Apple's Command Line Tools for Xcode, which includes Apple Clang. You can obtain earlier versions from your browser here. However, the version that you install should not be older than the one that CRAN used to build your R binary.
Download the GNU Fortran binary provided here and install by unpacking to root:
$ curl -LO https://mac.r-project.org/tools/gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz
$ sudo tar xvf gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz -C /
$ sudo ln -sfn $(xcrun --show-sdk-path) /opt/R/arm64/gfortran/SDK
The last command updates a symlink inside of the installation so that it points to the SDK inside of your Command Line Tools installation.
Download an OpenMP runtime suitable for your Apple Clang version here and install by unpacking to root. You can query your Apple Clang version with clang --version. For example, I have version 1300.0.29.3, so I did:
$ curl -LO https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
$ sudo tar xvf openmp-12.0.1-darwin20-Release.tar.gz -C /
After unpacking, you should find these files on your system:
/usr/local/lib/libomp.dylib
/usr/local/include/ompt.h
/usr/local/include/omp.h
/usr/local/include/omp-tools.h
Add the following lines to $(HOME)/.R/Makevars, creating the file if necessary.
CPPFLAGS += -I/usr/local/include -Xclang -fopenmp
LDFLAGS += -L/usr/local/lib -lomp
Test that you are able to use R to compile a C or C++ program with OpenMP support while linking relevant libraries from the GNU Fortran installation (indicated by the -l flags in the output of R CMD CONFIG FLIBS).
The most transparent approach is to use R CMD SHLIB directly. In a temporary directory, create an empty source file omp_test.c and add the following lines:
#ifdef _OPENMP
# include <omp.h>
#endif
#include <Rinternals.h>
SEXP omp_test(void)
{
#ifdef _OPENMP
Rprintf("OpenMP threads available: %d\n", omp_get_max_threads());
#else
Rprintf("OpenMP not supported\n");
#endif
return R_NilValue;
}
Compile it:
$ R CMD SHLIB omp_test.c $(R CMD CONFIG FLIBS)
Then call the compiled C function from R:
$ R -e 'dyn.load("omp_test.so"); invisible(.Call("omp_test"))'
OpenMP threads available: 8
If the compiler or linker throws an error, or if you find that OpenMP is still not supported, then one of us has made a mistake. Please report any issues.
Note that you can implement the same test using Rcpp, if you don't mind installing it:
library(Rcpp)
registerPlugin("flibs", Rcpp.plugin.maker(libs = "$(FLIBS)"))
sourceCpp(code = '
#ifdef _OPENMP
# include <omp.h>
#endif
#include <Rcpp.h>
// [[Rcpp::plugins(flibs)]]
// [[Rcpp::export]]
void omp_test()
{
#ifdef _OPENMP
Rprintf("OpenMP threads available: %d\\n", omp_get_max_threads());
#else
Rprintf("OpenMP not supported\\n");
#endif
return;
}
')
omp_test()
OpenMP threads available: 8
References
Everything is a bit scattered:
R Installation and Administration manual [link]
Writing R Extensions manual [link]
R for macOS Developers web page [link]
I resolved this issue by adding a path to the homebrew installation of gfortran to my ~/.R/Makevars following these instructions: https://pat-s.me/transitioning-from-x86-to-arm64-on-macos-experiences-of-an-r-user/#gfortran
I just avoided the issue until MacOS had things working more smoothly. so I either Windows Developer Virtual Machine (VM) or run my code development in another environment. I'm not too impressed with the updated and "faster" chipset, but that it doesn't work with much. Slow to implement and work-a-rounds often are a must.
Tested the following process for making multithread data.table work in a M2 MacBook Pro (macOS Monterey)
Steps are mostly the same with this answer by the user inferator.
Download and install R from CRAN
Download and install RStudio with developer tools
Run the following commands in terminal to install OpenMP
curl -O https://mac.r-project.org/openmp/openmp-12.0.1-darwin20-Release.tar.gz
sudo tar fvxz openmp-12.0.1-darwin20-Release.tar.gz -C /
Add compiler flags to connect clan w/ OpenMP. In terminal, write the following:
cd ~
mkdir .R
nano .R/Makevars
Inside the opened Makevars file paste the following lines. Once finished, hit command+O and then Enter to save. Do a command+X to close the editor.
CPPFLAGS += -Xclang -fopenmp
LDFLAGS += -lomp
Download and run the installer for gfortran by downloading gfortran-ARM-12.1-Monterey.dmg from the respective GitHub repo
This concludes the steps regarding enabling OpenMP and (hopefully) Rcpp in R under a M2 chip system.
Now, for testing that everything works with data.table I did the following
Open RStudio and run
install.packages("data.table", type = "source")
If everything is done correctly, the package should compile without any errors and return the following when running getDTthreads(verbose = TRUE):
OpenMP version (_OPENMP) 201811
omp_get_num_procs() 8
R_DATATABLE_NUM_PROCS_PERCENT unset (default 50)
R_DATATABLE_NUM_THREADS unset
R_DATATABLE_THROTTLE unset (default 1024)
omp_get_thread_limit() 2147483647
omp_get_max_threads() 8
OMP_THREAD_LIMIT unset
OMP_NUM_THREADS unset
RestoreAfterFork true
data.table is using 4 threads with throttle==1024. See ?setDTthreads.
[1] 4

Install gcc from source: bash: gcc -v /usr/bin/gcc: Is a directory

I just installed gcc-8.1 from source using those steps:
wget https://ftp.gnu.org/gnu/gcc/gcc-8.1.0/gcc-8.1.0.tar.gz
tar xvf gcc-8.1.0.tar.gz
cd gcc-8.1.0
apt build-dep gcc
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-8.1.0/configure --prefix=/usr/bin/gcc-8.1 --enable-languages=c,c++,fortran,go --disable-multilib
make -j8
make install
Everything is correct?
Then I add it to update-alternatives
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8.1 60 --slave /usr/bin/g++ g++ /usr/bin/g++-8.1
There are 3 choices for the alternative gcc (providing /usr/bin/gcc).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/gcc-7 60 auto mode
1 /usr/bin/gcc-5 60 manual mode
* 2 /usr/bin/gcc-7 60 manual mode
3 /usr/bin/gcc-8.1 60 manual mode
Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/gcc-8.1 to provide /usr/bin/gcc (gcc) in manual mode
update-alternatives: warning: skip creation of /usr/bin/g++ because associated file /usr/bin/g++-8.1 (of link group gcc) doesn't exist
My issue is when I type gcc -v, it said bash: /usr/bin/gcc: Is a directory
--prefix=/usr/bin/gcc-8.1 means that everything that is part of the installation will be placed in the /usr/bin/gcc-8.1/ directory.1
This means that your actual GCC binary is probably located at /usr/bin/gcc-8.1/bin/gcc (or some similarly-named executable, maybe it is actually called gcc-8 or gcc-8.1).
When you set the GCC binary to /usr/bin/gcc-8.1 using update-alternatives, you set the symlink that is normally used to resolve which GCC binary you want to a directory - resulting in the error that you are now getting.
To fix this issue, follow these steps:
Remove the wrong entry in update-alternatives:
update-alternatives --remove gcc /usr/bin/gcc-8.1
Add the right entry.2
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8.1/bin/gcc 60 \
--slave /usr/bin/g++ g++ /usr/bin/gcc-8.1/bin/g++
1 Well, mostly, anyways. Usual prefixes include / (binaries in /bin/), /usr/ (binaries in /usr/bin/) and /usr/local/ (binaries in /usr/local/bin/)
2 I am assuming you want to keep GCC installed at that awkward location. Recompiling and re-installing with --prefix=/opt/gcc-8.1 or something similar would probably be better, just modify the path as needed
This is a double edged sword. I am on windows so don't have the linux jargon. But located my gcc problem in a very wierd way. But maybe this will help someone from hours of digging and trying this and that. But cant say i have not learned a lot in the process.
gcc 10.4 release for windows
and that at least got me to here
Read down to the soundforge link

sclite (SCTK) install, file not recognized, file format not recognized, Cygwin

I am currently trying to install NIST's sclite, which is part of SCTK 2.4.0 (github or current version). I am attempting the install on Cygwin in bash. The installation is done using make.
What I've Done
I made a directory for the install and navigated to that directory
mkdir sctk2.4.0
cd sctk2.4.0
( You'll possibly need $ cd /path/to/dir/sctk2.4.0 .)
I cloned the project from github
git clone https://github.com/chinshr/sctk.git
navigated into the base folder
cd sctk
then I started following the instructions in the INSTALL file.
Running
make config
worked fine, but after typing
make all
I got the output that follows
(mkdir -p bin)
(cd src; make all)
make[1]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src'
(cd asclite; make all)
make[2]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/asclite'
(cd core; make all)
make[3]: Entering directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/asclite/core'
g++ -o asclite -g -Os alignment.o segment.o sgml_reportgenerator.o alignedsegmentiterator.o reportgenerator.o speechset.o segmentsgroup.o logger.o tokenalignment.o sgml_generic_reportgenerator.o recording.o statistics.o compressedlevenshteinmatrix.o segmentor.o id.o trntrn_segmentor.o linestyle_inputparser.o inputparser.o levenshteinmatrix.o levenshtein.o uemfilter.o speakermatch.o spkrautooverlap.o graphalignedsegment.o rawsys_reportgenerator.o graphalignedtoken.o timedobject.o stt_scorer.o aligner.o arraylevenshteinmatrix.o graph.o main.o trn_inputparser.o alignedspeech.o token.o alignedsegment.o graph_coordinate.o rttm_inputparser.o scorer.o properties.o ctmstmrttm_segmentor.o filter.o speech.o alignedspeechiterator.o stm_inputparser.o checker.o ctm_inputparser.o lzma/LzFind.o lzma/LzmaEnc.o lzma/Alloc.o lzma/LzmaLib.o lzma/LzmaDec.o -lm
alignment.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make[3]: *** [makefile:62: asclite] Error 1
make[3]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/asclite/core'
make[2]: *** [makefile:12: all] Error 2
make[2]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src/asclite'
make[2]: *** [makefile:12: all] Error 2
make[2]: Leaving directory '/cygdrive/c/David/programs/sctk2.4.0/sctk/src'
make: *** [makefile:20: all] Error 2
I've looked at this SO post, but I've determined that the alignment.o file is not corrupted. Just in case, I tried a few make clean and even re-cloned the project from github, but I still get the same error.
Can anyone help me complete this installation, or at least get to the next step?
System Details
$ uname -a
CYGWIN_NT-6.1 MyMachine 2.10.0(0.325/5/3) 2018-02-02 15:16 x86_64 Cygwin
$ bash --version
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin) ...
$ gcc --version
gcc (GCC) 6.4.0 ...
$ g++ --version
g++ (GCC) 6.4.0 ...
$ make --version
GNU Make 4.2.1
Built for x86_64-unknown-cygwin ...
$ systeminfo | sed -n 's/^OS\ *//p'
Name: Microsoft Windows 7 Enterprise
Version: 6.1.7601 Service Pack 1 Build 7601
Manufacturer: Microsoft Corporation
Configuration: Member Workstation
Build Type: Multiprocessor Free
Note
I'm asking about this problem and then giving an answer to my own question. (I like that StackOverflow is allowing us to do that.) Hopefully, this will make it easier for people to help me with the problems I ran into further in the installation.
The next problem I ran into is discussed here. You can see this next problem in the answer to this problem.
This is the 'EASIER' solution.
Here are the details on what I called "the kaldi solution". Right now, it's just a list of commands without details. As shown here, these commands will install a sclite-2.4.10 directory under the $HOME (~) directory:
$ cd
$ git clone https://github.com/kaldi-asr/kaldi.git
$ cd kaldi/tools
$ extras/check_dependencies.sh
$ make -j $(nproc --all)
$ cp -R sctk-2.4.10 ~/
$ cd
$ rm -rf kaldi
$ cd sctk-2.4.10/
$ cp $HOME/.bashrc "${HOME}/.bashrc.$(date +%Y%m%d-%H%M%S).bak"
$ echo -e "\n\n## Allow access to sclite, rfilter, etc" >> $HOME/.bashrc
$ echo 'export PATH='"$(pwd)/bin"':$PATH' >> $HOME/.bashrc
$ source ~/.bashrc
See this question/answer for details on how to use it on Windows.
(See my comment under the question for the kaldi solution.)
The solution to this problem was in the README, as solutions often are. Note: There was another problem which came up after this problem was solved. See the bottom of this answer for help with that.
Here is the command I used to get the pertinent info from the README.
cat README | tail -13
and here is the pertinent info
64 bits Compilation
With big alignments, sctk needs to be compiled in 64 bits.
By default, the C/C++ software are compiled in 32 bits with the options (-Os)
but can be compiled in 64 bits, -m64 is added to the CFLAGS variable in:
src/asclite/core/makefile
src/asclite/test/makefile
src/rfilter1/makefile
src/sclite/makefile
Example of CFLAGS:
For OSX 10.4+: -fast -m64 -arch x86_64 -arch ppc64
So, I went to the makefiles listed (except rfilter1, see below) and changed the code there, replacing each -Os with -m64. Do this ONLY for the makefiles that are listed. I'll give an example for one of the listed files, but note you will have to do it for the others.
cd sctk
vim src/asclite/core/makefile
When the file was open, I found the line:
CFLAGS = -g -Os
which I changed to
CFLAGS = -g -m64
(pressed "i" to get into INSERT mode, made the change, pressed "Esc", then pressed ":wq" (Write and Quit) followed by "Enter")
I made the changes in all the listed files EXCEPT src/rfilter1/makefile, because that file had no -Os in it. This ended up being important, as the install wouldn't work if I had changed this file at all.
After this was completed, I ran make clean, but I DID NOT run make config, because this would have undone the changes we just make. I went directly to:
make all
This gets us past where we were before.
This problem was taken care of, but there was another problem:
In file included from main.cpp:20:0:
recording.h:122:36: error: template argument 2 is invalid
map<string, Filter::Filter*> filters;
^
recording.h:122:36: error: template argument 4 is invalid
which I asked about here.
AN EVEN EASIER SOLUTION - Taking advantage of a new, edited version of sclite
This is in case someone finds the answer here useful. I know there are no votes here, but I just got a trophy telling me this is my first question to get 1000 views, so I'll update my answer to show the easiest way to get things done.
TL;DR
https://www.nist.gov/itl/iad/mig/tools
https://github.com/usnistgov/SCTK
% cd /the/dir/where/i/want/to/install
% git clone https://github.com/usnistgov/SCTK.git
% cd SCTK
From the git master README (quoted) with some comments I've put in.
% make config
% sed -i 's#[-]Os#-m64#g' src/asclite/core/makefile
% sed -i 's#[-]Os#-m64#g' src/asclite/test/makefile
% sed -i 's#[-]Os#-m64#g' src/sclite/makefile
% make clean
% ## Possible edit to the `rfilter1 makefile`, which are
% ## described at the end of the answer but were not necessary
% ## for me.
% make all
% make check
% make install
% make doc
I also add the executables' directory to my PATH and make the documentation available via the man command.
% pwd
/the/dir/where/i/want/to/install/SCTK
% # back up your `.bashrc`
% cp $HOME/.bashrc "${HOME}/.bashrc.$(date +%Y%m%d-%H%M%S).bak"
% # persistent path changes
% echo -e "\n\n## Allow access to sclite, rfilter, etc" >> $HOME/.bashrc
% # your machine might use something other than `export` for this. CHECK!
% echo 'export PATH='"$(pwd)/bin"':$PATH' >> $HOME/.bashrc
% # make changes availabel this session
% source ~/.bashrc
% # man stuff
% cd doc
% cp -r ./* /usr/man/man1
END OF THE TL;DR SECTION
Details
Since when I posted this in May 2018, there have finally been some updates made to the software:
I posted my question in May 2018, and the updates were made in Fall 2018. They partly fix the problems I ran into here, but some of the information in the README and some makefiles are useful to note here.
The 32- to 64- bit issue (changing -Os to -m64, as done above) was find-able via the README.
% cat -n README.md | grep -A 4 "64 bits Compilation"
61 **64 bits Compilation**:
62 With big alignments, sctk needs to be compiled in 64 bits. By default, the C/C++ software are compiled in 32 bits with the options (`-Os`) but can be compiled in 64 bits. To do so, `-m64` is added to the CFLAGS variable in `src/asclite/core/makefile`, `src/asclite/test/makefile`, `src/rfilter1/makefile` and `src/sclite/makefile`.
63
64 Example of `CFLAGS` for OSX 10.4+: `-fast -m64 -arch x86_64 -arch ppc64`
65
Here is line 62 with word wrap
With big alignments, sctk needs to be compiled in 64 bits. By default, the C/C++ software are compiled in 32 bits with the options (-Os) but can be compiled in 64 bits. To do so, -m64 is added to the CFLAGS variable in
src/asclite/core/makefile,
src/asclite/test/makefile,
src/rfilter1/makefile and
src/sclite/makefile.
Since there was no -Os in src/rfilter1/makefile, I didn't make any changes.
I was able to finish the installation with no problem (including no failed tests). Here is my system info.
$ uname -a
CYGWIN_NT-10.0 MyMachine 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
$ bash --version | head -n 1
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin)
$ gcc --version | head -n 1
gcc (GCC) 7.4.0
$ g++ --version | head -n 1
g++ (GCC) 7.4.0
$ make --version | head -n 2
GNU Make 4.2.1
Built for x86_64-unknown-cygwin
$ systeminfo | sed -n 's/^OS\ *//p'
Name: Microsoft Windows 10 Enterprise
Version: 10.0.17134 N/A Build 17134
Manufacturer: Microsoft Corporation
Configuration: Member Workstation
Build Type: Multiprocessor Free
However, it seems that some other people trying to compile on Cygwin have had issues. Here is some more info from the README
% grep "Special Note to Cygwin users" README.md
*Special Note to Cygwin users:* it has been reported that compilation of `rfilter1` can fail in some case, please read the OPTIONS part of the `rfilter1/makefile` and adapt accordingly before retrying compilation.
Well, let's look at the makefile for rfilter1, and see what some of you might need to do.
% head -n 15 src/rfilter1/makefile | tail -7
########################### Options for compilation #########################
####### If you have an very new version of GCC, the strcmp* family of functions
####### is included in the distribution. Changing the value of OPTIONS to
####### be blank will diable the use of supplied versions of these functions.
####### In particular, this behavior has been noted on some versions of cygwin
OPTIONS=-DNEED_STRCMP=1 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
So, if you have rfilter1 compilation problems, change the non-commented line to
OPTIONS= $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)

Linking g++ 4.8 to libstdc++

I downloaded and built gcc 4.8.1 on my desktop, running 64-bit Ubuntu 12.04. I built it out of source, like the docs recommend, and with the commands
../../gcc-4.8.1/configure --prefix=$HOME --program-suffix=-4.8
make
make -k check
make install
It seemed to pass all the tests, and I installed everything into my home directory w/ the suffix -4.8 to distinguish from the system gcc, which is version 4.6.3.
Unfortunately when I compile c++ programs using g++-4.8 it links to the system libc and libstdc++ rather than the newer ones compiled from gcc-4.8.1. I downloaded and built gcc 4.8 because I wanted to play around with the new C++11 features in the standard library, so this behaviour is definitely not what I wanted. What can I do to get gcc-4.8 to automatically link to the standard libraries that came with it rather than the system standard libraries?
When you link with your own gcc you need to add an extra run-time linker search path(s) with -Wl,-rpath,$(PREFIX)/lib64 so that at run-time it finds the shared libraries corresponding to your gcc.
I normally create a wrapper named gcc and g++ in the same directory as gcc-4.8 and g++-4.8 which I invoke instead of gcc-4.8 and g++-4.8, as prescribed in Dynamic linker is unable to find GCC libraries:
#!/bin/bash
exec ${0}SUFFIX -Wl,-rpath,PREFIX/lib64 "$#"
When installing SUFFIX and PREFIX should be replaced with what was passed to configure:
cd ${PREFIX}/bin && rm -f gcc g++ c++ gfortran
sed -e 's#PREFIX#${PREFIX}#g' -e 's#SUFFIX#${SUFFIX}#g' gcc-wrapper.sh > ${PREFIX}/bin/gcc
chmod +x ${PREFIX}/bin/gcc
cd ${PREFIX}/bin && ln gcc g++ && ln gcc c++ && ln gcc gfortran
(gcc-wrapper.sh is that bash snippet).
The above solution does not work with some versions of libtool because g++ -Wl,... -v assumes linking mode and fails with an error.
A better solution is to use specs file. Once gcc/g++ is built, invoke the following command to make gcc/g++ add -rpath to the linker command line (replace ${PREFIX}/lib64 as necessary):
g++ -dumpspecs | awk '/^\*link:/ { print; getline; print "-rpath=${PREFIX}/lib64", $0; next } { print }' > $(dirname $(g++ -print-libgcc-file-name))/specs
I just had the same problem when building gcc-4.8.2. I don't have root access on that machine and therefore need to install to my home directory. It took several attempts before I figured out the magic required to get this to work so I will reproduce it here so other people will have an easier time. These are the commands that I used to configure gcc:
prefix=/user/grc/packages
export LDFLAGS=-Wl,-rpath,$prefix/lib
export LD_RUN_PATH=$prefix/lib
export LD_LIBRARY_PATH=$prefix/lib
../../src/gmp-4.3.2/configure --prefix=$prefix
../../src/mpfr-2.4.2/configure --prefix=$prefix
../../src/mpc-0.8.1/configure --prefix=$prefix --with-mpfr=$prefix --with-gmp=$prefix
../../src/gcc-4.8.2/configure --prefix=$prefix --with-mpfr=$prefix --with-gmp=$prefix --with-mpc=$prefix --enable-languages=c,c++
That got me a working binary but any program I built with that version of g++ wouldn't run correctly unless I built it with the -Wl,-rpath,$prefix/lib64 option. It is possible to get g++ to automatically add that option by providing a specs file. If you run
strace g++ 2>&1 | grep specs
you can see which directories it checks for a specs file. In my case it was $prefix/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/specs so I ran g++ -dumpspecs to create a new specs file:
cd $prefix/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
$prefix/bin/g++ -dumpspecs > xx
mv xx specs
and then edited that file to provide the -rpath option. Search for the lines like this:
*link_libgcc:
%D
and edit to add the rpath option:
*link_libgcc:
%D -rpath /user/grc/packages/lib/%M
The %M expands to either ../lib or ../lib64 depending on whether you are building a 32-bit or a 64-bit executable.
Note that when I tried this same trick on an older gcc-4.7 build it didn't work because it didn't expand the %M. For older versions you can remove the %M and just hardcode lib or lib64 but that is only a viable solution if you only ever build 32-bit executables (with lib) or only ever build 64-bit executables (with lib64).
gcc -print-search-dirs will tell you where your compiler is looking for runtime libraries, etc. You can override this with the -B<prefix> option.

eclipse cdt: calling make file from command line and adding version number

two simple questions:
how do i call eclipse cdt generated make file with all the environment variable ? for example, my make file is generated at location PROJECT_FOLDER_ROOT/Debug/makefile , and if i try to call it:
khan#khan-P55A-UD3P:~/git/gcc/libGCC/Debug$ make -k -j5 all
Building file: ../src/utility/Versioning.cpp
Invoking: Cross G++ Compiler
mipsel-openwrt-linux-g++ -I/home/khan/carambola.pristine/staging_dir/target-mipsel_r2_uClibc-0.9.33.2/usr/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/utility/Versioning.d" -MT"src/utility/Versioning.d" -o "src/utility/Versioning.o" "../src/utility/Versioning.cpp"
/bin/sh: 1: mipsel-openwrt-linux-g++: not found
make: * [src/utility/Versioning.o] Error 127
make: Target `all' not remade because of errors.
it is looking for mipsel-openwrt-linux-g++ , which is an environment variable for the eclipse build system . how to include it in the command line usage?
second question:
is there any way to automatically increment build number in CDT ? google search was not helpful in this regard.
right after asking here, it managed to figure out the eclipse makefile issue:
i wrote this script to do it. hope it helps someone:
#!/bin/bash
CURRENT_PATH=$PWD
DEBUG_FOLDER_PATH=$CURRENT_PATH/Debug
TOOLCHAIN_PATH=/home/khan/carambola.pristine/staging_dir/toolchain-mipsel_r2_gcc-4.7-linaro_uClibc-0.9.33.2/bin
cd $DEBUG_FOLDER_PATH
export CWD=$DEBUG_FOLDER_PATH
export PWD=$DEBUG_FOLDER_PATH
export PATH=$TOOLCHAIN_PATH:$PATH
echo $CWD
echo $PWD
echo $PATH
make -k -j5 $1 $2 $3 $4
however, i am still looking for a way to increment build number somehow. any help would be appreciated.
thnkyou