Please support our C++ advertiser: Programming Forums
Views: 2008 | Replies: 12
![]() |
I got this code from a book I bought. I wanted to see if it words but it gives me errors.
Here is the source code.
and the header file:
The errors I keep on getting is:
1>Linking...
1>gaussj.obj : error LNK2019: unresolved external symbol _free_ivector referenced in function _gaussj
1>gaussj.obj : error LNK2019: unresolved external symbol _nrerror referenced in function _gaussj
1>gaussj.obj : error LNK2019: unresolved external symbol _ivector referenced in function _gaussj
1>LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Documents\Visual Studio 2005\Projects\Linear Equation\Debug\Linear Equation.exe : fatal error LNK1120: 4 unresolved externals
Here is the source code.
cplusplus Syntax (Toggle Plain Text)
#include<math.h> #define NRANSI #include"nrutil.h" #define SWAP(a,b) { temp=(a);(a)=(b);(b)=temp; } void gaussj(float **a, int n, float **b, int m) { int *indxc,*indxr,*ipiv; int i,icol,irow,j,k,l,ll; float big,dum,pivinv,temp; indxc=ivector(1,n); indxr=ivector(1,n); ipiv=ivector(1,n); for (j=1;j<=n;j++) ipiv[j]=0; for (i=1;i<=n;i++) { big=0.0; for (j=1;j<=n;j++) if (ipiv[j] != 1) for (k=1;k<=n;k++) { if (ipiv[k] == 0) { if (fabs(a[j][k]) >= big) { big=fabs(a[j][k]); irow=j; icol=k; } } else if (ipiv[k] > 1) nrerror("gaussj: Singular Matrix-1"); } ++(ipiv[icol]); if (irow != icol) { for (l=1;l<=n;l++) SWAP(a[irow][l],a[icol][l]) for (l=1;l<=m;l++) SWAP(b[irow][l],b[icol][l]) } indxr[i]=irow; indxc[i]=icol; if (a[icol][icol] == 0.0) nrerror("gaussj: Singular Matrix-2"); pivinv=1.0/a[icol][icol]; a[icol][icol]=1.0; for (l=1;l<=n;l++) a[icol][l] *= pivinv; for (l=1;l<=m;l++) b[icol][l] *= pivinv; for (ll=1;ll<=n;ll++) if (ll != icol) { dum=a[ll][icol]; a[ll][icol]=0.0; for (l=1;l<=n;l++) a[ll][l] -= a[icol][l]*dum; for (l=1;l<=m;l++) b[ll][l] -= b[icol][l]*dum; } } for (l=n;l>=1;l--) { if (indxr[l] != indxc[l]) for (k=1;k<=n;k++) SWAP(a[k][indxr[l]],a[k][indxc[l]]); } free_ivector(ipiv,1,n); free_ivector(indxr,1,n); free_ivector(indxc,1,n); } #undef SWAP #undef NRANSI
and the header file:
cplusplus Syntax (Toggle Plain Text)
#ifndef _NR_UTILS_H_ #define _NR_UTILS_H_ staticfloat sqrarg; #define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg) staticdouble dsqrarg; #define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg) staticdouble dmaxarg1,dmaxarg2; #define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\ (dmaxarg1) : (dmaxarg2)) staticdouble dminarg1,dminarg2; #define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\ (dminarg1) : (dminarg2)) staticfloat maxarg1,maxarg2; #define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\ (maxarg1) : (maxarg2)) staticfloat minarg1,minarg2; #define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\ (minarg1) : (minarg2)) staticlong lmaxarg1,lmaxarg2; #define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\ (lmaxarg1) : (lmaxarg2)) staticlong lminarg1,lminarg2; #define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\ (lminarg1) : (lminarg2)) staticint imaxarg1,imaxarg2; #define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\ (imaxarg1) : (imaxarg2)) staticint iminarg1,iminarg2; #define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\ (iminarg1) : (iminarg2)) #define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) #ifdefined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */ void nrerror(char error_text[]); float *vector(long nl, long nh); int *ivector(long nl, long nh); unsignedchar *cvector(long nl, long nh); unsignedlong *lvector(long nl, long nh); double *dvector(long nl, long nh); float **matrix(long nrl, long nrh, long ncl, long nch); double **dmatrix(long nrl, long nrh, long ncl, long nch); int **imatrix(long nrl, long nrh, long ncl, long nch); float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch, long newrl, long newcl); float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch); float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh); void free_vector(float *v, long nl, long nh); void free_ivector(int *v, long nl, long nh); void free_cvector(unsignedchar *v, long nl, long nh); void free_lvector(unsignedlong *v, long nl, long nh); void free_dvector(double *v, long nl, long nh); void free_matrix(float **m, long nrl, long nrh, long ncl, long nch); void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch); void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch); void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch); void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch); void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch, long ndl, long ndh); #else/* ANSI */ /* traditional - K&R */ void nrerror(); float *vector(); float **matrix(); float **submatrix(); float **convert_matrix(); float ***f3tensor(); double *dvector(); double **dmatrix(); int *ivector(); int **imatrix(); unsignedchar *cvector(); unsignedlong *lvector(); void free_vector(); void free_dvector(); void free_ivector(); void free_cvector(); void free_lvector(); void free_matrix(); void free_submatrix(); void free_convert_matrix(); void free_dmatrix(); void free_imatrix(); void free_f3tensor(); #endif/* ANSI */ #endif/* _NR_UTILS_H_ */
The errors I keep on getting is:
1>Linking...
1>gaussj.obj : error LNK2019: unresolved external symbol _free_ivector referenced in function _gaussj
1>gaussj.obj : error LNK2019: unresolved external symbol _nrerror referenced in function _gaussj
1>gaussj.obj : error LNK2019: unresolved external symbol _ivector referenced in function _gaussj
1>LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Documents\Visual Studio 2005\Projects\Linear Equation\Debug\Linear Equation.exe : fatal error LNK1120: 4 unresolved externals
Last edited by Ancient Dragon : Jul 27th, 2007 at 7:32 pm. Reason: remove color codes, correct code tags, and beautify code (whew!)
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,666
Reputation:
Rep Power: 40
Solved Threads: 990
>> for (j=1;j<=n;j++)
I think you misquoted the code (lines 19 and 20) because that is just so much nonsense. Proofread the code you have to make sure you did not make typing errors. If its really like that in the book then go to the publishers web site to see if they have a list of book corrections or electronic copy of the code, which sometimes has corrected code.
I think you misquoted the code (lines 19 and 20) because that is just so much nonsense. Proofread the code you have to make sure you did not make typing errors. If its really like that in the book then go to the publishers web site to see if they have a list of book corrections or electronic copy of the code, which sometimes has corrected code.
Last edited by Ancient Dragon : Jul 27th, 2007 at 7:39 pm.
•
•
Join Date: Apr 2005
Location: New York state
Posts: 501
Reputation:
Rep Power: 6
Solved Threads: 78
Last edited by ShawnCplus : Jul 27th, 2007 at 9:05 pm.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h-->++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h-->++ r z+*
•
•
•
•
>> for (j=1;j<=n;j++)
I think you misquoted the code (lines 19 and 20) because that is just so much nonsense. Proofread the code you have to make sure you did not make typing errors. If its really like that in the book then go to the publishers web site to see if they have a list of book corrections or electronic copy of the code, which sometimes has corrected code.
Um, it is fairly obvious that your online parser has a flaw and it not converting < (html syntax into plain text ">"). You shouldn't blame the OP for your mistakes Ancient Dragon. And why is my infraction that you mistakenly gave me still there, did I not ask you to get rid of it

I did say this before!
Last edited by iamthwee : Jul 28th, 2007 at 4:41 am.
... the hat of 'is this a cat in a hat?'
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,666
Reputation:
Rep Power: 40
Solved Threads: 990
•
•
•
•
Um, it is fairly obvious that your online parser has a flaw and it not converting < (html syntax into plain text ">"). You shouldn't blame the OP for your mistakes Ancient Dragon.
Its not an error -- to my knowledge (and I could be wrong) the only markup codes recognized are code tags. People are supposed to post ONLY code -- this is not a place to test html code. If someone wants to post C or C++ code that contains html markup code then its his respoinsibility to remove it.
•
•
•
•
And why is my infraction that you mistakenly gave me still there, did I not ask you to get rid of it
That was no mistake -- it was intentional.
Oh. I didn't realize Dani made you Super Mod.
Last edited by Ancient Dragon : Jul 28th, 2007 at 8:22 am.
Does anyone bother to actually read my posts these days, cos I find I am just repeating myself.
Ancient Dragon, your online code beautifier is flawed!
It changes all the "< >" symbols to < and > respectively! So telling the op of for experimenting with html is silly, It is YOUR fault. .
>That was no mistake -- it was intential.
I already told you, it was a mistake, I forgot to add the code tags and then was cut off the internet so I was unable to edit my post in time. Why should I be punished for a mistake?

You promised me you would tell the supermods, but you never did
Ancient Dragon, your online code beautifier is flawed!
It changes all the "< >" symbols to < and > respectively! So telling the op of for experimenting with html is silly, It is YOUR fault. .
>That was no mistake -- it was intential.
I already told you, it was a mistake, I forgot to add the code tags and then was cut off the internet so I was unable to edit my post in time. Why should I be punished for a mistake?

You promised me you would tell the supermods, but you never did
Last edited by Ancient Dragon : Jul 28th, 2007 at 8:53 am. Reason: post edited in error.
... the hat of 'is this a cat in a hat?'
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,666
Reputation:
Rep Power: 40
Solved Threads: 990
•
•
•
•
Does anyone bother to actually read my posts these days, cos I find I am just repeating myself.
Ancient Dragon, your online code beautifier is flawed!
It changes all the "< >" symbols to < and > respectively! So telling the op of for experimenting with html is silly, It is YOUR fault. .
Ah, my mistake. I though you meant the other way around. If there is a problem you should report it in the Community Feedback board. But I have not seen that in any other posts.
this is a test of html markup parsor for < and > symbol also together like this <>
As you can see it works great for me. Sometimes the parser turns things into smiley faces, but there is a check box to turn off smileys in text posts.
•
•
•
•
>That was no mistake -- it was intential.
I already told you, it was a mistake, I forgot to add the code tags and then was cut off the internet so I was unable to edit my post in time. Why should I be punished for a mistake?![]()
Another case of miscommunication.
Send me the PM or link where I made that statement because I don't remember it. This is something I think would be better discussed via PM instead of here.
Last edited by Ancient Dragon : Jul 28th, 2007 at 9:04 am.
>If there is a problem you should report it in the Community Feedback board. But I have not seen that in any other posts.
What has this got to do with the daniweb community feedback? Your online code beautifier is the thing that's broken. (Why am I repeating myself again?)
>As you can see it works great for me.
That's great, we all know the daniweb code tagging works fine. But what has this got to do with the online beautifier you are using which is broken?
>This is something I think would be better discussed via PM instead of here.
What is there to discuss. For the time being I will pretend it didn't happen. Please just don't make these mistakes in the future. Be careful with that infraction button you use. Thanx.
Just in case you didn't get it. I'm going to say it again.
YOUR ONLINE BEAUTIFIER IS BROKE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
What has this got to do with the daniweb community feedback? Your online code beautifier is the thing that's broken. (Why am I repeating myself again?)
>As you can see it works great for me.
That's great, we all know the daniweb code tagging works fine. But what has this got to do with the online beautifier you are using which is broken?
>This is something I think would be better discussed via PM instead of here.
What is there to discuss. For the time being I will pretend it didn't happen. Please just don't make these mistakes in the future. Be careful with that infraction button you use. Thanx.

Just in case you didn't get it. I'm going to say it again.
YOUR ONLINE BEAUTIFIER IS BROKE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Last edited by iamthwee : Jul 28th, 2007 at 9:35 am.
... the hat of 'is this a cat in a hat?'
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode