首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >进行未定义的错误引用

进行未定义的错误引用
EN

Stack Overflow用户
提问于 2015-09-29 08:56:40
回答 1查看 2K关注 0票数 0

我正在使用一个无头图像,并在GNU bash中编译这个简单的代码。我收到这些链接错误

代码语言:javascript
复制
#include <IL/il.h>   
#include <IL/ilu.h> 
#include <IL/ilut.h>   
#include <stdio.h>   
#include <stdlib.h>   
#include <string.h>   

int main(int argc, char **argv)   
{     
    ILuint  ImgId;

 // Initialize DevIL.   
    ilInit();   

    // Generate the main image name to use.   
    ilGenImages(1, &ImgId);   

    // Bind this image name.   
    ilBindImage(ImgId);   

    // Loads the image specified by File into the image named by ImgId.   
    if (!ilLoadImage(argv[1])) {   
        printf("Could not open file...exiting.\n");   
        return 3;   
    }   

    // Display the image's dimensions to the end user.   
    printf("Width: %d  Height: %d  Depth: %d  Bpp: %d\n",   
           ilGetInteger(IL_IMAGE_WIDTH),   
           ilGetInteger(IL_IMAGE_HEIGHT),   
           ilGetInteger(IL_IMAGE_DEPTH),   
           ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL));   

    return 0;
}
代码语言:javascript
复制
root@parallella:/home/parallella/parallella-examples/lena# make display
cc     display.c   -o display
/tmp/ccSqb23j.o: In function `main':
display.c:(.text+0xa): undefined reference to `ilInit'
display.c:(.text+0x16): undefined reference to `ilGenImages'
display.c:(.text+0x1e): undefined reference to `ilBindImage'
display.c:(.text+0x2a): undefined reference to `ilLoadImage'
display.c:(.text+0x48): undefined reference to `ilGetInteger'
display.c:(.text+0x52): undefined reference to `ilGetInteger'
display.c:(.text+0x5c): undefined reference to `ilGetInteger'
display.c:(.text+0x66): undefined reference to `ilGetInteger'
collect2: error: ld returned 1 exit status
make: *** [display] Error 1

我怎样才能解决链接器的问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-29 09:04:30

在哪里定义了ilInitilGenImages等?也就是说-哪个源文件/预编译库保存它们?您需要将该信息提供给cc。

假设这些文件是在名为foo.c的源文件中定义的,则解决方案如下:

cc display.c foo.c -o display

在进一步的详细信息中,当编译器对您的函数(在头文件中)有正确的声明时,这个错误会上升,但是没有找到任何定义(创建该二进制文件的实际二进制或源)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32839829

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档