Rubbish Output Dev-C Compiler / Program for Binomial Coefficient

N

Nena

Hi there,
I'm trying to include the Numerical Recipes for C++
for the Dev-C++ Editor Version.

But so far I've failed.

Therefore I've copied all head-files (for example nr.h)
into the folder where my program is. When compiling my
program two windows are poping up.
The first one is saying "Total errors 0" and "Size of
output file: 0".

And the second window behind the first one is a
"compiler and linker output" with the following two
lines
C:\DOKUME~1\LOKALE~1\Temp\ccyQaaaa.o(.text+0x2fc):lambda~1.cpp:
undefined reference to `NR::gammln(double)'
C:\DOKUME~1\LOKALE~1\Temp\ccyQaaaa.o(.text+0x317):lambda~1.cpp:
undefined reference to `NR::gammln(double)'

Here is my program where I'm trying to calculate
the simple binomial coefficient

#include<iostream>
#include<cstdlib>
#include<iomanip>
#include "nr.h" // include Numerical Recipes
#include<math.h>
#include<cmath>

using namespace std;
using namespace NR;

double myBino(DP n, DP k);

int main()
{
return 0;
}

double myBino(DP n, DP k)
{
double value = 0;

value = exp(gammln(n + 1.) - gammln(k + 1.));

cout << myBino(10, 6);

return value;
}

Could someone help me? I don't know exactly where to
look to fix my problem to get the program to work.

Many thanks!

Nena
 
R

red floyd

Nena said:
Hi there,
I'm trying to include the Numerical Recipes for C++
for the Dev-C++ Editor Version.

But so far I've failed.

Therefore I've copied all head-files (for example nr.h)
into the folder where my program is. When compiling my
program two windows are poping up.
The first one is saying "Total errors 0" and "Size of
output file: 0".

And the second window behind the first one is a
"compiler and linker output" with the following two
lines
C:\DOKUME~1\LOKALE~1\Temp\ccyQaaaa.o(.text+0x2fc):lambda~1.cpp:
undefined reference to `NR::gammln(double)'
C:\DOKUME~1\LOKALE~1\Temp\ccyQaaaa.o(.text+0x317):lambda~1.cpp:
undefined reference to `NR::gammln(double)'

Here is my program where I'm trying to calculate
the simple binomial coefficient

#include<iostream>
#include<cstdlib>
#include<iomanip>
#include "nr.h" // include Numerical Recipes
#include<math.h>
#include<cmath>

using namespace std;
using namespace NR;

double myBino(DP n, DP k);

int main()
{
return 0;
}

double myBino(DP n, DP k)
{
double value = 0;

value = exp(gammln(n + 1.) - gammln(k + 1.));

cout << myBino(10, 6);

return value;
}

Could someone help me? I don't know exactly where to
look to fix my problem to get the program to work.

Your main exits immediately.
 
M

Mark P

Nena said:
Hi there,
I'm trying to include the Numerical Recipes for C++
for the Dev-C++ Editor Version.

But so far I've failed.

Therefore I've copied all head-files (for example nr.h)
into the folder where my program is. When compiling my
program two windows are poping up.
The first one is saying "Total errors 0" and "Size of
output file: 0".

And the second window behind the first one is a
"compiler and linker output" with the following two
lines
C:\DOKUME~1\LOKALE~1\Temp\ccyQaaaa.o(.text+0x2fc):lambda~1.cpp:
undefined reference to `NR::gammln(double)'
C:\DOKUME~1\LOKALE~1\Temp\ccyQaaaa.o(.text+0x317):lambda~1.cpp:
undefined reference to `NR::gammln(double)'

Here is my program where I'm trying to calculate
the simple binomial coefficient

#include<iostream>
#include<cstdlib>
#include<iomanip>
#include "nr.h" // include Numerical Recipes
#include<math.h>
#include<cmath>

using namespace std;
using namespace NR;

double myBino(DP n, DP k);

int main()
{
return 0;
}

double myBino(DP n, DP k)
{
double value = 0;

value = exp(gammln(n + 1.) - gammln(k + 1.));

cout << myBino(10, 6);

return value;
}

Could someone help me? I don't know exactly where to
look to fix my problem to get the program to work.

Many thanks!

Nena

This is a compiler issue. Your code needs to be linked with the library
code-- the linker is basically saying that it doesn't see a definition
of the function NR::gammln( double) anywhere.
 
N

Nena

Okay, thanks.
I'm C++ beginner. And how can I link my code with the library code?

Thanks!
 
N

Nena

I've tried the following to link my code with the
library code under the Dev-C++ editor:

Options -> Compiler options -> Directories

Then I've added the path of my Numerical Recipes folder
into "C++ include files" and "Libraries directory".
Result: DOESN'T HELP!
I still obtain the same messages.

Aarrhhhhhhhh! Help!
 
M

Mark P

Nena said:
Okay, thanks.
I'm C++ beginner. And how can I link my code with the library code?

Thanks!

First, don't top-post-- reply below the message to which you're responding.

To your question, I don't know. You'll need to look at the
documentation for your compiler and perhaps also any info included with
the NR text. Generally you need to tell the compiler the name and
location of the library, but the details of this will depend on your
specific setup.

Normally I would say to find a discussion forum for your compiler, and
you might still try this, but Dev-C++ is sort of defunct at this point
and I don't know how much support you'll find. I'd suggest trying its
free successor, CodeBlocks, as you might find a more active community to
help you.
 
M

Mark P

Nena said:
I've tried the following to link my code with the
library code under the Dev-C++ editor:

Options -> Compiler options -> Directories

Then I've added the path of my Numerical Recipes folder
into "C++ include files" and "Libraries directory".
Result: DOESN'T HELP!
I still obtain the same messages.

Aarrhhhhhhhh! Help!

That's only half of what you need. That's the location to look for the
library, but you haven't provided the name of the library. Take a look at:

http://www.uniqueness-template.com/devcpp/

Near the bottom, there's an item called "Using library files". Follow
the general instructions there and add the appropriate -l[libname] flags
to the linker.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top