2012-09-26 106 views
-19

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

任何帮助,将不胜感激。

+3

你有链接到适当的库? –

+0

你到底是如何编译它的?它看起来像你不链接到jpeglib库 – Alex1985

+0

我只是将它们复制到编译器的include文件夹。是否还有其他我必须做的? – NiVeR

回答

2

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