Littlecms - 编译期间出错"未定义对`cmsOpenProfileFromFile'的引用"

时间:2017-11-09 21:22:20

标签: c cs50

请帮我使用LittleCMS框架 - 我收到了 "未定义引用`cmsOpenProfileFromFile' "

我做过:

1)从https://github.com/mm2/Little-CMS文件lcms2.h下载

2)已下载的https://sourceforge.net/projects/lcms/and尝试按照文档中的说明安装它(下载的tar文件,unTARed it,runned

./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;
    }

跑步后#34;制作"我收到了"未定义引用`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))。

我是编程方面的新手,所以请高瞻远瞩。 请帮我解决并实施Little CMS。

更新: 3种类型的汇编:

1)命令提示符(内部IDE&#39的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)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

1 个答案:

答案 0 :(得分:0)

解决方案是使用其他IDE - CS50 IDE不允许安装其他库。我安装了VirtualBox,安装了xubuntu,安装了lib,将-L/usr/local/lib -llcms2添加到Makefile中,我的程序编译没有错误。

相关问题