请问下面的编译错误怎么要解决?

xsquan78 2003-08-20 10:58:08
我在http://www.3dmirc.com/apron/tutorials/gl/gl_3ds_loader.zip
下载了一个读取3ds文件的程序,他是用api函数的,我想用mfc ,我建立了一个单文档后,先添加了一个cjpegfile 这个类,内容照抄例子的,但是编译这个cjpegfile.CPP的时候出现下面的
错误如下:
cjpegfile.obj : error LNK2001: unresolved external symbol "unsigned char __cdecl jpeg_finish_decompress(struct jpeg_decompress_struct *)" (?jpeg_finish_decompress@@YAEPAUjpeg_decompress_struct@@@Z)
cjpegfile.obj : error LNK2001: unresolved external symbol "unsigned int __cdecl jpeg_read_scanlines(struct jpeg_decompress_struct *,unsigned char * *,unsigned int)" (?jpeg_read_scanlines@@YAIPAUjpeg_decompress_struct@@PAPAEI@Z)
cjpegfile.obj : error LNK2001: unresolved external symbol "unsigned char __cdecl jpeg_start_decompress(struct jpeg_decompress_struct *)" (?jpeg_start_decompress@@YAEPAUjpeg_decompress_struct@@@Z)
cjpegfile.obj : error LNK2001: unresolved external symbol "int __cdecl jpeg_read_header(struct jpeg_decompress_struct *,unsigned char)" (?jpeg_read_header@@YAHPAUjpeg_decompress_struct@@E@Z)
cjpegfile.obj : error LNK2001: unresolved external symbol "void __cdecl jpeg_stdio_src(struct jpeg_decompress_struct *,struct _iobuf *)" (?jpeg_stdio_src@@YAXPAUjpeg_decompress_struct@@PAU_iobuf@@@Z)
cjpegfile.obj : error LNK2001: unresolved external symbol "void __cdecl jpeg_CreateDecompress(struct jpeg_decompress_struct *,int,unsigned int)" (?jpeg_CreateDecompress@@YAXPAUjpeg_decompress_struct@@HI@Z)
cjpegfile.obj : error LNK2001: unresolved external symbol "void __cdecl jpeg_destroy_decompress(struct jpeg_decompress_struct *)" (?jpeg_destroy_decompress@@YAXPAUjpeg_decompress_struct@@@Z)
cjpegfile.obj : error LNK2001: unresolved external symbol "struct jpeg_error_mgr * __cdecl jpeg_std_error(struct jpeg_error_mgr *)" (?jpeg_std_error@@YAPAUjpeg_error_mgr@@PAU1@@Z)
Debug/text_3ds.exe : fatal error LNK1120: 8 unresolved externals
Error executing link.exe.

其中 CJPEGFile.CPP
#include "CJPEGFile.h"
#include "data\include\define.h"
#include <stdio.h>
#include <setjmp.h>
#include "data\include\jpeglib.h"

我查了msdn里面好像有这样的解析
EXPORTS definitions

This statement makes one or more definitions available as exports to other programs.

EXPORTS marks the beginning of a list of export definitions. Each definition must be on a separate line. The EXPORTS keyword can be on the same line as the first definition or on a preceding line. The .DEF file can contain one or more EXPORTS statements.

The syntax for an export definition is:

entryname[=internalname] [@ordinal[NONAME]] [DATA] [PRIVATE]

The optional keyword PRIVATE prevents entryname from being placed in the import library generated by LINK. It has no effect on the export in the image also generated by LINK.

There are three methods for exporting a definition, listed in recommended order of use:

The __declspec(dllexport) keyword in the source code


An EXPORTS statement in a .DEF file


An /EXPORT specification in a LINK command
All three methods can be used in the same program. When LINK builds a program that contains exports, it also creates an import library, unless an .EXP file is used in the build.
请问这个问题怎么样解决?谢谢?
...全文
71 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xsquan78 2003-08-21
  • 打赏
  • 举报
回复
多谢你们的回答,我添加了#pragma comment( lib, ".\\data\lib\\jpeg.lib" )
但出现下面的错误,
libc.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)
libc.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)
libc.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
libc.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
libc.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
libc.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in libc.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
msvcrtd.lib(cinitexe.obj) : warning LNK4098: defaultlib "libc.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
libc.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/text_3ds.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

text_3ds.exe - 9 error(s), 2 warning(s)
还请帮助!
xiaolizi 2003-08-20
  • 打赏
  • 举报
回复
To xsquan78(人人)
在data\lib目录下有一个jpeg.lib,把这个文件加入到你的工程中,在cjpegfile 这个类的*.cpp文件头加入#pragma comment( lib, ".\\data\lib\\jpeg.lib" )
这样应该就没问题了。
xsquan78 2003-08-20
  • 打赏
  • 举报
回复
我在下载的文件里面都没有找到这2 个文件,但是例子的程序是可以运行的
BlueSky2008 2003-08-20
  • 打赏
  • 举报
回复
你去找找,应该有个jpeglib.lib文件,把它加入到编译器的link选项下。
要是没有,就找jpeglib.c,把它编译一下。

8,303

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧