[英]gcc: Find directory of libstdc++
I am writing a C library which needs to statically link with a library written in C++.我正在编写一个 C 库,它需要与用 C++ 编写的库静态链接。 I can specify the location of libstdc++.a
explicitly (since I am linking statically):我可以明确指定libstdc++.a
的位置(因为我是静态链接):
gcc main.c /some/library.a /usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.a
I found the location for libstdc++.a
by using the following:我使用以下命令找到了libstdc++.a
的位置:
$ g++ --print-file-name=libstdc++.a
/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.a
This is good and all, except for the fact that it uses g++
to find it.这很好,除了它使用g++
来找到它。 If I do the following with gcc
instead:如果我改为使用gcc
执行以下操作:
$ gcc --print-file-name=libstdc++.a
libstdc++.a
It cannot find it.它找不到它。 Am I missing something?我错过了什么吗? Is gcc
capable of doing this, or do I have to use g++
? gcc
能够做到这一点,还是我必须使用g++
?
STL (another name of the library), is native to C++. STL(库的另一个名称),原生于 C++。 It is written in C++.它是用 C++ 编写的。 So, gcc does not have any built in support for STL.因此,gcc 没有对 STL 的任何内置支持。 g++ support for STL is built in. g++ 支持 STL 是内置的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.