English 中文(简体)
g++ 试图(未)静态地将共有物体与校正++连接起来
原标题:g++ trying (failing) to link statically to libstdc++ for shared object

I m trying to create a shared object using a number of .O files created with the -fPIC command. When I run g++ with the -shared argument it appears to be trying to statically link to the libstdc++.a library, which of course fails. I m trying to figure out why it s automatically trying to link statically when I m not using the -static-stdc++ argument.

when I try creating the shared object I get the error ...libstdc++.a(ios) relocate R_x86_64_325 against vtable for std::ios_base : cannot be used when making a shared object

I ran G++ with the -V argument and received and can see LD receives the argument -lstdc++.

问题回答

在把单一共有物体连接起来时,你需要从现有的卷宗中这样做。 你无法从现有的档案中做到这一点;这将把这些档案与你档案联系起来,但不会把into你档案。 So gcc寻求并找到一份档案(a),并试图将其链接起来。 但是,由于没有为搬迁(无——fPIC)进行汇编,因此无法使用这些汇编来编制档案。

Your options are:

  • dynamically link your .so to the libstdc++ (and thus make it depending on the .so file that is installed in the system)
  • build .o files for libstdc++ and compile them with -fPIC then compile from those your .so file (here it does not matter if you use the .o files directly or an ar archive)

For the first (that I would recommend) option the following will suffice (it is from a makefile that I use for creating malloc/free intercepting .so files)

gcc -shared -lstdc++ -o your.so yourfiles.o

我不得不首先在图书馆搜索道路上找到静态图书馆,或者在奥尼特找到静态图书馆。 确保共同版本的适当版本得到安装并找到。 页: 1 您的“g++”可以绕开开放图书馆的顺序。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签