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!
alexatsearidgeAsked:
Who is Participating?
 
itsmeandnobodyelseConnect With a Mentor Commented:
>>>> 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.
0
 
alexatsearidgeAuthor Commented:
OK,

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 < 2.15.94.0.2-1 conflicts with glibc-devel-2.7-2.i386
        binutils < 2.17.50.0.3-4 conflicts with binutils-devel-2.17.50.0.18-1.i386
        binutils >= 2.17.50.0.17-3 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)

ANY IDEAS?
0
 
itsmeandnobodyelseCommented:
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.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
alexatsearidgeAuthor Commented:
So...you're saying that if I do the following:

include=/usr/local/gcc-4.3.2/include
lib=/usr/local/gcc-4.3.2/lib
export include
export lib

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

I tried that, it didn't work.
0
 
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.
0
 
itsmeandnobodyelseCommented:
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

http://www.brothersoft.com/dimages-126905.html

where you could download version 1.3.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.