Check which version of g++ being used - g++

I have both 32 and 64 bit g++ installed on my server and when compiling I want to make sure that I am compiling in 64 bit mode, when I do g++ --version I don't get information about which architecture package I installed, is there a way I can check command line with g++ to see if it is using the 64 bit version.
I need the 32 bit version for other dependencies so its not an option to remove that.

~$ g++ -dumpmachine
x86_64-linux-gnu

Related

Installing recen version of GCC

I am a novice so please bear with me if I ask something that is silly in nature. I wanted to install getfem++ on my Mac for my research and had to compile it from the source as per the instructions given at:
http://download.gna.org/getfem/html/homepage/python/install.html#in-a-general-unix-linux-based-systems
However, when I give the following command:
./configure --enable-python=yes
it gives me the following error:
configure: error: g++ do not support option -std=c++11. Update g++ to at least release 4.8.1.
SO I installed g++ using Homebrew and as per the instructions given by #quine on
https://apple.stackexchange.com/questions/99077/how-to-set-gcc-4-8-as-default-gcc-compiler
I edited the bash profile and added the necessary lines to set alias.
Then I checked the g++ version using g++ -v
and it says 4.8.5 as per the last line. Now when I run the configure command as before, I get the same error. as: configure: error: g++ do not support option -std=c++11. Update g++ to at least release 4.8.1.
Can someone help me by pointing out where I am going wrong? Thank you!!

How to install and use libnet in mac os?

I want to program in C with libnet in Mac OS.
When I type in gcc *.o -o network -lnet, there's an error:
library not found for -lnet.
And when I use homebrew install linnet, is says:
Warning: libnet-1.1.6 already installed.
It is the problem of library PATH.Flow the steps to solve this problem.
First, find where you install the library. For my case, the libnet is located in /usr/local/Cellar/libnet/1.1.6.
Second, run /usr/local/Cellar/libnet/1.1.6/bin/libnet-config.
Third, use -L to add the path when you link.
gcc *.o -L/usr/local/Cellar/libnet/1.1.6/lib -lnet.

How to make GNUstep libobjc2 to work?

I downloaded and built GNUstep libobjc2 1.6.1,
svn co http://svn.gna.org/svn/gnustep/libs/libobjc2/1.6.1/ rep
cd rep
make
and got this error when I tried to compile a Objective-C code.
hoon#ubuntu:~/work/objc2$ clang -fobjc-nonfragile-abi -fobjc-arc -fblocks *.m *.a -l pthread; ./a.out
Objective-C ABI Error: Loading modules from incompatible ABIs while loading
a.out: loader.c:38: __objc_exec_class: Assertion `objc_check_abi_version(module)' failed.
Aborted (core dumped)
It seems I need to build libobjc.a with some different configurations. What is the problem and what should I do to fix this error?
Env: Ubuntu 12.04 LTS
This is a good question because LLVM and CLang and GNUstep don't claim to be hard or complicated to use. They do ask their users to read (and reread) their documentation though. I've just discovered this combination for Ubuntu myself and it is very intriguing. And there are a lot of moving parts at the moment.
If the OP got an answer on one of the gnustep mailing lists, then it would be nice to hear here how it was resolved.
Without suggesting the normal route of starting over and only installing the latest from LLVM and GNUstep directly, here's my take.
The OP is trying to use ARC and blocks with the runtime provided by the gunstep/libobjc2 project.
libobjc2 should probably be built with clang version 3.2 - or maybe the top of tree.
clang -v will tell you what version you have on your machine. I've found even Ubuntu 12.10 doesn't provide clang-3.2. So I download it from the LLVM website. They have prebuilt binaries for Ubuntu 12.04 LTS. To get make to use clang for this build step, I've seen instructions to set and export CC=clang and CXX=clang++.
Once libobjc2 is built, care must be taken where it gets installed. If the system already has an older libobjc.so.x.y library (this provides the runtime environment for Obj-C), clang or the linker may be picking up the wrong one when you start compiling your own source. I found libobjc.so.4.6.0 built from the libobjc2 source was installed to /usr/local/lib both on Ubuntu 12.04 and 12.10 when I ran the make install step. This path was not setup by the libobjc2 install step.
To get this library picked up, I had to add /usr/local/lib to the env variable LD_LIBRARY_PATH. It wouldn't hurt to try 'locate libojbc.so' to see if there are other versions on the system.
Finally, the libobjc2 readme, https://github.com/gnustep/gnustep-libobjc2#readme, says this new version of the gnustep library supports two ABIs, and each ABI supports ARC and blocks. The advice I've seen about compiling with libobjc2 is to also provide the runtime version expected to be compiling and linking with: -fobjc-runtime=gnustep. Clang on Ubuntu still defaults to the older ABI. -fobjc-nonfragile-abi may accomplish the same thing but I've seen it mentioned that flag was or will be deprecated.
The OP error may actually come from the step where a.out is being run, rather than where clang was compiled. Perhaps the dynamic loader is picking up the legacy libobj.so. Again, I would use locate to see if the system even has more than one.
This is just a guess, but I'm gonna go out on a limb and guess that GNUstep is going to build with GCC by default. A good first step might be to reconfigure the GNUstep build to use Clang. I can't say what variety of issues that will expose, but...
Alternately, you could try building your application with GCC instead of Clang.
This is a fairly late answer, but I have found a way to get everything working (on Elementary OS specifically so I imagine it should be fine on Ubuntu and similar distros).
As mentioned, it is better/easier to build everything from source because you get to pick the prefix, build options, etc. The general method:
Install cmake (if it's not already installed) --> sudo apt-get install cmake
Download, build and install llvm and clang as per the instructions here (or see attached build script). For speed, use the --enable-optimized flag. Tests are "optional" ;-)
The default build scripts for compiler-rt do not include the Blocks runtime. You could modify the build scripts, or rejoice that someone else has already done it (particularly if, like me, your cmake isn't great). Download, build and install libBlocksRuntime from this git repo (it is essentially a clone of the latest compiler-rt Blocks runtime code with custom build scripts). FOLLOW THEIR COMPILATION AND TESTING METHOD.
Download, build and install libobjc2 from GNUStep. The instructions for correct building are actually inside the now-deprecated makefile.
Run ldconfig (if required - though there's no harm in running it even if it isn't).
As #WeakPointer you may still need to edit the LD_LIBRARY_PATH environment variable to pick up your new libraries. Another option is to make some quick and dirty symlinks so clang can find your new libraries.
Final note: I haven't done any comparisons between GNUStep's libobjc2 and GCC's libobjc, the latter of which DOES contain some Objective-C 2.0 features... Be careful with your library selection if you keep both on your system at the same time!
The following script should do it all (untested!):
#!/bin/bash
# Temporary base directories
basedir="./clangllvm_temp"
basedir2="./libBlocksRuntime_temp"
basedir3="./libObjc2_temp"
# Clang, llvm, compiler-rt
mkdir $basedir
cd $basedir
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../..
cd llvm/tools/clang/tools
svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
cd ../../../..
cd llvm/projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd ../..
mkdir build
cd build
../llvm/configure --prefix=$PREFIX --enable-optimized
make
sudo make install
cd ../..
# libBlocksRuntime
git clone https://github.com/mackyle/blocksruntime.git $basedir2
cd $basedir2
sudo ./buildlib
sudo ./checktests
sudo ./installlib
# Test!
clang -o sample -fblocks sample.c -lBlocksRuntime && ./sample
cd ..
# libobjc2
https://github.com/gnustep/gnustep-libobjc2.git $basedir3
cd $basedir3
mkdir Build
cd Build
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
sudo make && sudo -E make install
cd ../..
# Cleanup
rm -rf $basedir
rm -rf $basedir2
rm -rf $basedir3
# ldconfig
sudo ldconfig
# Additional symlink/LD_LIBRARY_PATH stuff here if required.
# EOF
Key difference was using Clang for build. Take care not to use GCC which is system default compiler. I removed gobjc and g++ packages from system to avoid this issue.
export CC=clang
export CXX=clang++
svn co http://svn.gna.org/svn/gnustep/libs/libobjc2/1.6.1/
cd 1.6.1
make
This answer was hinted from this mailing list thread:
http://lists.gnu.org/archive/html/discuss-gnustep/2012-12/msg00036.html
Described script is posted here:
http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux
Now it compiles simple ARC code.
It seems GCC and Clang generated codes are incompatible.
Update
I wrote scripts to setup libobjc2 on FreeBSD and CentOS.
The scripts are mostly copied from a blog.

Running boomerang

I am on Ubuntu 8.04 and I have just downloaded Boomerang and unzip the files into a folder on my desktop.
I cd into that folder where the exe boomerang file resides, and typed ./boomerang and boomerang.
However I got the error message:
unable to execute ./boomerang: No such file or directory.
Why does this happen?
I guess, you're on a 64 bit system, which mean you must install some x86 libraries to run the program,
to list the libraries the binary is linked against, run readelf -d | grep NEEDED
once you know the libraries, just install it for x86 architecture: here are some common and necessary libraries for x86
sudo apt-get install libgc1c2:i386 libexpat1-dev:i386 lib32stdc++6 lib32z1 lib32z1-dev
now the program should start normally,
but if it persists, you should see a different kind of error,
try to install those libraries for x86
make sure you have Qt installed for the GUI version.
The error is most likely because you have a 64-bit system, but the boomerang binaries are 32-bit, and many newer 64-bit systems no longer ship with 32-bit support.
The solution is to install 32-bit support for your system; the method for doing this may differ, however the procedure I used was:
sudo apt-get install -y lib32z1 lib32ncurses5 lib32bz2-1.0
Which should be compatible with Ubuntu and many derivatives, though you should look up the correct procedure for your particular OS version, rather than simply running this command.
However, there may also be a number of other 32-bit libraries that are still required before boomerang will run on a 64-bit linux distribution, but at least once you have 32-bit support installed it can tell you what these are!
Are you sure you unpacked it ??
weewee#ubuntu:~/Downloads$ tar xzf boomerang-linux-alpha-0.3.tar.gz
weewee#ubuntu:~/Downloads$ cd boomerang-linux-alpha-0.3/
weewee#ubuntu:~/Downloads/boomerang-linux-alpha-0.3$ ls -l boomerang
-rwxr-xr-x 1 weewee weewee 2376620 Jun 13 2006 boomerang
weewee#ubuntu:~/Downloads/boomerang-linux-alpha-0.3$ ./boomerang
Boomerang alpha 0.3 13/June/2006
Usage: boomerang [ switches ] <program>
boomerang -h for switch help

Cross compile mono for arm

Has anyone successfully cross-compiled mono for ARM under Linux without scratchbox or qemu?
(maybe with distcc or some cross-compiler toolchain)
I managed to cross compile mono(2.0, 2.4, 2.6, 2.8, 2.10.1) with Scratchbox 2 installed on a Ubuntu machine using CodeSourcery Lite tool chain. I used the article from the Mono project page.
First compile it on the native machine
./configure
$ make
$ make install DESTDIR=path
Then in sb2:
[sbox-ARMEL: ~] > ./configure --disable-mcs-build
[sbox-ARMEL: ~] > make
[sbox-ARMEL: ~] > make install DESTDIR=path
I use this for configuration
./configure --enable-minimal=profiler,debug,logging,soft_debug --with-tls=--with-tls=__thread --with-monotouch=no --without-mcs-docs --disable-mono-debugger CFLAGS=-DARM_FPU_NONE --disable-mcs-build
I tried and tried and tried with scratchbox2 last night.. Ran into some problem.. Ended up just compiling on arm, went fine! took 30 minutes!
CFLAGS=-DARM_FPU_VFP_HARD HardFloat
CFLAGS=-DARM_FPU_VFP_NONE SoftFloat
Compile mono on PC
sudo make install `directory like /tmptree etc`
move all these files from /tmptree over to / etc on your arm device.
./autogen.sh --disable-mcs-build
make CFLAGS=-DARM_FPU_VFP_HARD
sudo make install
sudo ldconfig
Mono Hard Float Patch
Tried doing Hard Float with mono 3.0.3.. it said it didn't support it yet.