视觉工作室2008快递中的错误LNK2019 [英] error LNK2019 in visual studio 2008 express
问题描述
我刚刚开始尝试使用vs2008 express在c ++中创建自己的函数库。
我知道这对专家来说可能是一个简单的问题在那里,但我从一个简单的测试示例开始,看看我是否可以管理。
我已将包含和库文件的路径放入ide编译器。
任何有关我做错的建议都将受到赞赏。提前致谢
如果这有帮助我已经包含了代码:(由于某种原因,提交的问题省略了#include< iostream>)
这是错误信息:
1> functest.obj:错误LNK2019:未解析的外部符号int __cdecl twicenum(int)(?twicenum @@ YAHH函数_main引用@Z
1> C:\ Users \ Bill \ Document'\\Visual Studio 2008 \New folder\testfunclib \Debug \ testfunclib.exe:致命错误LNK1120:1个未解析的外部代码
main(1),header(2)和函数定义(3)模块的代码如下:
.................................................. ..............................................(1)。 ..
// main prg叫做testfunclib
..........
#include< iostream>
#includemyfunclib.h
使用命名空间std;
int main()
{
int b =两次num(4);
cout<< b;
}
.....( 2)................................................ ....................................
头文件myfunclib.h < br $>
// ...命名空间,变量和函数原型到这里
/ *您必须在您想要在图书馆中使用的原型功能之前放置extern * /
extern int twicenum(int);
(3)............................................... ..............................................
函数定义twicenum.cpp
#includemyfunclib.h
#include< iostream>
使用命名空间std;
int twicenum(int x);
{
int res;
res = x * 2;
cout<< res;
return(res);
}
............................ .................................................. ..........
I have just started to try to create my own library of functions in c++, using vs2008 express.
I know this is probably a simple problem to the experts out there but I started with a simple test example to see if I could manage.
I have put the paths to my include and library files into the ide compiler.
Any advice on what I have done wrong will be appreciated. Thanks in advance
I have included the code if this helps: (For some reason the submitted question has omitted #include <iostream>)
This is the error message:
1>functest.obj : error LNK2019: unresolved external symbol "int __cdecl twicenum(int)" (?twicenum@@YAHH@Z) referenced in function _main
1>C:\Users\Bill\Documents\Visual Studio 2008\New folder\testfunclib\Debug\testfunclib.exe : fatal error LNK1120: 1 unresolved externals
code for main (1), header (2) and function definition (3) modules follows:
................................................................................................(1)...
//main prg is called testfunclib
..........
#include <iostream>
#include "myfunclib.h"
using namespace std;
int main()
{
int b=twicenum(4);
cout<<b;
}
.....(2)....................................................................................
Header File myfunclib.h
//… Namespaces, variables, and function prototypes go here
/*You have to put extern before your prototyped function you want to use in your library*/
extern int twicenum(int);
(3).............................................................................................
function definition twicenum.cpp
#include "myfunclib.h"
#include <iostream>
using namespace std;
int twicenum(int x);
{
int res;
res=x*2;
cout<<res;
return (res);
}
........................................................................................
推荐答案
我遇到过同样的问题。这可能会有所帮助:
在编译用C编写的Win32项目时,我遇到了链接器问题。 [ ^ ]
I had the same problem once. This might help :
I have a linker problem when compiling my Win32 project written in C.[^]
这篇关于视觉工作室2008快递中的错误LNK2019的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!