无法编译此代码

时间:2012-09-26 11:08:51

标签: c++ libjpeg

  

可能重复:
  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) 

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:2)

在您的代码中,您引用了未实现它们的函数(jpeg_std_error,...),因此您必须向链接器提供它们的实现。这通常是通过向链接器的输入列表中添加.lib.a或类似内容来完成的。请查看获取示例的位置并获取这些函数(源C / C ++)文件的实现或获取其编译库(格式为.lib.a)并将其添加到链接器中为链接器指定的标志,每个东西都将按预期工作