gpt4 book ai didi

c++ - GCC 建立链接问题

转载 作者:行者123 更新时间:2023-11-30 05:34:50 29 4
gpt4 key购买 nike

我正在尝试在 HTR-toolsUtils 上执行 make我面临以下问题:

gcc -g -Wall -lm  -I./include -o pgmmedian pgmmedian.c libpgm.o
Undefined symbols for architecture x86_64:
"_CALC_MEDIAN", referenced from:
_main in pgmmedian-7918de.o
"_MERGE_SLICE", referenced from:
_main in pgmmedian-7918de.o
"_SORT_SLICE", referenced from:
_main in pgmmedian-7918de.o
"_pgm_getuint", referenced from:
_pgm_readpgminitrest in libpgm.o
_pgm_readpgmrow in libpgm.o
"_pgm_writepgmrowplain", referenced from:
_pgm_writepgmrow in libpgm.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [pgmmedian] Error 1

生成文件:

#
# CONFIGURABLE OPTIONS
#

#CC = cc
CC = gcc

#CFLAGS = -O3 -I.
CFLAGS = -g
WFLAGS = -Wall
LDFLAGS = -lm
#LDFLAGS = -s

BINARIESDIR = $(HOME)/bin
SCRIPTSDIR = $(HOME)/scripts
EXAMPLESDIR = $(HOME)/CATTI-Examples

...

我在 OSX El Captain 上运行。我阅读了一些建议使用 g++ 而不是 gcc 运行的问题,但没有运气

使用 gcc -lstdc++ 我得到同样的错误,使用 g++(通过在 Makefile 中更改它们)我得到:

clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
pgmskew.c:24:10: fatal error: 'values.h' file not found
#include <values.h>
^
1 error generated.
make: *** [pgmskew] Error 1

➜ gcc -v

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix

有什么建议吗?提前致谢 。

最佳答案

您缺少一些定义这些符号的库。您需要找出 libpgm.o 需要什么库并链接到它。

关于c++ - GCC 建立链接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34063989/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com