Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can't solve a linking error

Posted on 1997-02-26
1
Medium Priority
?
219 Views
Last Modified: 2010-04-10
I am trying to link a whole series of files each with its own node (in Borland C++4.5).  There do not appear to be any errors in the code itself only in the linking.  The message I get is

   Undefined symbol arrayread(char far*, int) in module easywav2.cpp

I have only included the relevant parts of both of these files as they are quite long.  I have not even mentioned the word far in my definition.


#include <complex.h>
extern complex *arrayread (char *filename, int    num_elem);
int main()
{
...
...
complex *x;
char* filename;
unsigned int numpointsx;

cout << endl << "Filename?";
cin >> filename;
x = arrayread(filename, numpointsx);
....
....
}


The arrayread function is in a seperate node.

#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <fstream.h>
#include <complex.h>

complex *arrayread (char *filename, int *num_elem)
{
      int i=0,j;
      complex *data;
      char buffer[10];
      double tempd;

      fstream file;
      file.open (filename, ios::in );

      while (!file.eof())
      {
            i++;
            file.getline(buffer,10);
            cout << buffer << endl;
      }
      file.close();
      file.open (filename, ios::in );

      data = new complex[i];
      for (j=0; j<i; j++)  // loop reads in data
            {
            file.getline(buffer,10);
            sscanf(buffer,"%lf",&tempd);
            data[j]=tempd;
            }
      file.close();

      *num_elem = i;
      return data;
}


I hope all the information that I have given is sufficient.  If you need any more then please let me know.
0
Comment
Question by:DavidZ021497
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
edtmihu earned 100 total points
ID: 1162265
The function is implemented as :
complex *arrayread (char *filename, int *num_elem)
but refered to as :
extern complex *arrayread (char *filename, int num_elem);
the problem is the num_elem parameter.
Change the forward declaration to:
complex *arrayread (char *filename, int *num_elem);

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question