Solved

Problems compiling/linking with two GCC versions installed.

Posted on 2008-10-07
6
1,289 Views
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/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!
0
Comment
Question by:alexatsearidge
  • 3
  • 3
6 Comments
 

Author Comment

by:alexatsearidge
ID: 22662563
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
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
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.
0
 

Author Comment

by:alexatsearidge
ID: 22688176
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 39

Accepted Solution

by:
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.
0
 

Author Comment

by:alexatsearidge
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.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
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/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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now