gcc 4.7.1 build ends with undefined reference - c++

I am getting a
fortran/arith.o: In function gfc_mpfr_to_mpz(__mpz_struct*,
__mpfr_struct*, locus*)': arith.c:(.text+0x1169): undefined reference tompfr_get_z_2exp'
from gcc 4.7.1 build process. I am following
gcc-wiki
However, I have made a little change to the
download_prequisites
script. And that is I am downloading the latest releases of all the prequisites for gcc where the original one was downloading a bit older ones since the above link was given for gcc 4.6. However, it can not find some symbols related to mpfr library.
A related google search gives me this thread however it also did not help me, maybe someone else could understand that differently than me:
A similar thread
Any hints on how to resolve this problem?

I recently built gcc 4.7.1 for Mountain Lion and followed a very nice tutorial of how to do a gcc build. In it, it describes all the necessary lib compilations, include mpfr, gmp and others. If you're running linux, I think it will work for you as well, give it a try:
http://solarianprogrammer.com/2012/07/21/compiling-gcc-4-7-1-mac-osx-lion/
Let me know if that helps.

Related

Using SFML for Codeblocks C++ appears ERROR library SFML

I have a problem when I tried to install SFML on Codeblocks. Well, first I install codeblocks: codeblocks-20.03mingw-setup.exe . That's compile correctly after that I download SFML 2.5.1: GCC 5.1.0 TDM (SJLJ) - Code::Blocks - 32-bit.
Following, I extract the SFML file.The problem comes I COPY THE CONTENT OF "BIN" INSIDE OF MY CODEBLOCKS PROJECT. A video helps me to do all of before, I WROTE ALL THE LIBRARIES: GRAPHICS, WINDOW, NETWORK, AUDIO, SYSTEM BUT NOTHING. I show you the error:
cannot find -lsfml-audio-d-2
And continue with network, window,system, graphics
At the ends:
error: ld returned 1 exit status
what's wrong? help me please. I have to make a video game using CODEBLOCKS as soon as I fixed this problem. I'll so thankful for your answers.
On the SFML download website (https://www.sfml-dev.org/download/sfml/2.5.1/), it says:
The compiler versions have to match 100%!
The CodeBlocks 20.03 MinGW installation includes version 8.1.0 of the GCC compiler (as is stated on the download page: http://www.codeblocks.org/downloads/26).
Your downloaded version of SFML thus is only intended to work with version 5.1.0 of GCC, but you have version 8.1.0. This can result in a number of errors.
There are a few possibilities to fix your issue:
You could theoretically compile SFML yourself with your specific compiler, but this option may be quite complicated.
You could use a compiler with the matching version. On the SFML download website, there are some links to the needed compilers. After having installed a compiler, you will have to configure CodeBlocks to detect the new compiler on your system (reference: Adding compiler to code::blocks). Now, in order to add SFML to your project, I would suggest to use this official guide:
https://www.sfml-dev.org/tutorials/2.5/start-cb.php
You could use an environment like MSYS2 (which I use personally) to have a package manager to manage your compiler and libraries installations. This way, your compiler installation and your libraries should work with each other. But in order to use this compiler in CodeBlocks, CodeBlocks would have to be configured.
I would suggest that you refer to option 2 because it probably is the quickest solution.
Feel free to ask if you have any more questions. I know from personal experience that setting up SFML (or any other C++ library) to work with your IDE may be quite tricky.

MinGW-w64's gcc and Address Sanitizer

Installing MinGW-w64 5.1 I find -fsanitize=address is available. It compiles fine, and when it starts linking I get thousands of:
undefined reference to '__asan_report_load1'
undefined reference to '__asan_report_load4'
I googled and found libasan referenced various places, but also comments that when you include -fsanitize=address it automatically includes that library for linking. I searched the MinGW-w64 5.1 install dirctory for "asan" and it was not found anywhere.
What do I need to add on to use address sanitizing features in MinGW-w64? Thank you.
I've looked quickly into release notes for 4.8, 4.9 and 5.1 - ASAN is not available for Windows

Install gcc 4.9 on windows and configure it in Netbeans

Preamble
If anything I wrote is not correct, please be so kind and correct me. I am a php developer mainly - I am not into this compiling stuff. I know there are a lot of topics around the www but they seems to be either old/outdated, very complex or links to a bunch of files on sourceforge (I have no clue what files I should download and what to do with them after downloading them).
Searching a couple of days by now
I am researching for a couple of days by now and tried different compilers and settings but I don't get a standalone executable for a c++14 programme.
First compiler
The first compiler I used was cygwin. I was able to compile it with c++14 but on other computers cygwin had to be installed as well as a cygwin dll was missing. I googled and figured out that programmes compiled using Cygwin requires this dll but cannot be included to the programme itself - or did I missed something?
Current compiler
I then switched to MinGW which seems to be a better choice as it allows to compile standalone executables which is correct as I am able to do so. Well, the MinGW setup I downloaded from http://www.mingw.org/ installed among other the gcc version 4.8.1. I need 4.9.1 for c++14.
As the title says I want to configure it in Netbeans but if there is a proper tutorial for a command line compiling it's no problem either but I try to avoid using another IDE as we use it at work, too.
drangon.org
I also heard about http://www.drangon.org/mingw/ but there are tons of links linking to similiar stuff.
My goals
Get a better understanding about gcc and this compiling stuff in general.
Install gcc 4.9.1 (preferred into MinGW as it's currently installed)
Configure it in Netbeans 8.
I suggest you to try MinGW-w64. (Download.)
It's similar to MinGW, but have better multitreading support, can easily compile x64 applications, and what's more important, at this moment it uses GCC 4.9.2.
By the way, MinGW applications require some .dlls to work too. Usually you just provide these libraries with your application, but another option is to add -static flag at linking phase. Applications that are compiled with it do not require any external library files (unless you're using 3rd party libraries that don't support static linking).

RedHat devtoolset - implications for distributing compiled code

I'm running CentOS 6.4 and need a later version of the C++ compiler to build my development tools (Qt Creator in this case).
I'm unclear on the implications of using devtools and I'm hoping someone can explain.
If I compile programs using devtools, does that means the executable will run on other Centos 6.4 installations without change?
Or..do I know have to ship libraries or other files with my compiled programs?
If so...do I have to modify my C++ code to reference the later libraries? or is this something done by the person installing my compiled program
I hope this somewhat late answer can still help you. What I found is that compiling my project with devtoolset (1.1 in my case, but that should not matter too much) on RHEL 6.4 produces binaries which can almost run on a standard RedHat EL 6.4 (should be similar for Centos 6.4).
The only trouble I ran into was compiling my project with -std=c++11, which produced some problems due to incompatible symbols. The reason is that the GCC folks considered these parts of the standard library to be experimental in GCC 4.4, so they broke ABI compatibility in some places.
Turns out, there's an easy fix: Link your programs with the additional command-line-argument -static-libstdc++. That way, the binary becomes a bit larger but is runs on an unmodified RHEL 6.4 without installing additional libraries/updates for the devtoolset.
To answer your questions explicitly:
Yes, almost.
No.
Don't change the code, just add -static-libstdc++ when linking.

undefined references during link phase using Boost 1.53

I am using g++ 4.1.2 and Boost 1.53 on Red Hat Linux rel 5.5. There is an issue during the linking process which is unclear to me. I get the error msg:
/usr/local/boost_1_53_0/stage/lib/libboost_thread.so:
undefined reference to `std::bad_exception::what() const#GLIBCXX_3.4.9'
/usr/local/boost_1_53_0/stage/lib/libboost_thread.so:
undefined reference to `std::bad_alloc::what() const#GLIBCXX_3.4.9'
collect2: ld returned 1 exit status
There seems to be a problem related to the libstdc++.so file version I'm linking with. If I alternate hiding and revealing this file I can get my program to link. However, I would like to be able to 'make' in one step as I did before I introduced the Boost libraries and concurrent threading.
Please help shed some light on this issue if you have any insight.
Please try to install via yum.
yum install boost
You will not encouter such issues.
Try to include rpmforge and epel yum repositories.
http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning shows that GLIBCXX_3.4.9 is the symbol version used by the libstdc++.so from GCC 4.2.0, so if the Boost library wants that version then it means it was compiled with GCC 4.2.x
That means you can't use the library with a program linked by GCC 4.1.2, you need to link with GCC 4.2.0 or later
libstdc++.so is backward compatible but not forwards compatible, so you can compile a program with one version and link it to a newer version, but you can't compile with a newer version and link to an older version.