![]() |
|
|
|
#1
|
|||
|
|||
|
In general how do I compile my *.c files that uses the nr files?
|
|
#2
|
|||
|
|||
|
There is no "general" set of instructions for compiling any C program, so the answer to, "How do I ... ?" is: "It depends."
How about giving us some details of your setup?
How do you compile your other (non-NR) *.c programs?
Regards, Dave Last edited by davekw7x; 01-07-2009 at 11:31 AM. |
|
#3
|
|||
|
|||
|
Compile *.c files
Hi,
Thanks for your respone. I am using openSUSE 10.3 (i586) - Kenet 2.6 The compiler is gcc version 4.2.1 The directory structure is /usr/local/src/NR_C301/legacy/nr2/C_211 I am trying to compile one of the example. I compile all the NR routine .../recipes#gcc -v -I../other -I/usr/include *.c => rlftfrag.c:30: error: redefinition of 'main' rlftfrag.c:9: error: previous definition of 'main' was here rlftfrag.c:50: error: redefinition of 'main' rlftfrag.c:9: error: previous definition of 'main' was here .../recipes#ar cr libnr.a *.c => then I got file "libnr.a" .../examples#gcc -g xjulday.c -I../other -I/usr/include -o xjulday -L ../recipes -lm =>In file includes from xjulday.c:7: ../other/nr.h:423: error: conflivting type for 'select' /usr/include/sys/select.h:112: error: previous declaration of 'select' was here Thanks in Advance |
|
#4
|
|||
|
|||
|
Quote:
So, I suggest that you move the original nr.h to a "safe" directory. Make a copy in the recipes directory. Then comment out line 423 of nr.h in the recipes directory. Code:
/*float select(unsigned long k, unsigned long n, float arr[]); */ I assume that you meant to tell it to use libnr.a, so: Maybe the compile command would be something like Code:
gcc -g xjulday.c -I../other -o xjulday -L../recipes -lnr -lm If this doesn't work, and you can't figure out why, then post again and tell us what happened. Don't try any of the following until you get a successful compilation and execution of xjulday. If this does work, you will have to do something about the NR select() function in case you ever need it. Here is what I did, way back when... I made a copy of the select.c file in the recipes directory and called it nrselect.c, then I moved the original select.c to the "safe" directory. I changed all references to the select() function in the files in NR recipes and examples and other directories to nrselect(). (I did this after moving the affected files to the "safe" directory and making copies back in their original directories.) If you haven't done this already, don't forget to go back into your new nr.h and change line 423. Code:
float nrselect(unsigned long k, unsigned long n, float arr[]); Then try compiling various files in the examples directory. Let us know how it works out. Regards, Dave Footnotes: 1. The above worked on my Centos 5 workstation (GNU gcc Version 4.1.2). 2. I also moved all files in the recipes directory with a main() function to another directory before compiling the library so that there wouldn't be any files in the library with a main() function. A minor point, maybe, but I like things to be as clean as possible (within reason). Last edited by davekw7x; 01-08-2009 at 04:41 PM. |
|
#5
|
|||
|
|||
|
Hi Dave,
thanks a lot. It's working. Guy |
|
#6
|
|||
|
|||
|
I'm also having a problem compiling my *.c files
I'm new at c, which is why I'm trying to work with the NR in the first place.
When I downloaded the files, they did not come with any clear instructions or any Makefiles that I could see. I'm using Linux (ubuntu) and CLI gcc. My initial goal is to get lu decomposition working, with the old c code version. And I'm kind of in a panic -- I was expecting this part of my work to be a piece of cake, yet I'm wasting all kinds of time on it. I've tried all kinds of things, some of which gave me *.a library files, with no good results. What I'm hoping for, (against hope?) is a way to just collect all the necessary files in a directory (copied, not original) and *either* some commands to make the libraries I need, *or* the proper gcc "incantations" to just attach the NR .c and .h files and compile my code. If I can even get the calendar demo going, I'll be better off. It seems like others here have done it - please help! Thanks, Alex |
![]() |
| Thread Tools | |
| Display Modes | |
|
|