[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1384
  • Last Modified:

Problems compiling/linking with two GCC versions installed.

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/libstdc++.so.6: 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!
  • 3
  • 3
1 Solution
alexatsearidgeAuthor Commented:

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/libstdc++.so.6: version `CXXABI_1.3.1' not found (required by dimages)
dimages: /usr/local/gcc-3.4.1/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by dimages)

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.
alexatsearidgeAuthor Commented:
So...you'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.
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

>>>> 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.
alexatsearidgeAuthor Commented:
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.
Sorry for not reading your follow-up question thoroughly and thanks for accepting my answer nevertheless ...

>>>> dimages: /usr/local/gcc-3.4.1/lib/libstdc++.so.6: 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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now