0

I have 2 program I wrote on my windows computer using Visual Studio 2013. They run fine and work perfectly on my computer, but when I brought them over to my school account that is on a Linux machine, a problem arose. They compile and 1 ran, but the other did not. The one that did not run gave me an error:

.../lib/compat/libstdc++.so.6: version CXXABI_1.3.2 required by...

I have been doing research and I can't seem to find out what in my program would be using libstdc++.so.6, I'm not even really sure what it is or does. Since I am on a student account I can't go installing it using sudo, and it is a homework so I can't submit it using my own libraries.

Any Idea on what my program might be using that would require libstdc++.so.6?

I have 3 files: main.cpp, LinkedList.cpp and LinkedList.h.

I think it might be in main.cpp because I think it stems from a library I am including and main.cpp is the only one that uses outside libraries. Here is the list of libraries it uses:

#include <iomanip>
#include <stdio.h>
#include <fstream>
#include <ctype.h>
#include <string>
#include <iostream> 
#include <vector>
#include <sstream>
#include <bitset>
#include <algorithm>
#include "LinkedList.h"

Thanks in advance!

Jwags
  • 474
  • 6
  • 15
  • 1
    You need to recompile it on Linux- then it should work. That library is what implements a good portion of your code. – rholmes Oct 16 '15 at 00:12
  • You say you compile it on linux but the error you are getting tells me that you didn't compile it. Or maybe you thought you compiled it but in reality didn't... – sashang Oct 16 '15 at 00:13
  • add -static to the linker instructions. – user4581301 Oct 16 '15 at 00:13
  • Oh and libstdc++.so [is the C++ standard library](https://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.what). Everything prefixed with std:: in your code is in there. Unless you specified `using namespace std;`, [but no one would be silly enough to do that.](http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) – user4581301 Oct 16 '15 at 00:18
  • I did recompile it on Linux. Could I be compiling it wrong? I am using g++ compiler, versin 4.8.5. I have tried: g++ main.cpp LinkedList.cpp -o output – Jwags Oct 16 '15 at 00:45
  • I also tried: `g++ -c main.cpp -o main.o`, `g++ -c LinkedList.cpp -o LinkedList.o` and `g++ main.o LinkedList.o` The error I keep getting is: `/usr/local/lib/compat/libstdc++.so.6: version CXXABI_1.3.2 required by /home/.../Interpretor/output not found` – Jwags Oct 16 '15 at 00:48
  • Give `g++ -static main.cpp LinkedList.cpp -o output ` a go, but it sounds like the compiler tool chain at school may not be in synch with the installed libraries. – user4581301 Oct 16 '15 at 01:17
  • Maybe try with `-std=c++11` as you compile, this might be enough to make the compiler use the newer library. Although, you are better off talking to the professor or department staff who run the lab, since they are the ones able to actually fix a mismatch. – Ben Voigt Oct 16 '15 at 02:28
  • @user4581301 Your solution worked, but I now have to figure out why my program requires this. I like the solution but think I can change my program to not need static. Once I find the reason it needs static I will add it to my question as the solution. Thanks! – Jwags Oct 16 '15 at 02:54
  • Don't add it to the question. If it's an answer, add it as an answer. – user4581301 Oct 16 '15 at 04:03

3 Answers3

0

You are trying to run a program linked against one version of the libraries under another set. That should work fine as long as the library versions aren't too far apart. In your case, the difference between libraries is just too large.

GCC (C++ in particular) has changed quite a bit lately, some programs that used to compile and run fine now blow up or don't compile at all (due to language changes, compiler bugs accepting broken code, ...), and the library ABI has also changed. Your best bet is to carry source code around, and make sure you got compatible language versions on both ends. If that is inconvenient, a solution is to make sure you have the same compiler (and other environment) at both places. The easiest way to get this is to install the same distribution and version.

vonbrand
  • 11,412
  • 8
  • 32
  • 52
0

First you can't remove the dependencies of libstdc++.so.6, because it's a standard C++ library. To solve your problem you have to check whether your libstdc++.so have the right version

strings /usr/lib64/libstdc++.so.6|grep GXXABI_1.3.1

if there have no matching version, you will have 2 methods like these:

  1. update your gcc on your school's linux OS

    yum intsall gcc

  2. download a matching libstdc++.so from this website: download gcc || download matching libstdc++ then replace the libstdc++.so to /usr/lib64/libstdc++.so.6.*

0

SOLUTION

I went through a few steps to find my solution. Originally I could compile my program but could not run it.

1) My first step to solve the issue was to change my method of compiling. Originally I compiled my program with the following: g++ main.cpp LinkedList.cpp -o output. I changed it to: g++ -static main.cpp LinkedList.cpp -o output which allowed me to compile and run. This worked but static is a method to dynamically link libraries. This prevents linking with the shared libraries. This is not a good solution because it takes a lot longer and increases the file size of the executable, so I wanted to improve.

2) The second thing I did was remove using namespace std. Yes, I cheated and used it. So I went through my program and added std:: to the appropriate places.

3) The last thing I did was clean up my code. I was using a lot of libraries because my program was a large and complicated program. I was using all of the libraries I had listed in my original post. I went through my code and anywhere I was using a function from a library I would try and write my own code that would do the same thing which would result in my program not depending on those libraries. I was able to replicate a decent amount of these dependent foreign functions with my own which added lot of code, but it allowing me to remove some of these includes. My list of includes is now:

#include <fstream>
#include <string>
#include <iostream> 
#include <vector>
#include <algorithm>
#include "LinkedList.h"
#include <math.h>

I am not sure exactly which step resolved my issue, but now I can compile with my preferred method, g++ main.cpp LinkedList.cpp -o output, and my program runs fine.

I hope this helps someone.

Jwags
  • 474
  • 6
  • 15