Getting xodeint from numerical recipes to work in dev-c++

In summary: C++ can wait.Summary: In summary, the conversation discusses the speaker's difficulty with compiling a numerical code example in dev-c++ for a computational physics course. They are missing some necessary files in their project folder and have tried adding different files without success. They downloaded the code from a machine-readable source and are asking for help in getting it to work.
  • #1
mjordan2nd
177
1
I am taking a computational physics course, and currently I have very little knowledge of programming. I have downloaded the numerical recipes machine-readable code, and I am trying to get one of their examples to work in dev-c++. Unfortunately, I am having difficulty.

I have copied xodeint.c, odeint.c, nrutil.h, nrutil.c, and nr.h from subdirectories of ./nr_c304/legacy/nr2/C_211 into my project folder. I then pulled up xodeint.c in dev-c++. Upon compilation, I got the following errors:

Code:
6   0   C:\Users\Amol\Documents\School\graduate computational\ODEexample\xodeint.c  In file included from C:\Users\Amol\Documents\School\graduate computational\ODEexample\xodeint.c
183 7   C:\Users\Amol\Documents\School\graduate computational\ODEexample\nr.h   [Warning] conflicting types for built-in function 'fmin' [enabled by default]
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x195): undefined reference to `vector'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x1a8): undefined reference to `vector'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x1cd): undefined reference to `matrix'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x1ef): undefined reference to `bessj0'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x211): undefined reference to `bessj1'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x238): undefined reference to `bessj'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x25f): undefined reference to `bessj'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x2b5): undefined reference to `rkqs'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x30a): undefined reference to `odeint'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x3e7): undefined reference to `bessj'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x4d4): undefined reference to `free_matrix'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x4f1): undefined reference to `free_vector'
C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o xodeint.c:(.text+0x508): undefined reference to `free_vector'
c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe    C:\Users\Amol\AppData\Local\Temp\ccAOtzsJ.o: bad reloc address 0x0 in section `.pdata'
C:\Users\Amol\Documents\School\graduate computational\ODEexample\collect2.exe   [Error] ld returned 1 exit status

So I suppose I'm missing some files in my project folder that are necessary to compile the code, but I'm not sure what I'm missing. I have tried adding certain files to my project folder, such as bessj1.c, however this does not change the errors I receive. Any help in getting this working would be much appreciated.

Regards.
 
Technology news on Phys.org
  • #2
Give a link to where you downloaded the code.

The phrase "machine readable code" is confusing. A file like xodeint.c that ends in ".c" should be human readable source code file, not a file of machine code.
 
  • #3
I downloaded the file from here: http://www.nr.com/ under the machine readable source-code link. They're just .c and .h c files.
 
  • #4
You are correct that something is missing. Compling a program can produce errors about missing things in two stages. The error can happen as a source code file is being compiled or the error can happen after the files are compiled and the linker tries to link up the object files that have been produced by the compiler.

I think the errors you show are happening when the program is being linked. (I don't use the ming compiler myself, so I base this on http://www.mingw.org/wiki/the_linker_consistently_giving_undefined_references ). Can you post the command that your development environment is using to link the program. It may mention some libraries that you haven't downloaded.
 
  • #5
Stephen is correct. Those errors are unresolved symbols (function entry points). NB you are trying to compile C source with dev-c++. C++ and C are NOT the same language. I do not know dev-c++, it may have a switch setting to become a C compiler, but I doubt it. I would doubt the validity of final compiled result, if it ever succeeds. C++ runtime API semantics are not necessarily the same as those for C.

There are free C compilers - gcc is one. Consider using that. Are you on Windows, Cygwin, or Linux?

Ignoring the compiler for now -- There some possibilities:

1. You are missing some "primary" .c files
2. You have to compile some intermediate object files (usually creates a .o file) from some existing .c files. Then place them on the final compile command line.

If you have a make file please post it. Otherwise please post your compile command(s).

IMO, We should get you going with a C compiler first.
 

1. How do I obtain the numerical recipes code for use in Dev-C++?

The numerical recipes code can be purchased directly from their website, or it may be available through your institution's library. Once obtained, you can simply add the code files to your Dev-C++ project.

2. Why is the numerical recipes code not working in Dev-C++?

There could be several reasons for this. First, make sure you have properly added the code files to your project. You may also need to adjust your compiler settings to ensure they are compatible with the code. Additionally, check for any errors or warnings in the code itself.

3. Can I use the numerical recipes code in Dev-C++ for any programming language?

No, the numerical recipes code is specifically designed for use in C and C++ programming languages. It may not work in other languages or may require significant modifications.

4. How can I test the accuracy of the numerical recipes code in Dev-C++?

To test the accuracy of the numerical recipes code, you can compare its results to known values or use analytical solutions to verify the calculations. It may also be helpful to run the code with different input values and compare the results.

5. Can I modify the numerical recipes code in Dev-C++ for my own purposes?

Yes, you can modify the code for your own purposes as long as you adhere to the terms and conditions set by numerical recipes. However, it is important to thoroughly understand the code and its implications before making any modifications.

Similar threads

  • Programming and Computer Science
Replies
11
Views
2K
Replies
9
Views
3K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
9
Views
8K
  • Programming and Computer Science
Replies
1
Views
269
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
6
Views
1K
  • Programming and Computer Science
Replies
12
Views
3K
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
8
Views
3K
Back
Top