NR in C++: Compiler Compatibility
William Vetterling
03-03-2002, 08:03 PM
Prior to release of the Numerical Recipes in C++, we tested the code with the following compilers:
Microsoft Visual C++ 6.0
Borland C++ Builder 5.0
GNU C++ 2.95.2
KAI C++ 4.04
Sun Workshop Compiler C++ 5.0
GNU C++ 2.95.2
We do not yet have comprehensive knowledge about the performance of the Recipes with other compilers or compiler versions, other than to say that if the compiler is truly ANSI/ISO C++ compatible, it is supposed to work the C++ Recipes.
If you have used the C++ Recipes with other compilers or other versions of these compilers, please share your information about compatibility, or about specific incompatibilities, in this thread. Users will also be interested in any workarounds you have found for non-compatible compilers.
tonyz
01-29-2003, 08:58 PM
William,
I am inquiring to see if anyone has tested NR in Visual Studio.NET.
I am trying to create a Managed C++ Library for use in .NET applications, however I get an error in every file:
fatal error C1010: unexpected end of file while looking for precompiled header directive
I have not yet figured out what is wrong with the header files. If anyone can shed some light on this, I would appreciate it.
Thanks
Tony
William Vetterling
02-09-2003, 01:36 PM
Tony,
I don't have Visual C++ .NET, but Visual C++ also has this error message. It results when a precompiled header is specified but is not actually included by the source. According to the help file, the error can be caused by specifying an incorrect file as a header file, or by specifying an include file with the /Yu (Use Precompiled Header) command line option that is not listed in the source file as an include file.
It may be that you are not purposefully doing these things. You will have to check the project settings to see if the use of precompiled headers is being specified accidentally.
Choose menu options:
Project
Settings
C/C++ tab
Category: Precompiled Header
In this category, I think the choices "Not using precompiled headers" or "Automatic use of precompiled headers" will work.
windmaomao
02-14-2003, 03:49 PM
borland c++ builder 6.0
First there's no problem using nr in bc++ compile if you read the instructions came with nr code.
When i tried to make a package for all nr routines(which i guess will make my job easier later), i got "reference unsolved" error. I figured out by disabling the "precompiled headers" options and add #pragma package(smart_init) to each of nr routine.
Hope this helps.
tonyz
03-12-2003, 10:04 AM
Thanks for the advice.
Although adding that line fixed that problem, I did run into other trying to call the routines from C#.
In the end, I ended up porting the routines I needed to C#, and all is well. Turns out the port is fairly simply and replicable.
Cheers,
Tony
sgsong
12-06-2004, 07:36 AM
compiler version 1.3 to get the NR C++ examples to work. It seems to have some problems with the file "nrutil_nr.h".
robertoguillenp
07-16-2006, 10:51 AM
Hello William,
I had the same problem as the other user's.
I followed your advice and got rid of that error, however I ran into a new one that I have no idea how to solve.
Once I made sure the automatic use of precompiled headers option was on, I got this error message when trying to use 'newt', which is:
error C2664: 'newt' : cannot convert parameter 3 from 'void (const class NRVec<double> &,class NRVec<double> &)' to 'void (__cdecl *)(c
onst class NRVec<double> &,class NRVec<double> &)
Since I also bought me the NR C++ example book, I used the xnewt C++ example on page 165. It compiled it very well, but when I copy the same routine into my MFC C++ source code I got the very same error messagge, which makes think it wasn't a typing mistake.
I guess the problem is related to using different compiler options when developing an MFC or console application.
Can you please give me any clue how to compile this NR routine?
Thanks a lot !
Roberto.
Tony,
I don't have Visual C++ .NET, but Visual C++ also has this error message. It results when a precompiled header is specified but is not actually included by the source. According to the help file, the error can be caused by specifying an incorrect file as a header file, or by specifying an include file with the /Yu (Use Precompiled Header) command line option that is not listed in the source file as an include file.
It may be that you are not purposefully doing these things. You will have to check the project settings to see if the use of precompiled headers is being specified accidentally.
Choose menu options:
Project
Settings
C/C++ tab
Category: Precompiled Header
In this category, I think the choices "Not using precompiled headers" or "Automatic use of precompiled headers" will work.