Problems compiling/linking with two GCC versions installed.

Posted on 2008-10-07
Last Modified: 2013-12-06
I've dug myself into a hole.

I have compiled and installed GCC from source, two versions (3.1.4 and 4.3.2). I have used the -prefix=/usr/local/gcc-3.1.4 and -prefix=/usr/local/gcc-4.3.2 for both. I have added a sym link from /usr/local/bin/g++ to /usr/local/gcc-3.4.1/bin/g++.

I am compiling a C++ project using NetBeans. When it compiles, I get the following errors multiple times:

/usr/local/lib/libpqxx.a(connection_base.o): In function `operator<< <std::char_traits<char> >':
/usr/local/lib/gcc/i686-pc-linux-gnu/4.3.2/../../../../include/c++/4.3.2/ostream:517: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'

I have no idea why it is referencing the include files in 4.3.2. I don't know exactly how gcc or NetBeans works with all the standard c++ libraries. I'm also using libpq and libpqxx libraries to do DB stuff.

* Fedora Core 8.
* NetBeans 6.1.
* GCC 3.4.1 and 4.3.2.
* GNU Make 3.8.1.

A long time ago (a few weeks ago) before I started fidgeting with gcc, I used to just compile and build c++ code with the gcc compiler that was installed with Fedora, and it worked fine. Somewhere along the line I started using libpqxx code that wasn't compiling correctly, so I update gcc for that.

Then I was able to build and run the code with the newer compiler, but when I ran it I would get the following error:

dimages: /usr/lib/ version `GLIBCXX_3.4.9' not found (required by dimages)

..."dimages" being the name of my program. So I read a few posts that gave me the idea to try to use an older compiler. This is where I am now stuck.

Thanks in advance!
Question by:alexatsearidge
  • 3
  • 3

Author Comment

ID: 22662563

A bit of a change here. I fixed the problem by removing a "-L../../gcc-3.4.1/lib". Cleaning up the linker options seems to have done the trick. Also note that version 3.1.4 should be 3.4.1 (I have the latter, not what I had mentioned above).

After having done that I seemed to get even worse linker errors, however.

`.gnu.linkonce.t._ZNK12cimg_library4CImgIhE10get_resizeEiiiij' referenced in section `.rodata' of build/Debug/GNU-Linux-x86/src/DAWC_ImageManager.o: defined in discarded section `.gnu.linkonce.t._ZNK12cimg_library4CImgIhE10get_resizeEiiiij' of build/Debug/GNU-Linux-x86/src/DAWC_ImageManager.o

Another net search suggested I downgrade binutils. In attempting to do that I was warned of failed dependancies:

        binutils < conflicts with glibc-devel-2.7-2.i386
        binutils < conflicts with binutils-devel-
        binutils >= is needed by (installed) gcc-4.1.2-33.i386

So I figure'd I try using the newer gcc again and see how far that gets me. So now I'm stuck using gcc-4.3.2, compiling and linking just fine, but when I run I get:

dimages: /usr/local/gcc-3.4.1/lib/ version `CXXABI_1.3.1' not found (required by dimages)
dimages: /usr/local/gcc-3.4.1/lib/ version `GLIBCXX_3.4.9' not found (required by dimages)

LVL 39

Expert Comment

ID: 22667569
You need to check the environment variables 'include' and 'lib' which should point to the folders of the appropriate version. Normally, the latest installation will overwrite these settings.

Author Comment

ID: 22688176're saying that if I do the following:

export include
export lib

and then recompile and run, I won't get the errors anymore?

I tried that, it didn't work.
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

LVL 39

Accepted Solution

itsmeandnobodyelse earned 500 total points
ID: 22697534
>>>> tried that, it didn't work.
>>>> I have no idea why it is referencing the include files in 4.3.2.
if you set the environment to 4.3.2, you may not wonder why the compiler establishes a reference ...

Note, the include and lib is only one possibility why it may not work. Check, the makefile and the sources whether none of them explicitly includes or sets definitions for the wrong environment.

Generally, it is not a good idea when building at the command line to have more than one compiler version active beside you have good expertise in both the operation system and the compiler.

Author Comment

ID: 22733762
I'll give you the answer since technically you answered my original question. Note that in my follow-up post above I stated that I did indeed get rid of the original error messages by removing a faulty linker option.

I modified my question in the follow-up post to get help on the GLIBCXX errors being thrown after running the application. I have so far been unable to solve this problem.

I have, however, been able to build and use another older version of gcc without getting those errors (version 4.0.0). But I still don't know why I'm getting those errors in 4.3.2, and how I can solve them. I would be interested in finding that solution. But since I've found a way to work around it, I'm closing this question.
LVL 39

Expert Comment

ID: 22734107
Sorry for not reading your follow-up question thoroughly and thanks for accepting my answer nevertheless ...

>>>> dimages: /usr/local/gcc-3.4.1/lib/ version `CXXABI_1.3.1' not found (required by dimages)

It seems to be a library for screensaver. I found that link

where you could download version 1.3.

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question