Mryqu's Notes


  • 首页

  • 搜索
close

[C] Exec format error

时间: 2013-10-20   |   分类: Tool   C++     |   阅读: 137 字 ~1分钟

很久没用g++了,结果编个小程序还出错。

mryqu:~/ctest$ g++ -g -c wvc.cpp -o wvc
mryqu:~/ctest$ chmod a+x wvc
mryqu:~/ctest$ ./wvc
-bash: ./wvc: cannot execute binary file: Exec format error
mryqu:~/ctest$ file wvc
wvc: ELF 64-bit LSB  relocatable, x86-64, version 1 (SYSV), not stripped

查了查gcc的帮助,才发现用了-c选项后其实是只编译不链接的:

-c
Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o.
Unrecognized input files, not requiring compilation or assembly, are ignored.

去掉-c选项后一切OK!

mryqu:~/ctest$ g++ -g wvc.cpp -o wvc
mryqu:~/ctest$ file wvc
wvc: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=XXXX, not stripped
mryqu:~/ctest$ chmod a+x wvc

标题:[C] Exec format error
作者:mryqu
声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!

#C# #gcc# #-c# #executable# #format#
[Hadoop] hadoop job -list已废弃
批处理:搜索Jar包中的类文件
  • 文章目录
  • 站点概览

Programmer & Architect

662 日志
27 分类
1472 标签
GitHub Twitter FB Page
© 2009 - 2023 Mryqu's Notes
Powered by - Hugo v0.120.4
Theme by - NexT
0%