请帮助我使用LittleCMS框架-我收到"对`cmsOpenProfileFromFile'的未定义引用">
我做了:
1) 下载自https://github.com/mm2/Little-CMS文件lcms2.h
2) 已下载https://sourceforge.net/projects/lcms/and试着像文档中写的那样安装它(下载了tar文件,取消了tar,运行了
./configure
make
sudo make install
3) 尝试实现教程中的示例:
#include "lcms2.h"
int main(void)
{
cmsHPROFILE hInProfile, hOutProfile;
cmsHTRANSFORM hTransform;
hInProfile = cmsOpenProfileFromFile("AdobeRGB1998.icc", "r");
hOutProfile = cmsOpenProfileFromFile("WebCoatedSWOP2006Grade5.icc", "r");
hTransform = cmsCreateTransform(hInProfile, TYPE_BGR_8, hOutProfile, TYPE_BGR_8, INTENT_PERCEPTUAL, 0);
cmsCloseProfile(hInProfile);
cmsCloseProfile(hOutProfile);
return 0;
}
在运行"make"之后,我收到了"对`cmsOpenProfileFromFile'的未定义引用"。
我想我必须安装一些库(我必须在makefile中添加类似的东西——L/opt/local/lib64-llcms2,或者将其添加到clang…),但我已经阅读了数千字节的网页,没有人告诉我如何从头开始——库不会出现在/opt/local/lib64或/opt/local/lib文件夹中(我在任何目录中都找不到lcms2)。
我的IDE是:CS50 IDE,Linux版本4.9.17-c9(root@30db80bfe262)(gcc版本4.9.2(Debian 4.9.2-10))。
我对编程很陌生,所以请屈尊俯就。请帮我解决和实现小CMS。
更新:3种类型的汇编:
1) 命令提示符(内部IDE的makefile,没有我的makefile):
~/workspace/cmyk/ $ make cmyk
clang -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow -c -o cmyk.o cmyk.c
clang cmyk.o -lcrypt -lcs50 -lm -o cmyk
cmyk.o: In function `main':
/home/ubuntu/workspace/cmyk/cmyk.c:9: undefined reference to `cmsOpenProfileFromFile'
/home/ubuntu/workspace/cmyk/cmyk.c:10: undefined reference to `cmsOpenProfileFromFile'
/home/ubuntu/workspace/cmyk/cmyk.c:12: undefined reference to `__ubsan_handle_shift_out_of_bounds'
/home/ubuntu/workspace/cmyk/cmyk.c:12: undefined reference to `__ubsan_handle_shift_out_of_bounds'
/home/ubuntu/workspace/cmyk/cmyk.c:12: undefined reference to `__ubsan_handle_shift_out_of_bounds'
/home/ubuntu/workspace/cmyk/cmyk.c:12: undefined reference to `__ubsan_handle_shift_out_of_bounds'
/home/ubuntu/workspace/cmyk/cmyk.c:12: undefined reference to `__ubsan_handle_shift_out_of_bounds'
cmyk.o:/home/ubuntu/workspace/cmyk/cmyk.c:12: more undefined references to `__ubsan_handle_shift_out_of_bounds' follow
cmyk.o: In function `main':
/home/ubuntu/workspace/cmyk/cmyk.c:12: undefined reference to `cmsCreateTransform'
/home/ubuntu/workspace/cmyk/cmyk.c:14: undefined reference to `cmsCloseProfile'
/home/ubuntu/workspace/cmyk/cmyk.c:15: undefined reference to `cmsCloseProfile'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [cmyk] Error 1
2) Makefile1(带有叮当声):
CC = clang
CFLAGS = -ggdb3 -O0 -Qunused-arguments -std=c99 -Wall -Werror
EXE = cmyk
HDRS = lcms2.h
LIBS =
SRCS = cmyk.c
OBJS = $(SRCS:.c=.o)
$(EXE): $(OBJS) $(HDRS) Makefile
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
$(OBJS): $(HDRS) Makefile
clean:
rm -f core $(EXE) *.o
输出:
~/workspace/cmyk/ $ make cmyk
clang -ggdb3 -O0 -Qunused-arguments -std=c99 -Wall -Werror -c -o cmyk.o cmyk.c
clang -ggdb3 -O0 -Qunused-arguments -std=c99 -Wall -Werror -o cmyk cmyk.o
cmyk.o: In function `main':
/home/ubuntu/workspace/cmyk/cmyk.c:9: undefined reference to `cmsOpenProfileFromFile'
/home/ubuntu/workspace/cmyk/cmyk.c:10: undefined reference to `cmsOpenProfileFromFile'
/home/ubuntu/workspace/cmyk/cmyk.c:12: undefined reference to `cmsCreateTransform'
/home/ubuntu/workspace/cmyk/cmyk.c:14: undefined reference to `cmsCloseProfile'
/home/ubuntu/workspace/cmyk/cmyk.c:15: undefined reference to `cmsCloseProfile'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [cmyk] Error 1
3) Makefile2:
iEdit: cmyk.o
gcc $^ -o $@ -std=c99
.c.o:
gcc -c $< -std=c99
cmyk.o: lcms2.h
输出:
~/workspace/cmyk/ $ make cmyk
gcc -c cmyk.c -std=c99
clang cmyk.o -lcrypt -lcs50 -lm -o cmyk
cmyk.o: In function `main':
cmyk.c:(.text+0x13): undefined reference to `cmsOpenProfileFromFile'
cmyk.c:(.text+0x26): undefined reference to `cmsOpenProfileFromFile'
cmyk.c:(.text+0x50): undefined reference to `cmsCreateTransform'
cmyk.c:(.text+0x60): undefined reference to `cmsCloseProfile'
cmyk.c:(.text+0x6c): undefined reference to `cmsCloseProfile'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [cmyk] Error 1
解决方案是使用其他IDE-CS50 IDE不允许安装额外的库。我安装了VirtualBox,安装了xubuntu,安装了lib,在Makefile中添加了-L/usr/local/lib -llcms2
,我的程序编译得没有错误。