Littlecms - 编译时出错 "undefined reference to `cmsOpenProfileFromFile' "
Littlecms - error during compiling "undefined reference to `cmsOpenProfileFromFile' "
请帮助我使用 LittleCMS 框架 - 我收到了
“对 cmsOpenProfileFromFile 的未定义引用”
我做了:
1) 从 https://github.com/mm2/Little-CMS 文件下载 lcms2.h
2) 下载 https://sourceforge.net/projects/lcms/and 尝试像文档中写的那样安装它(下载 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' 的未定义引用”。
我想我必须安装一些库(而且我必须将类似 -L/opt/local/lib64 -llcms2 添加到 makefile 或将其添加到 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) ).
我是编程新手,所以请居高临下。
请帮我解决并实现Little 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 (有 clang):
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) 生成文件 2:
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,将 -L/usr/local/lib -llcms2
添加到 Makefile 并且我的程序编译没有错误。
请帮助我使用 LittleCMS 框架 - 我收到了 “对 cmsOpenProfileFromFile 的未定义引用”
我做了:
1) 从 https://github.com/mm2/Little-CMS 文件下载 lcms2.h
2) 下载 https://sourceforge.net/projects/lcms/and 尝试像文档中写的那样安装它(下载 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' 的未定义引用”。
我想我必须安装一些库(而且我必须将类似 -L/opt/local/lib64 -llcms2 添加到 makefile 或将其添加到 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) ).
我是编程新手,所以请居高临下。 请帮我解决并实现Little 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 (有 clang):
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) 生成文件 2:
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,将 -L/usr/local/lib -llcms2
添加到 Makefile 并且我的程序编译没有错误。