GCC创建一个共享对象而不是可执行二进制文件 [英] GCC creates a shared object instead of an executable binary
问题描述
ar rcs lib / libryftts.a $ ^
gcc -shared $ ^ -o lib / libryftts.so
在我的Makefile中。我也能够成功地将它们安装到 / usr / local / lib
当我使用nm测试文件时,所有函数都在那里。
我的问题是,当我运行 gcc testing / test.c -lryftts -o test&&文件./test
或 gcc testing / test.c lib / libryftts.a -o test&&文件./test
它说:
test:ELF 64位LSB共享对象 code>而不是
test:ELF 64位LSB可执行文件
,如我所料。我做错了什么?
我做错了什么?
无。
听起来像您的GCC被配置为构建 - 馅饼
默认情况下为二进制文件。这些二进制文件实际上是共享库(类型为 ET_DYN
),除非它们像普通可执行文件那样运行。
所以你应该运行你的二进制文件,(如果它有效的话)不用担心它。
或者你可以将你的二进制文件与 gcc -no-pie ...
并且应该产生一个非< ET_EXEC
文件
会说 ELF 64位LSB可执行文件
。
I have a library I am building. All of my objects compile and link successively when I run either one of:
ar rcs lib/libryftts.a $^
gcc -shared $^ -o lib/libryftts.so
in my Makefile. I also am able to successfully install them into /usr/local/lib
When I test the file with nm, all the functions are there.
My problem is that when I run gcc testing/test.c -lryftts -o test && file ./test
or gcc testing/test.c lib/libryftts.a -o test && file ./test
it says:
test: ELF 64-bit LSB shared object
instead of test: ELF 64-bit LSB executable
as I would expect. What am I doing wrong?
What am I doing wrong?
Nothing.
It sounds like your GCC is configured to build -pie
binaries by default. These binaries really are shared libraries (of type ET_DYN
), except they run just like a normal executable would.
So your should just run your binary, and (if it works) not worry about it.
Or you could link your binary with gcc -no-pie ...
and that should produce a non-PIE
executable of type ET_EXEC
, for which file
will say ELF 64-bit LSB executable
.
这篇关于GCC创建一个共享对象而不是可执行二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!