Thread overview
Linker error? - fraction.zip
Feb 17, 2006
Mel
Feb 17, 2006
Walter Bright
Feb 17, 2006
Bertel Brander
February 17, 2006
I just recently started to re-teach myself C++ after a few years, so many it's just a stupid error on my part.  (If so, permission to correct/scold/flame/beat/shoot me is freely granted)

Anyway, here are my the contents of my three files:

***************************************
//driver.cpp
#include "fraction.h"

int main()
{
Fraction a;
a.doNothing();
return 0;
}

***************************************
//fraction.cpp
#include "fraction.h"

void Fraction::doNothing()
{
}

***************************************
//fraction.h
#ifndef __FRACTION_H
#define __FRACTION_H

class Fraction
{
public:
void doNothing();
};

#endif

***************************************

After running "dmc driver", I get the following output:

link driver,,,user32+kernel32/noi;
OPTLINK (R) for Win32 Release 7.50B1
Copyright (C) Digital Mars 1989-2001 All Rights Reserved

driver.obj(driver)
Error 42: Symbol Undefined ?doNothing@Fraction@@QAEXXZ (void syscall
Fraction::doNothing( void ))

--- errorlevel 1

The only reason I can think of is that maybe my system's Japanese configuration is throwing something off ( '\' is always displayed as a yen symbol).  Anyone have any ideas?

Thanks in advance,
Mel


February 17, 2006
You need to compile fraction.cpp and link it in, too.

"Mel" <Mel_member@pathlink.com> wrote in message news:dt37vh$1m8a$1@digitaldaemon.com...
> link driver,,,user32+kernel32/noi;
> OPTLINK (R) for Win32 Release 7.50B1
> Copyright (C) Digital Mars 1989-2001 All Rights Reserved
>
> driver.obj(driver)
> Error 42: Symbol Undefined ?doNothing@Fraction@@QAEXXZ (void syscall
> Fraction::doNothing( void ))


February 17, 2006
Mel wrote:
> I just recently started to re-teach myself C++ after a few years, so many it's
> just a stupid error on my part.  (If so, permission to
> correct/scold/flame/beat/shoot me is freely granted)
> 

Just compile it all at once:
dmc driver.cpp fraction.cpp -omyprog.exe

Which will create myprog.exe

-- 
Absolutely not the best homepage on the net:
http://home20.inet.tele.dk/midgaard
But it's mine - Bertel