[英]The main function of bpgview.c is not compiled by gcc
BPG is a digital image format that is more compression-efficent than jpeg. BPG是一种数字图像格式,比jpeg压缩效率更高。 I wanted to compile libbpg-0.9.6 on OS X 10.10.5 (14F1509). 我想收集关于OS X 10.10.5(14F1509)libbpg-0.9.6。 My Xcode version is 7.2.1 (7C1002). 我的Xcode版本是7.2.1 (7C1002)。
$gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents
/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix
I have all the necessary libraries( see: github.com/mirrorer/libbpg) installed. 我已经安装了所有必需的库(请参阅:github.com/mirrorer/libbpg)。 When I run make I have the following error: 当我运行make时,出现以下错误:
gcc -Os -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT -I. -DCONFIG_BPG_VERSION=\"0.9.6\" -g -I./x265/source -I./x265.out/8bit -c -o x265_glue.o x265_glue.c
g++ -g -Wl,-dead_strip -o bpgenc bpgenc.o x265_glue.o x265.out/8bit/libx265.a x265.out/10bit/libx265.a x265.out/12bit/libx265.a -lpng -ljpeg -lm -lpthread
gcc -Os -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT -I. -DCONFIG_BPG_VERSION=\"0.9.6\" -g -c -o bpgview.o bpgview.c
gcc -g -Wl,-dead_strip -o bpgview bpgview.o libbpg.a -lSDL_image -lSDL -lm -lpthread
ld: entry point (_main) undefined. for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bpgview] Error 1
I did check the symbols in bpgview.o. 我确实检查了bpgview.o中的符号。 Not only didn't int main show up but also the static void help and static void set_caption in bpgview.c . 不仅没有显示int main ,而且还显示了bpgview.c中的static void help和static void set_caption 。
$nm bpgview.o
U _IMG_Load
U _SDL_AddTimer
U _SDL_CreateRGBSurface
U _SDL_EnableKeyRepeat
U _SDL_FillRect
U _SDL_Flip
U _SDL_FreeSurface
U _SDL_GetVideoInfo
U _SDL_Init
U _SDL_LockSurface
U _SDL_MapRGB
U _SDL_PushEvent
U _SDL_RemoveTimer
U _SDL_SetVideoMode
U _SDL_UnlockSurface
U _SDL_UpperBlit
U _SDL_WM_SetCaption
U _SDL_WaitEvent
00000000000006f6 T _SDL_main
U ___snprintf_chk
U ___stack_chk_fail
U ___stack_chk_guard
U ___stderrp
U _bpg_decoder_close
U _bpg_decoder_decode
U _bpg_decoder_get_frame_duration
U _bpg_decoder_get_info
U _bpg_decoder_get_info_from_buf
U _bpg_decoder_get_line
U _bpg_decoder_open
U _bpg_decoder_start
0000000000000000 T _bpg_load
0000000000000404 T _center_image
0000000000000465 T _draw_image
U _exit
U _fclose
U _fopen
U _fprintf
U _fread
U _free
U _fseek
U _ftell
U _fwrite
U _getopt
000000000000021f T _load_image
U _malloc
0000000000000c64 t _open_window
U _optind
000000000000069a T _pan_image
U _printf
U _realloc
00000000000003c6 t _restart_frame_timer
0000000000000cbc t _timer_cb
The complete make output is on pastebin. 完整的make输出在pastebin上。
I find it very strange but there may be some gcc options I don't know about that let the compiler ignore functions. 我觉得这很奇怪,但是可能有些我不知道的gcc选项会让编译器忽略函数。 Thank you for your time. 感谢您的时间。
I figured out that -e _SDL_main
solved the issue of the missing entry point. 我发现-e _SDL_main
解决了缺少入口点的问题。 This seems strange at first but it turned out the compiler used this symbol for jet unknown reasons instead of _main
. 乍一看似乎很奇怪,但事实证明编译器出于喷射未知的原因而不是_main
使用此符号。
The disassembled object-file is proof as is the working binary: ( https://ptpb.pw/6kev.png ) 反汇编的目标文件和工作的二进制文件都是证明:( https://ptpb.pw/6kev.png )
The missing _help and _set_caption came from the -Os
option which optimizes size. 缺少的_help和_set_caption来自优化大小的-Os
选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.