Why are my G++ shared libraries incompatible after switching to Opensuse 12.3?

  • Thread starter PPeter
  • Start date
  • Tags
    Issues
In summary: On a PC, you would typically have a few static libraries and a lot of dynamic libraries. When you run an executable that uses a static library, the library is copied into memory and the executable can use it without having to load it again. If you run an executable that uses a dynamic library, the library is not copied into memory and the executable needs to find the library each time it is needed.
  • #1
PPeter
3
1
Before I switched to Opensuse 12.3, I was running Arch, and doing something like:
Code:
g++ -o test -I ./include/ -L ./lib/ -ltcod -ltcodxx ./src/main.cpp
with no problems occurring.

Now, when I try to do that (with everything kept the exact same as when on Arch), I get:
Code:
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: skipping incompatible lib/libtcod.so when searching for -ltcod
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: cannot find -ltcod
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: skipping incompatible lib/libtcodxx.so when searching for -ltcodxx
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld: cannot find -ltcodxx

I also tried including -Wl,-rpath=./lib/ , but it still made no difference.

Any help as to why the libraries have become incompatible all of a sudden would be greatly appreciated.
 
Technology news on Phys.org
  • #3
Also, is there the possibility of an issue of static vs dynamic libraries? I seem to remember a problem along those lines when. at the office, I got switched from Red Hat 4 to Red Hat 5.
 
  • #5
I guess.

By the way, the error message posted does not quite say that the library was not found, it says that what was found is not compatible...whatever that means...different compiler? different size (32 vs 64)? different something? Sorry, I am no expert on these matters.
 
  • #6
The term "shared libraries" may refer to libraries that are either static OR dynamic. Static libraries are compiled right into your executable, whereas dynamic libraries are linked at runtime.
 

Related to Why are my G++ shared libraries incompatible after switching to Opensuse 12.3?

1. What is a shared library in G++?

A shared library in G++ is a collection of pre-compiled code that can be linked to a program at runtime. It contains functions, variables, and other resources that can be accessed by multiple programs, reducing the need for duplicate code and improving efficiency.

2. How do I create a shared library in G++?

To create a shared library in G++, you need to compile your code with the -shared flag and specify the -fPIC option to generate position-independent code. You also need to use the -soname flag to set the shared library's name and version number.

3. How do I link a program to a shared library in G++?

To link a program to a shared library in G++, you need to use the -l flag followed by the name of the shared library. You also need to specify the path to the shared library using the -L flag if it is not in the default search path.

4. What are some common issues with G++ shared libraries?

Some common issues with G++ shared libraries include incorrect compilation flags, missing dependencies, and conflicting versions of the shared library. These can lead to runtime errors or failure to link the program to the shared library.

5. How can I troubleshoot G++ shared library issues?

To troubleshoot G++ shared library issues, you can use tools such as ldd and objdump to check for missing dependencies and conflicting versions. You can also use the -Wl,--verbose flag to get more information about the linking process and any errors that occur.

Similar threads

Replies
18
Views
7K
Back
Top