w****h 发帖数: 212 | 1 如果程序报错:
error LNK2001: unresolved external symbol "public: static int HeapSort::
heap_size" (?heap_size@HeapSort@@2HA)
如何解决?
以前遇到这个问题,似乎是开始不应该选择console application,应该用empty
project。当时重建empty project就解决了。
但现在再次遇到,在VC 2008 express edition,代码文件很多,不知道如何设置?难
道要重新建一个empty project吗?
多谢。 |
|
a******6 发帖数: 78 | 2 一个简单的程序,不知道哪里出了问题,请各位大虾指点一下:
谢谢
#include
#include
#include
#include
int main()
{
double a[3];
int i;
GetRNGstate();
for(i=0;i<=3;i++)
{
a[i]=rnorm(0.0,1.0);
printf("a[%2d]=%f \n",i,a[i]);
}
PutRNGstate();
}
错误如下:
Linking...
test.obj : error LNK2001: unresolved external symbol _PutRNGstate
test.obj : error LNK2001: unresolved external symbol _Rf_rnorm
test.obj : error LNK2001: unresolved external symbol _GetRNGsta |
|
b***y 发帖数: 2799 | 3 ☆─────────────────────────────────────☆
wmbyhh (wmbyhh) 于 (Sun Jun 29 23:05:45 2008) 提到:
报错: error LNK2001: unresolved external symbol "public: static int
HeapSort::heap_size" (?heap_size@HeapSort@@2HA)
error LNK2001: unresolved external symbol "public: static int * HeapSort::heap" (?heap@HeapSort@@2PAHA)
----------------------
class HeapSort
{
public:
static int heap_size;
static int heap[MAX_HEAP]; //define an array of the heap
public:
HeapSort(void);
static void AddNu |
|
b*******y 发帖数: 1240 | 4 debug和release的编译都通过
但都是运行不了
Debug有LNK2001的warning
release底下有200多个warning,大部分是type转换的warning,没LNK的 |
|
m*****k 发帖数: 731 | 5 我现在使用的是oracle8i,WINDOWS 2000。想用PRO*C连接ORACLE数据库。PRO*C程序预编
译通过,但是联编出现问题。
在VC中编译出错,如下:
Linking...
proj1Dlg.obj : error LNK2001: unresolved external symbol "void __cdecl
sqlcxt(void * *,unsigned long *,struct sqlexd *,struct sqlcxp const *)"
(?sqlcxt@@YAXPAPAXPAKPAUsqlexd@@PBUsqlcxp@@@Z)
Debug/proj1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
proj1.exe - 2 error(s), 0 warning(s)
不知问题出在那,请指教 |
|
b*********n 发帖数: 1258 | 6 这几句是我刚才写的,修改了一下
char* fileName="abcdefg";
int len=strlen(fileName);
LinearSuffixSort(fileName,len);
还是不行,VC 6下,compile通过(no error),build的时候
=======================
error LNK2001: unresolved external symbol "int * __cdecl LinearSuffixSort(ch
ar * &,int &)" (?LinearSuffixSort@@YAPAHAAPADAAH@Z)
fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
=======================
谢谢
the |
|
i**p 发帖数: 902 | 7 Just found VC++ does not support this function.
error LNK2001: unresolved external symbol _strlongth |
|
p***o 发帖数: 1252 | 8 这跟你的 error LNK2001: unresolved external symbol _strlongth
有啥关系?
include
as |
|
K*****n 发帖数: 65 | 9 Can you do a search in all cpp of your project for
"int HeapSort::heap_size"?
static class data member gets no memory allocated, you need to define one
like global variables.
say
int HeapSort::heap_size = 100; //initialization is optional |
|
w****h 发帖数: 212 | 10 我开始在头文件里定义的是static int heap_size;
为什么不能定义static? |
|
K*****n 发帖数: 65 | 11 I know you define
static int heap_size;
in your class HeapSort in header file.
static class member is shared by all its class objects, so it gets no room
in objects. That's why you need make ANOTHER GLOBAL define in
your cpp file.
int HeapSort::heap_size = 100; //initialization is optional |
|
K*****n 发帖数: 65 | 12 Here is a quote from http://www.cprogramming.com/tutorial/statickeyword.html
An important detail to keep in mind when debugging or implementing a program
using a static class member is that you cannot initialize the static class
member inside of the class. In fact, if you decide to put your code in a
header file, you cannot even initialize the static variable inside of the
header file; do it in a .cpp file instead. Moreover, you are required to
initialize the static class member or it will not b |
|
|
j*****j 发帖数: 115 | 14 class A
{
static int a;
public:
static ini(int b)
{
a=b;
}
};
int main()
{
A a1;
a1.ini(3);
}
报错:
const error LNK2001: unresolved external symbol "private: static int A::a" (
?a@A@@0HA)
谢谢 |
|
s*******e 发帖数: 664 | 15 ☆─────────────────────────────────────☆
Ramboiory (暗黑八神庵) 于 (Tue Jun 23 17:25:14 2009, 美东) 提到:
[问题1]
代码如下:
class Weather
{
public:
static void (Weather::*m_fpAction)();
void StayIn();
void StayOut();
};
void (Weather::*m_fpAction)() = &Weather::StayIn; //初始化
报错如下:
Linking...
1>class.obj : error LNK2001: unresolved external symbol "public: void __
thiscall Weather::StayIn(void)" (?StayIn@Weather@@QAEXXZ)
1>D:\Documents\Study\Research_in_UIUC\Projects\Wireless Scheduling\VC_
Pro |
|
h**********c 发帖数: 4120 | 16 Just jumped a similar error of a project of my own:
LINK : debug\qtwagon2012.exe not found or not built by the last incremental
link; performing full link
Creating library debug\qtwagon2012.lib and object debug\qtwagon2012.exp
glwidget.obj : error LNK2019: unresolved external symbol "public: static
class qtLight * __cdecl qtLightSingleton::getInstance(void)" (?getInstance@
qtLightSingleton@@SAPAVqtLight@@XZ) referenced in fu
nction "public: void __thiscall GLWidget::slotLight3dMoveOrders(int,... 阅读全帖 |
|