RSS Forums RSS

LNK2001 and LNK2019 problem!

Please support our C++ advertiser: Programming Forums
Reply
Posts: 2
Reputation: padawan is an unknown quantity at this point 
Solved Threads: 0
padawan padawan is offline Offline
Newbie Poster

LNK2001 and LNK2019 problem!

  #1  
Oct 12th, 2008
Hi everyone,

I have a problem with debugging a dll file. I'm trying to convert the epanet2.dll (EPANET: a free source-coded water resource program) into a 64-bit dll file for my project. When compiling, errors coding LNK2001 and LNK2019 occurred many times.

error LNK2001: unresolved external symbol ...
error LNK2001: unresolved external symbol ...

Here is some of the "error" including code:
File : vars.h ** (One of the header files)
  1. #pragma once
  2.  
  3. #include "stdafx.h"
  4.  
  5. extern FILE *InFile, /* Input file pointer */
  6. *OutFile, /* Output file pointer */
  7. *RptFile, /* Report file pointer */
  8. *HydFile, /* Hydraulics file pointer */
  9. *TmpOutFile; /* Temporary file handle */
  10. extern long HydOffset, /* Hydraulics file byte offset */
  11. OutOffset1, /* 1st output file byte offset */
  12. OutOffset2; /* 2nd output file byte offset */
  13. extern char Msg[MAXMSG+1], /* Text of output message */
  14. InpFname[MAXFNAME+1], /* Input file name */
  15. Rpt1Fname[MAXFNAME+1], /* Primary report file name */
  16. Rpt2Fname[MAXFNAME+1], /* Secondary report file name */
  17. HydFname[MAXFNAME+1], /* Hydraulics file name */
  18. OutFname[MAXFNAME+1], /* Binary output file name */
  19. MapFname[MAXFNAME+1], /* Map file name */
  20. Title[MAXTITLE][MAXMSG+1], /* Problem title */
  21. ChemName[MAXID+1], /* Name of chemical */
  22. ChemUnits[MAXID+1], /* Units of chemical */
  23. DefPatID[MAXID+1], /* Default demand pattern ID */
  24. Atime[13], /* Clock time (hrs:min:sec) */
  25. Hydflag, /* Hydraulics flag */
  26. Qualflag, /* Water quality flag */
  27. Unitsflag, /* Unit system flag */
  28. Flowflag, /* Flow units flag */
  29. Pressflag, /* Pressure units flag */
  30. Formflag, /* Hydraulic formula flag */
  31. Rptflag, /* Report flag */
  32. Summaryflag, /* Report summary flag */
  33. Messageflag, /* Error/warning message flag */
  34. Statflag, /* Status report flag */
  35. Energyflag, /* Energy report flag */
  36. Nodeflag, /* Node report flag */
  37. Linkflag, /* Link report flag */
  38. Tstatflag, /* Time statistics flag */
  39. Warnflag, /* Warning flag */
  40. Openflag, /* Input processed flag */
  41. OpenHflag, /* Hydraul. system opened flag */
  42. SaveHflag, /* Hydraul. results saved flag */
  43. OpenQflag, /* Quality system opened flag */
  44. SaveQflag, /* Quality results saved flag */
  45. Saveflag; /* General purpose save flag */
  46. extern int MaxNodes, /* Node count from input file */
  47. MaxLinks, /* Link count from input file */
  48. MaxJuncs, /* Junction count */
  49. MaxPipes, /* Pipe count */
  50. MaxTanks, /* Tank count */
  51. MaxPumps, /* Pump count */
  52. MaxValves, /* Valve count */
  53. MaxControls, /* Control count */
  54. MaxRules, /* Rule count */
  55. MaxPats, /* Pattern count */
  56. MaxCurves, /* Curve count */
  57. Nnodes, /* Number of network nodes */
  58. Ntanks, /* Number of tanks */
  59. Njuncs, /* Number of junction nodes */
  60. Nlinks, /* Number of network links */
  61. Npipes, /* Number of pipes */
  62. Npumps, /* Number of pumps */
  63. Nvalves, /* Number of valves */
  64. Ncontrols, /* Number of simple controls */
  65. Nrules, /* Number of control rules */
  66. Npats, /* Number of time patterns */
  67. Ncurves, /* Number of data curves */
  68. Nperiods, /* Number of reporting periods */
  69. Ncoeffs, /* Number of non-0 matrix coeffs*/
  70. DefPat, /* Default demand pattern */
  71. Epat, /* Energy cost time pattern */
  72. MaxIter, /* Max. hydraulic trials */
  73. ExtraIter, /* Extra hydraulic trials */
  74. TraceNode, /* Source node for flow tracing */
  75. PageSize, /* Lines/page in output report */
  76. CheckFreq, /* Hydraulics solver parameter */
  77. MaxCheck; /* Hydraulics solver parameter */
  78. extern double Ucf[MAXVAR], /* Unit conversion factors */
  79. Ctol, /* Water quality tolerance */
  80. Htol, /* Hydraulic head tolerance */
  81. Qtol, /* Flow rate tolerance */
  82. RQtol, /* Flow resistance tolerance */
  83. Hexp, /* Exponent in headloss formula */
  84. Qexp, /* Exponent in orifice formula */
  85. Dmult, /* Demand multiplier */
  86. Hacc, /* Hydraulics solution accuracy */
  87. BulkOrder, /* Bulk flow reaction order */
  88. WallOrder, /* Pipe wall reaction order */
  89. TankOrder, /* Tank reaction order */
  90. Kbulk, /* Global bulk reaction coeff. */
  91. Kwall, /* Global wall reaction coeff. */
  92. Climit, /* Limiting potential quality */
  93. Rfactor, /* Roughness-reaction factor */
  94. Diffus, /* Diffusivity (sq ft/sec) */
  95. Viscos, /* Kin. viscosity (sq ft/sec) */
  96. SpGrav, /* Specific gravity */
  97. Ecost, /* Base energy cost per kwh */
  98. Dcost, /* Energy demand charge/kw/day */
  99. Epump, /* Global pump efficiency */
  100. Emax, /* Peak energy usage */
  101. Dsystem, /* Total system demand */
  102. Wbulk, /* Avg. bulk reaction rate */
  103. Wwall, /* Avg. wall reaction rate */
  104. Wtank, /* Avg. tank reaction rate */
  105. Wsource; /* Avg. mass inflow */
  106. extern long Tstart, /* Starting time of day (sec) */
  107. Hstep, /* Nominal hyd. time step (sec) */
  108. Qstep, /* Quality time step (sec) */
  109. Pstep, /* Time pattern time step (sec) */
  110. Pstart, /* Starting pattern time (sec) */
  111. Rstep, /* Reporting time step (sec) */
  112. Rstart, /* Time when reporting starts */
  113. Rtime, /* Next reporting time */
  114. Htime, /* Current hyd. time (sec) */
  115. Qtime, /* Current quality time (sec) */
  116. Hydstep, /* Actual hydraulic time step */
  117. Rulestep, /* Rule evaluation time step */
  118. Dur; /* Duration of simulation (sec) */
  119. extern SField Field[MAXVAR]; /* Output reporting fields */
  120. extern char *S; /* Link status */
  121. extern char *OldStat; /* Previous link/tank status */
  122. extern double *D, /* Node actual demand */
  123. *C, /* Node actual quality */
  124. *E, /* Emitter flows */
  125. *K, /* Link settings */
  126. *Q, /* Link flows */
  127. *R, /* Pipe reaction rate */
  128. *X; /* General purpose array */
  129. extern double *H; /* Node heads */
  130. extern STmplist *Patlist; /* Temporary time pattern list */
  131. extern STmplist *Curvelist; /* Temporary list of curves */
  132. extern Spattern *Pattern; /* Time patterns */
  133. extern Scurve *Curve; /* Curve data */
  134. extern Snode *Node; /* Node data */
  135. extern Slink *Link; /* Link data */
  136. extern Stank *Tank; /* Tank data */
  137. extern Spump *Pump; /* Pump data */
  138. extern Svalve *Valve; /* Valve data */
  139. extern Scontrol *Control; /* Control data */
  140.  
  141.  
  142. typedef struct HTentry *HTtable;
  143.  
  144. HTtable *HTcreate(void);
  145. int HTinsert(HTtable *, char *, int);
  146. int HTfind(HTtable *, char *);
  147. char *HTfindKey(HTtable *, char *);
  148. void HTfree(HTtable *);
  149.  
  150. extern HTtable *Nht, *Lht; /* Hash tables for ID labels */
  151. extern Padjlist *Adjlist; /* Node adjacency lists */
  152. extern double *Aii, /* Diagonal coeffs. of A */
  153. *Aij, /* Non-zero, off-diagonal coeffs. of A */
  154. *F; /* Right hand side coeffs. */
  155. extern double *P, /* Inverse headloss derivatives */
  156. *Y; /* Flow correction factors */
  157. extern int *Order, /* Node-to-row of A */
  158. *Row, /* Row-to-node of A */
  159. *Ndx; /* Index of link's coeff. in Aij */
  160. /*
  161. ** The following arrays store the positions of the non-zero coeffs.
  162. ** of the lower triangular portion of A whose values are stored in Aij:
  163. */
  164. extern int *XLNZ, /* Start position of each column in NZSUB */
  165. *NZSUB, /* Row index of each coeff. in each column */
  166. *LNZ; /* Position of each coeff. in Aij array */
  167.  
  168.  
  169.  
  170. File : smatrix.c
  171.  
  172. #include <stdio.h>
  173. #include <string.h>
  174. #include <malloc.h>
  175. #include <math.h>
  176. #include "stdafx.h"
  177. #include "hash.h"
  178. #include "text.h"
  179. #include "types.h"
  180. #include "funcs.h"
  181. #include "vars.h"
  182. #define EXTERN extern
  183.  
  184. int *Degree; /* Number of links adjacent to each node */
  185.  
  186.  
  187. int createsparse()
  188. {
  189. int errcode = 0;
  190.  
  191. /* Allocate data structures */
  192. ERRCODE(allocsparse());
  193. if (errcode) return(errcode);
  194. Degree = (int *) calloc(Nnodes+1, sizeof(int));
  195. ERRCODE(MEMCHECK(Degree));
  196. ERRCODE(buildlists(TRUE));
  197. if (!errcode)
  198. {
  199. xparalinks(); /* Remove parallel links */
  200. countdegree(); /* Find degree of each junction */
  201. } /* (= # of adjacent links) */
  202.  
  203. Ncoeffs = Nlinks;
  204. ERRCODE(reordernodes());
  205.  
  206. ERRCODE(storesparse(Njuncs));
  207. if (!errcode) freelists();
  208. ERRCODE(ordersparse(Njuncs));
  209.  
  210. ERRCODE(buildlists(FALSE));
  211.  
  212. free(Degree);
  213. return(errcode);
  214. }
  215.  
  216. int allocsparse()
  217. {
  218. int errcode = 0;
  219. Adjlist = (Padjlist *) calloc(Nnodes+1, sizeof(Padjlist));
  220. Order = (int *) calloc(Nnodes+1, sizeof(int));
  221. Row = (int *) calloc(Nnodes+1, sizeof(int));
  222. Ndx = (int *) calloc(Nlinks+1, sizeof(int));
  223. ERRCODE(MEMCHECK(Adjlist));
  224. ERRCODE(MEMCHECK(Order));
  225. ERRCODE(MEMCHECK(Row));
  226. ERRCODE(MEMCHECK(Ndx));
  227. return(errcode);
  228. }
  229.  
  230.  
  231. void freesparse()
  232. {
  233. freelists();
  234. free(Adjlist);
  235. free(Order);
  236. free(Row);
  237. free(Ndx);
  238. free(XLNZ);
  239. free(NZSUB);
  240. free(LNZ);
  241. } /* End of freesparse */
  242.  
  243.  
  244. int buildlists(int paraflag)
  245. {
  246. int i,j,k;
  247. int pmark = 0;
  248. int errcode = 0;
  249. Padjlist alink;
  250.  
  251. /* For each link, update adjacency lists of its end nodes */
  252. for (k=1; k<=Nlinks; k++)
  253. {
  254. i = Link[k].N1;
  255. j = Link[k].N2;
  256. if (paraflag) pmark = paralink(i,j,k); /* Parallel link check */
  257.  
  258. /* Include link in start node i's list */
  259. alink = (struct Sadjlist *) malloc(sizeof(struct Sadjlist));
  260. if (alink == NULL) return(101);
  261. if (!pmark) alink->node = j;
  262. else alink->node = 0; /* Parallel link marker */
  263. alink->link = k;
  264. alink->next = Adjlist[i];
  265. Adjlist[i] = alink;
  266.  
  267. /* Include link in end node j's list */
  268. alink = (struct Sadjlist *) malloc(sizeof(struct Sadjlist));
  269. if (alink == NULL) return(101);
  270. if (!pmark) alink->node = i;
  271. else alink->node = 0; /* Parallel link marker */
  272. alink->link = k;
  273. alink->next = Adjlist[j];
  274. Adjlist[j] = alink;
  275. }
  276. return(errcode);
  277. } /* End of buildlists */
  278.  
  279.  
  280. int paralink(int i, int j, int k)
  281. {
  282. Padjlist alink;
  283. for (alink = Adjlist[i]; alink != NULL; alink = alink->next)
  284. {
  285. if (alink->node == j) /* Link || to k (same end nodes) */
  286. {
  287. Ndx[k] = alink->link; /* Assign Ndx entry to this link */
  288. return(1);
  289. }
  290. }
  291. Ndx[k] = k; /* Ndx entry if link not parallel */
  292. return(0);
  293. } /* End of paralink */
  294.  
  295.  
  296. void xparalinks()
  297. {
  298. int i;
  299. Padjlist alink, /* Current item in adjacency list */
  300. blink; /* Previous item in adjacency list */
  301.  
  302. /* Scan adjacency list of each node */
  303. for (i=1; i<=Nnodes; i++)
  304. {
  305. alink = Adjlist[i]; /* First item in list */
  306. blink = NULL;
  307. while (alink != NULL)
  308. {
  309. if (alink->node == 0) /* Parallel link marker found */
  310. {
  311. if (blink == NULL) /* This holds at start of list */
  312. {
  313. Adjlist[i] = alink->next;
  314. free(alink); /* Remove item from list */
  315. alink = Adjlist[i];
  316. }
  317. else /* This holds for interior of list */
  318. {
  319. blink->next = alink->next;
  320. free(alink); /* Remove item from list */
  321. alink = blink->next;
  322. }
  323. }
  324. else
  325. {
  326. blink = alink; /* Move to next item in list */
  327. alink = alink->next;
  328. }
  329. }
  330. }
  331. } /* End of xparalinks */
  332.  
  333.  
  334. void freelists()
  335. {
  336. int i;
  337. Padjlist alink;
  338.  
  339. for (i=0; i<=Nnodes; i++)
  340. {
  341. for (alink = Adjlist[i]; alink != NULL; alink = Adjlist[i])
  342. {
  343. Adjlist[i] = alink->next;
  344. free(alink);
  345. }
  346. }
  347. } /* End of freelists */
  348.  
  349.  
  350. void countdegree()
  351. {
  352. int i;
  353. Padjlist alink;
  354. memset(Degree,0,(Nnodes+1)*sizeof(int));
  355.  
  356. /* NOTE: For purposes of node re-ordering, Tanks (nodes with */
  357. /* indexes above Njuncs) have zero degree of adjacency. */
  358.  
  359. for (i=1; i<=Njuncs; i++)
  360. for (alink = Adjlist[i]; alink != NULL; alink = alink->next)
  361. if (alink->node > 0) Degree[i]++;
  362. }
  363.  
  364.  
  365. int reordernodes()
  366. {
  367. int k, knode, m, n;
  368. for (k=1; k<=Nnodes; k++)
  369. {
  370. Row[k] = k;
  371. Order[k] = k;
  372. }
  373. n = Njuncs;
  374. for (k=1; k<=n; k++) /* Examine each junction */
  375. {
  376. m = mindegree(k,n); /* Node with lowest degree */
  377. knode = Order[m]; /* Node's index */
  378. if (!growlist(knode)) return(101); /* Augment adjacency list */
  379. Order[m] = Order[k]; /* Switch order of nodes */
  380. Order[k] = knode;
  381. Degree[knode] = 0; /* In-activate node */
  382. }
  383. for (k=1; k<=n; k++) /* Assign nodes to rows of */
  384. Row[Order[k]] = k; /* coeff. matrix */
  385. return(0);
  386. } /* End of reordernodes */
  387.  
  388.  
  389. int mindegree(int k, int n)
  390. {
  391. int i, m;
  392. int min = n,
  393. imin = n;
  394.  
  395. for (i=k; i<=n; i++)
  396. {
  397. m = Degree[Order[i]];
  398. if (m < min)
  399. {
  400. min = m;
  401. imin = i;
  402. }
  403. }
  404. return(imin);
  405. } /* End of mindegree */
  406.  
  407.  
  408. int growlist(int knode)
  409. {
  410. int node;
  411. Padjlist alink;
  412.  
  413. /* Iterate through all nodes connected to knode */
  414. for (alink = Adjlist[knode]; alink != NULL; alink = alink -> next)
  415. {
  416. node = alink->node; /* End node of connecting link */
  417. if (Degree[node] > 0) /* End node is active */
  418. {
  419. Degree[node]--; /* Reduce degree of adjacency */
  420. if (!newlink(alink)) /* Add to adjacency list */
  421. return(0);
  422. }
  423. }
  424. return(1);
  425. } /* End of growlist */
  426.  
  427.  
  428. int newlink(Padjlist alink)
  429. {
  430. int inode, jnode;
  431. Padjlist blink;
  432.  
  433. /* Scan all entries in adjacency list that follow anode. */
  434. inode = alink->node; /* End node of connection to anode */
  435. for (blink = alink->next; blink != NULL; blink = blink->next)
  436. {
  437. jnode = blink->node; /* End node of next connection */
  438.  
  439. /* If jnode still active, and inode not connected to jnode, */
  440. /* then add a new connection between inode and jnode. */
  441. if (Degree[jnode] > 0) /* jnode still active */
  442. {
  443. if (!linked(inode,jnode)) /* inode not linked to jnode */
  444. {
  445.  
  446. /* Since new connection represents a non-zero coeff. */
  447. /* in the solution matrix, update the coeff. count. */
  448. Ncoeffs++;
  449.  
  450. /* Update adjacency lists for inode & jnode to */
  451. /* reflect the new connection. */
  452. if (!addlink(inode,jnode,Ncoeffs)) return(0);
  453. if (!addlink(jnode,inode,Ncoeffs)) return(0);
  454. Degree[inode]++;
  455. Degree[jnode]++;
  456. }
  457. }
  458. }
  459. return(1);
  460. } /* End of newlink */
  461.  
  462.  
  463. int linked(int i, int j)
  464.  
  465. {
  466. Padjlist alink;
  467. for (alink = Adjlist[i]; alink != NULL; alink = alink->next)
  468. if (alink->node == j) return(1);
  469. return(0);
  470. } /* End of linked */
  471.  
  472.  
  473. int addlink(int i, int j, int n)
  474. {
  475. Padjlist alink;
  476. alink = (struct Sadjlist *) malloc(sizeof(struct Sadjlist));
  477. if (alink == NULL) return(0);
  478. alink->node = j;
  479. alink->link = n;
  480. alink->next = Adjlist[i];
  481. Adjlist[i] = alink;
  482. return(1);
  483. } /* End of addlink */
  484.  
  485.  
  486. int storesparse(int n)
  487. {
  488. Padjlist alink;
  489. int i, ii, j, k, l, m;
  490. int errcode = 0;
  491.  
  492. /* Allocate sparse matrix storage */
  493. XLNZ = (int *) calloc(n+2, sizeof(int));
  494. NZSUB = (int *) calloc(Ncoeffs+2, sizeof(int));
  495. LNZ = (int *) calloc(Ncoeffs+2, sizeof(int));
  496. ERRCODE(MEMCHECK(XLNZ));
  497. ERRCODE(MEMCHECK(NZSUB));
  498. ERRCODE(MEMCHECK(LNZ));
  499. if (errcode) return(errcode);
  500.  
  501. /* Generate row index pointers for each column of matrix */
  502. k = 0;
  503. XLNZ[1] = 1;
  504. for (i=1; i<=n; i++) /* column */
  505. {
  506. m = 0;
  507. ii = Order[i];
  508. for (alink = Adjlist[ii]; alink != NULL; alink = alink->next)
  509. {
  510. j = Row[alink->node]; /* row */
  511. l = alink->link;
  512. if (j > i && j <= n)
  513. {
  514. m++;
  515. k++;
  516. NZSUB[k] = j;
  517. LNZ[k] = l;
  518. }
  519. }
  520. XLNZ[i+1] = XLNZ[i] + m;
  521. }
  522. return(errcode);
  523. } /* End of storesparse */
  524.  
  525.  
  526. int ordersparse(int n)
  527.  
  528. {
  529. int i, k;
  530. int *xlnzt, *nzsubt, *lnzt, *nzt;
  531. int errcode = 0;
  532.  
  533. xlnzt = (int *) calloc(n+2, sizeof(int));
  534. nzsubt = (int *) calloc(Ncoeffs+2, sizeof(int));
  535. lnzt = (int *) calloc(Ncoeffs+2, sizeof(int));
  536. nzt = (int *) calloc(n+2, sizeof(int));
  537. ERRCODE(MEMCHECK(xlnzt));
  538. ERRCODE(MEMCHECK(nzsubt));
  539. ERRCODE(MEMCHECK(lnzt));
  540. ERRCODE(MEMCHECK(nzt));
  541. if (!errcode)
  542. {
  543.  
  544. /* Count # non-zeros in each row */
  545. for (i=1; i<=n; i++) nzt[i] = 0;
  546. for (i=1; i<=n; i++)
  547. {
  548. for (k=XLNZ[i]; k<XLNZ[i+1]; k++) nzt[NZSUB[k]]++;
  549. }
  550. xlnzt[1] = 1;
  551. for (i=1; i<=n; i++) xlnzt[i+1] = xlnzt[i] + nzt[i];
  552.  
  553. /* Transpose matrix twice to order column indexes */
  554. transpose(n,XLNZ,NZSUB,LNZ,xlnzt,nzsubt,lnzt,nzt);
  555. transpose(n,xlnzt,nzsubt,lnzt,XLNZ,NZSUB,LNZ,nzt);
  556. }
  557.  
  558. /* Reclaim memory */
  559. free(xlnzt);
  560. free(nzsubt);
  561. free(lnzt);
  562. free(nzt);
  563. return(errcode);
  564. } /* End of ordersparse */
  565.  
  566.  
  567. void transpose(int n, int *il, int *jl, int *xl, int *ilt, int *jlt,
  568. int *xlt, int *nzt)
  569. {
  570. int i, j, k, kk;
  571.  
  572. for (i=1; i<=n; i++) nzt[i] = 0;
  573. for (i=1; i<=n; i++)
  574. {
  575. for (k=il[i]; k<il[i+1]; k++)
  576. {
  577. j = jl[k];
  578. kk = ilt[j] + nzt[j];
  579. jlt[kk] = i;
  580. xlt[kk] = xl[k];
  581. nzt[j]++;
  582. }
  583. }
  584. } /* End of transpose */
  585.  
  586.  
  587. int linsolve(int n, double *Aii, double *Aij, double *B)
  588. {
  589. int *link, *first;
  590. int i, istop, istrt, isub, j, k, kfirst, newk;
  591. int errcode = 0;
  592. double bj, diagj, ljk;
  593. double *temp;
  594.  
  595. temp = (double *) calloc(n+1, sizeof(double));
  596. link = (int *) calloc(n+1,sizeof(int));
  597. first = (int *) calloc(n+1,sizeof(int));
  598. ERRCODE(MEMCHECK(temp));
  599. ERRCODE(MEMCHECK(link));
  600. ERRCODE(MEMCHECK(first));
  601. if (errcode)
  602. {
  603. errcode = -errcode;
  604. goto ENDLINSOLVE;
  605. }
  606. memset(temp,0,(n+1)*sizeof(double));
  607. memset(link,0,(n+1)*sizeof(int));
  608.  
  609. /* Begin numerical factorization of matrix A into L */
  610. /* Compute column L(*,j) for j = 1,...n */
  611. for (j=1; j<=n; j++)
  612. {
  613. /* For each column L(*,k) that affects L(*,j): */
  614. diagj = 0.0;
  615. newk = link[j];
  616. k = newk;
  617. while (k != 0)
  618. {
  619.  
  620. /* Outer product modification of L(*,j) by */
  621. /* L(*,k) starting at first[k] of L(*,k). */
  622. newk = link[k];
  623. kfirst = first[k];
  624. ljk = Aij[LNZ[kfirst]];
  625. diagj += ljk*ljk;
  626. istrt = kfirst + 1;
  627. istop = XLNZ[k+1] - 1;
  628. if (istop >= istrt)
  629. {
  630.  
  631. /* Before modification, update vectors 'first' */
  632. /* and 'link' for future modification steps. */
  633. first[k] = istrt;
  634. isub = NZSUB[istrt];
  635. link[k] = link[isub];
  636. link[isub] = k;
  637.  
  638. /* The actual mod is saved in vector 'temp'. */
  639. for (i=istrt; i<=istop; i++)
  640. {
  641. isub = NZSUB[i];
  642. temp[isub] += Aij[LNZ[i]]*ljk;
  643. }
  644. }
  645. k = newk;
  646. }
  647.  
  648. /* Apply the modifications accumulated */
  649. /* in 'temp' to column L(*,j). */
  650. diagj = Aii[j] - diagj;
  651. if (diagj <= 0.0) /* Check for ill-conditioning */
  652. {
  653. errcode = j;
  654. goto ENDLINSOLVE;
  655. }
  656. diagj = sqrt(diagj);
  657. Aii[j] = diagj;
  658. istrt = XLNZ[j];
  659. istop = XLNZ[j+1] - 1;
  660. if (istop >= istrt)
  661. {
  662. first[j] = istrt;
  663. isub = NZSUB[istrt];
  664. link[j] = link[isub];
  665. link[isub] = j;
  666. for (i=istrt; i<=istop; i++)
  667. {
  668. isub = NZSUB[i];
  669. bj = (Aij[LNZ[i]] - temp[isub])/diagj;
  670. Aij[LNZ[i]] = bj;
  671. temp[isub] = 0.0;
  672. }
  673. }
  674. } /* next j */
  675.  
  676. /* Foward substitution */
  677. for (j=1; j<=n; j++)
  678. {
  679. bj = B[j]/Aii[j];
  680. B[j] = bj;
  681. istrt = XLNZ[j];
  682. istop = XLNZ[j+1] - 1;
  683. if (istop >= istrt)
  684. {
  685. for (i=istrt; i<=istop; i++)
  686. {
  687. isub = NZSUB[i];
  688. B[isub] -= Aij[LNZ[i]]*bj;
  689. }
  690. }
  691. }
  692.  
  693. /* Backward substitution */
  694. for (j=n; j>=1; j--)
  695. {
  696. bj = B[j];
  697. istrt = XLNZ[j];
  698. istop = XLNZ[j+1] - 1;
  699. if (istop >= istrt)
  700. {
  701. for (i=istrt; i<=istop; i++)
  702. {
  703. isub = NZSUB[i];
  704. bj -= Aij[LNZ[i]]*B[isub];
  705. }
  706. }
  707. B[j] = bj/Aii[j];
  708. }
  709.  
  710. ENDLINSOLVE:
  711. free(temp);
  712. free(link);
  713. free(first);
  714. return(errcode);
  715. }

I'm using Visual Studio 2005. I searched the errors on many forums but can't find an exact solution.

The error list is:

1>------ Build started: Project: epanetdll, Configuration: Debug x64 ------
1>Compiling...
1>Generating Code...
1>Linking...
1> Creating library D:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\epanetdll\x64\Debug\epanetdll.lib and object D:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\epanetdll\x64\Debug\epanetdll.exp
1>epanetdll.exp : warning LNK4070: /OUT:EPANET2.DLL directive in .EXP differs from output filename 'D:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\epanetdll\x64\Debug\epanetdll.dll'; ignoring directive
1>smatrix.obj : error LNK2019: unresolved external symbol Ndx referenced in function allocsparse
1>smatrix.obj : error LNK2001: unresolved external symbol Nlinks
1>smatrix.obj : error LNK2019: unresolved external symbol Row referenced in function allocsparse
1>smatrix.obj : error LNK2019: unresolved external symbol Order referenced in function allocsparse
1>smatrix.obj : error LNK2019: unresolved external symbol Adjlist referenced in function allocsparse
1>smatrix.obj : error LNK2001: unresolved external symbol Nnodes
1>smatrix.obj : error LNK2001: unresolved external symbol Njuncs
1>smatrix.obj : error LNK2019: unresolved external symbol LNZ referenced in function storesparse
1>smatrix.obj : error LNK2019: unresolved external symbol NZSUB referenced in function storesparse
1>smatrix.obj : error LNK2019: unresolved external symbol Ncoeffs referenced in function storesparse
1>smatrix.obj : error LNK2019: unresolved external symbol XLNZ referenced in function storesparse
1>smatrix.obj : error LNK2001: unresolved external symbol Link
...
(These errors are also occuring in the other files. I didn't send them because it's too long!)

It seems the errors are related with the linker. But I can't get it. Can you give me any idea to solve this problem?

Thanks for any idea
Last edited by cscgal : Oct 12th, 2008 at 7:00 pm. Reason: Added code tags
AddThis Social Bookmark Button
Reply With Quote  
Posts: 3,877
Reputation: Dave Sinkula is a splendid one to behold Dave Sinkula is a splendid one to behold Dave Sinkula is a splendid one to behold Dave Sinkula is a splendid one to behold Dave Sinkula is a splendid one to behold Dave Sinkula is a splendid one to behold Dave Sinkula is a splendid one to behold 
Solved Threads: 164
Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: LNK2001 and LNK2019 problem!

  #2  
Oct 12th, 2008
You've extern'd the variables, where do you define them?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the C++ Forum
Views: 471 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:50 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC