473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Very basic question.

My native language is c, but I have the unpleasant task of porting a C++
code from SGI MIPS to Linux Opteron, I have no help from the author of the
code.

One of several problems is that my g++ (3.3.3) compiler balks at expressions
like <int>: for example if Scan is a well defined object, the compiler balks
at Scan<int> ::~Scan; the error message is 'undefined reference to
Scan<int>'. Is <int> a cast operator? What can be done to avoid the error
message?

Thanks in advance.

--
ESOJAY
Jul 22 '05 #1
5 1472

"ESOJAY" <es******@hotmail.com> wrote in message
news:cb**********@news.ox.ac.uk...
My native language is c, but I have the unpleasant task of porting a C++
code from SGI MIPS to Linux Opteron, I have no help from the author of the
code.

One of several problems is that my g++ (3.3.3) compiler balks at expressions like <int>: for example if Scan is a well defined object, the compiler balks at Scan<int> ::~Scan; the error message is 'undefined reference to
Scan<int>'. Is <int> a cast operator? What can be done to avoid the error
message?

Thanks in advance.


Looks like a template parameter, but who can say unless you post at the very
least complete line of code.

POST MORE CODE.

john

Jul 22 '05 #2

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2j*************@uni-berlin.de...

"ESOJAY" <es******@hotmail.com> wrote in message
news:cb**********@news.ox.ac.uk...
My native language is c, but I have the unpleasant task of porting a C++
code from SGI MIPS to Linux Opteron, I have no help from the author of the code.

One of several problems is that my g++ (3.3.3) compiler balks at expressions
like <int>: for example if Scan is a well defined object, the compiler

balks
at Scan<int> ::~Scan; the error message is 'undefined reference to
Scan<int>'. Is <int> a cast operator? What can be done to avoid the error message?

Thanks in advance.


Looks like a template parameter, but who can say unless you post at the

very least complete line of code.

POST MORE CODE.

john


The code looks like:

#include <file1>
#include <file2>
#include <file3>
using namespace std;

#include "file4"
#include "file5"

typedef vector<double> Var1;
typedef double Var2;

template <class T>
class func {

public:
func (vector<int *> Var3, int *Var4, int *Var5 = NULL) ;
func (vector<Var1> Var6) ;
func (vector<Var2>& Var6) ;
func (func<T> &m) ;
~func(void);
...........................
void func2(bool b) ;

protected:
.....................
};

The offending line is:
func<int>::func2(bool).
Linker error is undefined reference to func<int>::func2(bool).

Thanks,

--
ESOJAY

Jul 22 '05 #3

"ESOJAY" <es******@hotmail.com> wrote in message
news:cb**********@news.ox.ac.uk...

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2j*************@uni-berlin.de...

"ESOJAY" <es******@hotmail.com> wrote in message
news:cb**********@news.ox.ac.uk...
My native language is c, but I have the unpleasant task of porting a C++ code from SGI MIPS to Linux Opteron, I have no help from the author of the code.

One of several problems is that my g++ (3.3.3) compiler balks at

expressions
like <int>: for example if Scan is a well defined object, the compiler

balks
at Scan<int> ::~Scan; the error message is 'undefined reference to
Scan<int>'. Is <int> a cast operator? What can be done to avoid the error message?

Thanks in advance.


Looks like a template parameter, but who can say unless you post at the

very
least complete line of code.

POST MORE CODE.

john


The code looks like:

#include <file1>
#include <file2>
#include <file3>
using namespace std;

#include "file4"
#include "file5"

typedef vector<double> Var1;
typedef double Var2;

template <class T>
class func {

public:
func (vector<int *> Var3, int *Var4, int *Var5 = NULL) ;
func (vector<Var1> Var6) ;
func (vector<Var2>& Var6) ;
func (func<T> &m) ;
~func(void);
...........................
void func2(bool b) ;

protected:
.....................
};

The offending line is:
func<int>::func2(bool).
Linker error is undefined reference to func<int>::func2(bool).

Thanks,


A linker error means that you've failed to define the entity named. In this
case you've failed to give a definition for the method func2, in the class
template func<T>, in the case when T equals int.

Now there is no such definition in the code you've posted but maybe the
definition is somewhere else in your code. Do you see a function looking
something like this

template <class T>
void func<T>::func2(bool ...)
{
...
}

somewhere in your code? Its because that hasn't been included in your code
or has been included but not in the right place that you are getting linker
errors.

It would also be worth looking around and seeing where the method func2 is
actually being called.

john
Jul 22 '05 #4
ESOJAY wrote:
My native language is c, but I have the unpleasant task of porting a C++
code from SGI MIPS to Linux Opteron, I have no help from the author of the
code.

One of several problems is that my g++ (3.3.3) compiler balks at expressions
like <int>: for example if Scan is a well defined object, the compiler balks
at Scan<int> ::~Scan; the error message is 'undefined reference to
Scan<int>'. Is <int> a cast operator? What can be done to avoid the error
message?


Do you know on what compiler(s) the original code was compiled? Template
instantiation can be handled in several different ways. See the GCC
TexInfo manual, under 'C++ Extensions --> Template Instantiation', or
the comp.lang.c++ FAQ (search the web for that).

--
Regards,
Buster.
Jul 22 '05 #5
On Wed, 23 Jun 2004 14:16:49 +0100 in comp.lang.c++, "ESOJAY"
<es******@hotmail.com> wrote,
The offending line is:
func<int>::func2(bool).
Linker error is undefined reference to func<int>::func2(bool).


Please refer to these topics in Marshall Cline's C++ FAQ and see if they
shed any light on the problem:

[34.12] Why can't I separate the definition of my templates class from
it's declaration and put it inside a .cpp file?

[34.13] How can I avoid linker errors with my template functions?

You can get the FAQ at: http://www.parashift.com/c++-faq-lite/

Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Tom | last post by:
Hey all, I've been planning to get myself started with DocBook for quite some time now, so when I unexpectedly encountered a task for which DocBook might actually be very useful, I thought I'd...
30
by: Vla | last post by:
why did the designers of c++ think it would be more useful than it turned out to be?
5
by: Lee David | last post by:
I went to the sun site and downloaded what I hope is the development part of java. I downloaded JDK5 with Netbeans. I installed it and now have a folder in my program group "Netbeans". Is that...
10
by: Jason Curl | last post by:
Greetings, I have an array of 32 values. This makes it extremely fast to access elements in this array based on an index provided by a separate enum. This array is defined of type "unsigned long...
6
by: msnews.microsoft.com | last post by:
Hello All, I am very new to ASP.NET and I have a basic question. Can somebody please explain? I have an .aspx Web Page with a textbox control. When the Page initially loads I am calling a...
8
by: pamelafluente | last post by:
Hi, I would like to get some advice. I know enough vb.net on win apps, but I have never worked on web applications and asp.net. I would appreciate if you could indicate the most basic...
6
by: aghazalp | last post by:
hi guys, this would be the most basic question ever...I am not a programmer but I am trying to learn programming in python...I was reading John Zelle's text book and instructed me to make .py file...
17
by: blueapricot416 | last post by:
This is a very basic question -- but I can't find the answer after looking for 20 minutes. If you code something like: function set_It() { setTimeout('Request_Complete("apple", -72)',5000) }...
7
by: Bruno43 | last post by:
Hi I am trying to learn Visual Basic and I am getting everything for the most part, mainly because of my ability to read code like a book, but my question is what is the best way to Navigate through...
56
by: mdh | last post by:
As I begin to write more little programs without the help of the exercises, little things pop up that I need to understand more fully. Thus, below, and although this is not the exact code, the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.