我是一个新手C & C++,我迫切需要帮助。我想重新使用已由供应商编码的功能。为此,供应商给我提供了.H
文件& .lib
文件。供应商代码是使用Visual C语言开发的,我尝试在Visual C++ 6中访问这些.lib文件。编译成功。链接时出错。采取的步骤:链接问题C/C++
- 我已链接项目设置下的所有
.lib
文件。
我仍然得到以下错误消息:
pricing_w32.obj:错误LNK2001:解析外部符号
_open_item_info_files
调试/ pricing_w32.exe:致命错误LNK1120:1周无法解析的外部 错误执行链接。可执行程序。
下面是代码,我曾写入:
#include<stdio.h>
#include<string.h>
#include<fstream>
#include<conio.h>
#include<stdlib.h>
#include<iostream>
#include <windows.h>
extern "C"
{
#include<cma_telx.h>
}
using namespace std;
int process_file(char **in_file);
extern "C"
{
void lkup_item_info(void *item);
int open_item_info_files(int *err);
int close_item_info_files(int *err);
int open_item_promo_files(int *err);
int close_item_promo_files(int *err);
void lkup_rtn_csp_db(void *itemCspWDB);
void lkup_rtn_promos_csp_db(void *itemPrmCspWDB);
int do_empdisc_lookup(struct EMPDISC_RECORD *edisc, int *err);
int do_empauth_lookup(struct EMPLOYEE_AUTH_REC *eauth, int *err);
void return_all_promos(struct ALL_PRMINFO_BASE &all_promos);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
char UPC[7];
void *SKU;
cout<<"Normal end"<<endl;
int return_code, *err;
return_code = open_item_info_files(err);
cout<<return_code<<"open item return code"<<endl;
cout<<return_code<<"Close item return code"<<endl;
return 0;
}
cma_telx.h包含以下函数原型:
int open_item_info_files(int *err);
下面是命令的片段:DUMPBIN /符号cma_telx。 lib
076 00000000 SECT1D notype()External | ?open_item_info_files @@ YAHPAH @ Z(int __cdecl open_item_info_files(int *)) 标记索引00000083大小00000121行00007129下一个函数0000008E 078 00000000 SECT1E notype静态| .data 段长度9,#relocs 0,#linenums 0,校验和145249B4,选择2(挑选任何) 07A 00000000 SECT1E notype外部| ?_ C @ _08OOCA @ PMSDPTCL?$ AA @(string') 07B 00000000 SECT1F notype Static | .data Section length 7, #relocs 0, #linenums 0, checksum 7F8A6B53, selection 2 (pick any) 07D 00000000 SECT1F notype External | [email protected][email protected][email protected] (
string') 07E 00000000 SECT20 notype静态| .data 段长度7,#relocs 0,#linenums 0,校验和F397CDFF,选择2(挑选任何) 080 00000000 SECT20 notype外部| _ _ @ @ 06OHCH @ KPXREF $ AA @(`string') 081 00000000 UNDEF notype()External | _ imp _FileManager 082 00000000 UNDEF notype()External | __chkstk
错误显示你编译时不喜欢那些库文件 – gongzhitaao
@gongzhitaao,* link *,你的意思是? – Raptor
你确定库中有一个叫做'open_item_info_files'的函数吗?你的拼写/大小写/标点完全正确吗?你可以看看这个问题http://stackoverflow.com/questions/305287/how-to-see-the-contents-of-windows-library-lib它可以帮助你“窥视”图书馆。要么你没有连接正确,要么你要求的东西不在那里。这将帮助您缩小搜索范围。 – Floris