【问题标题】:Can't compile this code [duplicate]无法编译此代码 [重复]
【发布时间】:2012-09-26 11:08:50
【问题描述】:

可能重复:
What is an undefined reference/unresolved external symbol error and how do I fix it?

我在编译这段代码时遇到了麻烦http://pastebin.com/a7AMbYPv

这是我得到的错误:

C:\Dev-Cpp\include\main.cpp In function 'int write_jpeg_file(char*)': 
109 25 C:\Dev-Cpp\include\main.cpp [Error] invalid conversion from 'int' to 'J_COLOR_SPACE' [-fpermissive] 
C:\Dev-Cpp\include\main.cpp In function 'int main()': 
130 21 C:\Dev-Cpp\include\main.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings] 
130 48 C:\Dev-Cpp\include\main.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings] 
C:\Users\NIVER\Desktop\Makefile.win [Error] [../../../Dev-Cpp/include/main.o] Error 1 (if this is the only error: please check your library includes) 

任何帮助将不胜感激。

【问题讨论】:

  • 您是否已链接到相应的库?
  • 你是如何编译它的?看起来你没有链接 jpeglib 库
  • 您在链接时遇到问题,而不是在编译时。确保您已将所需的库添加到链接器设置中。
  • -1 我来到这里是期待编译器错误。并且编辑您的问题以包含编译器错误不算在内。

标签: c++ libjpeg


【解决方案1】:

在您的代码中,您引用了未实现它们的函数(jpeg_std_error,...),因此您必须将它们的实现提供给链接器。这通常通过在链接器的输入列表中添加.lib.a 或类似的东西来完成。请查看您从哪里获得示例并获得这些函数的实现(源 C/C++)文件或获得其编译库(形式为 .lib.a)并将它们添加到链接器,并带有指定的标志您的链接器和一切都会按预期工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多