Brug for hjælp.

Tags:    c++ java programmering threads

<< < 12 > >>
Jeg får følgende fejl med MingW Compiler i Dev-C++.

Compiler: Default compiler
Building Makefile: "C:\\Private\\projekter\\calculator\\source\\dev-cpp\\Makefile.win"
Executing make...
make.exe -f "C:\\Private\\projekter\\calculator\\source\\dev-cpp\\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++/3.3.1" -I"C:/Dev-Cpp/include/c++/3.3.1/mingw32" -I"C:/Dev-Cpp/include/c++/3.3.1/backward" -I"C:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"C:/Dev-Cpp/include"

g++.exe main.o math.o -o "calculator.exe" -L"C:/Dev-Cpp/lib"

math.o(.text+0x100):math.cpp: multiple definition of `Plus()'
main.o(.text+0x100):main.cpp: first defined here
math.o(.text+0x188):math.cpp: multiple definition of `Minus()'
main.o(.text+0x188):main.cpp: first defined here
math.o(.text+0x210):math.cpp: multiple definition of `Dividere()'
main.o(.text+0x210):main.cpp: first defined here
math.o(.text+0x298):math.cpp: multiple definition of `Gange()'
main.o(.text+0x298):main.cpp: first defined here
math.o(.text+0x320):math.cpp: multiple definition of `ArealCirkel()'
main.o(.text+0x320):main.cpp: first defined here
math.o(.text+0x36a):math.cpp: multiple definition of `ArealRektangel()'
main.o(.text+0x36a):main.cpp: first defined here
math.o(.text+0x3d2):math.cpp: multiple definition of `ArealTrekant()'
main.o(.text+0x3d2):main.cpp: first defined here
math.o(.text+0x442):math.cpp: multiple definition of `ArealTrapez()'
main.o(.text+0x442):main.cpp: first defined here
math.o(.text+0x4dc):math.cpp: multiple definition of `RumfangPrisme()'
main.o(.text+0x4dc):main.cpp: first defined here
math.o(.text+0x526):math.cpp: multiple definition of `RumfangCylinder()'
main.o(.text+0x526):main.cpp: first defined here
math.o(.text+0x570):math.cpp: multiple definition of `RumfangKegle()'
main.o(.text+0x570):main.cpp: first defined here
math.o(.text+0x5c2):math.cpp: multiple definition of `RumfangKegleStub()'
main.o(.text+0x5c2):main.cpp: first defined here
math.o(.text+0x676):math.cpp: multiple definition of `RumfangPyramide()'
main.o(.text+0x676):main.cpp: first defined here
math.o(.text+0x6c8):math.cpp: multiple definition of `RumfangPyramideStub()'
main.o(.text+0x6c8):main.cpp: first defined here
math.o(.text+0x75e):math.cpp: multiple definition of `RumfangKugle()'
main.o(.text+0x75e):main.cpp: first defined here
math.o(.text+0x7ba):math.cpp: multiple definition of `Hastighed()'
main.o(.text+0x7ba):main.cpp: first defined here
math.o(.text+0x822):math.cpp: multiple definition of `Kvadratrod()'
main.o(.text+0x822):main.cpp: first defined here
math.o(.text+0x878):math.cpp: multiple definition of `DiameterTilRadius()'

main.o(.text+0x878):main.cpp: first defined here
math.o(.text+0x8ce):math.cpp: multiple definition of `RadiusTilDiameter()'
main.o(.text+0x8ce):main.cpp: first defined here

math.o(.text+0x91e):math.cpp: multiple definition of `HastighedTilTid()'
main.o(.text+0x91e):main.cpp: first defined here
math.o(.text+0x950):math.cpp: multiple definition of `Massefylde()'
main.o(.text+0x950):main.cpp: first defined here
math.o(.text+0x98e):math.cpp: multiple definition of `Procent()'
main.o(.text+0x98e):main.cpp: first defined here
math.o(.text+0x9d4):math.cpp: multiple definition of `Hjaelp()'
main.o(.text+0x9d4):main.cpp: first defined here
math.o(.text+0xa10):math.cpp: multiple definition of `Om()'
main.o(.text+0xa10):main.cpp: first defined here
math.o(.text+0xa8c):math.cpp: multiple definition of `OhmsLov()'
main.o(.text+0xa8c):main.cpp: first defined here
math.o(.text+0xe20):math.cpp: multiple definition of `Effekt()'
main.o(.text+0xe20):main.cpp: first defined here

math.o(.text+0xd90):math.cpp: multiple definition of `Modstand()'
main.o(.text+0xd90):main.cpp: first defined here
math.o(.text+0xd00):math.cpp: multiple definition of `Spaending()'
main.o(.text+0xd00):main.cpp: first defined here
math.o(.text+0xc70):math.cpp: multiple definition of `StroemStyrke()'
main.o(.text+0xc70):main.cpp: first defined here
math.o(.bss+0x0):math.cpp: multiple definition of `sum'
main.o(.bss+0x0):main.cpp: first defined here
math.o(.bss+0x8):math.cpp: multiple definition of `areal'
main.o(.bss+0x8):main.cpp: first defined here
math.o(.bss+0x10):math.cpp: multiple definition of `volumen'
main.o(.bss+0x10):main.cpp: first defined here
math.o(.bss+0x18):math.cpp: multiple definition of `hastighed'
main.o(.bss+0x18):main.cpp: first defined here
math.o(.bss+0x20):math.cpp: multiple definition of `kvadratrod'
main.o(.bss+0x20):main.cpp: first defined here
math.o(.bss+0x28):math.cpp: multiple definition of `radius'
main.o(.bss+0x28):main.cpp: first defined here
math.o(.bss+0x30):math.cpp: multiple definition of `R'

main.o(.bss+0x30):main.cpp: first defined here

math.o(.bss+0x38):math.cpp: multiple definition of `U'
main.o(.bss+0x38):main.cpp: first defined here
math.o(.bss+0x40):math.cpp: multiple definition of `I'
main.o(.bss+0x40):main.cpp: first defined here
math.o(.bss+0x48):math.cpp: multiple definition of `P'
main.o(.bss+0x48):main.cpp: first defined here
math.o(.bss+0x50):math.cpp: multiple definition of `pctsum'
main.o(.bss+0x50):main.cpp: first defined here
collect2: ld returned 1 exit status

make.exe: *** [calculator.exe] Error 1

Execution terminated

Nogen som måske har et hint til hvor fejlen kan findes?

source koderne ligger her:

Main.cpp
http://www.jaj.hj.dyndns.dk/tmp/main.cpp.txt

Math.cpp
http://www.jaj.hj.dyndns.dk/tmp/math.cpp.txt

Math.h
http://www.jaj.hj.dyndns.dk/tmp/math.h.txt

På forhånd tak.

Mvh. Jan Arni Jacobsen



20 svar postet i denne tråd vises herunder
1 indlæg har modtaget i alt 4 karma
Sorter efter stemmer Sorter efter dato
Hent den først som en string, og lav den så bagefter om til en double ved hjælp af fx atof.

1101110100010110000101000001

[Redigeret d. 05/02-05 12:28:31 af Nicolai Lyster Fersner]



Du skal skrive extern foran "double sum;" og alle de andre variable i .h filen.

Du skal have double sum; i én af cpp filerne.

Du skal ikke inkludere math.cpp i main.cpp



Og du skal tilføje prototyper til dine funktioner, i stil med:
double Gange();
double Dividere();
I math.h

Og du skal inkludere iostream i dine cpp filer.

(Og du bør kalde math.h noget andet, kompileren kunne finde på at inkludere sin egen math.h.)



Du skal skrive extern foran "double sum;" og alle de andre variable i .h filen.

Du skal have double sum; i én af cpp filerne.

Du skal ikke inkludere math.cpp i main.cpp


extern double sum;+andre variabler: DONE
Du skal ikke inkludere math.cpp i main.cpp: DONE
Du skal have double sum; i én af cpp filerne.: ?

Jeg får nu følgende fejl.

Compiler: Default compiler
Building Makefile: "C:\\Private\\projekter\\calculator\\source\\dev-cpp\\Makefile.win"
Executing make...
make.exe -f "C:\\Private\\projekter\\calculator\\source\\dev-cpp\\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/include/c++/3.3.1" -I"C:/Dev-Cpp/include/c++/3.3.1/mingw32" -I"C:/Dev-Cpp/include/c++/3.3.1/backward" -I"C:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"C:/Dev-Cpp/include"

main.cpp: In function `int main(int, char**)':

main.cpp:57: error: `GANGE' undeclared (first use this function)
main.cpp:57: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:58: error: `Gange' undeclared (first use this function)

main.cpp:59: error: `sum' undeclared (first use this function)

main.cpp:61: error: `DIVIDERE' undeclared (first use this function)
main.cpp:62: error: `Dividere' undeclared (first use this function)

main.cpp:65: error: `PLUS' undeclared (first use this function)
main.cpp:66: error: `Plus' undeclared (first use this function)

main.cpp:69: error: `MINUS' undeclared (first use this function)
main.cpp:70: error: `Minus' undeclared (first use this function)
main.cpp:73: error: `AREAL_CIRKEL' undeclared (first use this function)

main.cpp:74: error: `ArealCirkel' undeclared (first use this function)
main.cpp:75: error: `areal' undeclared (first use this function)
main.cpp:77: error: `AREAL_REKTANGEL' undeclared (first use this function)
main.cpp:78: error: `ArealRektangel' undeclared (first use this function)

main.cpp:81: error: `FART' undeclared (first use this function)
main.cpp:82: error: `Hastighed' undeclared (first use this function)
main.cpp:83: error: `hastighed' undeclared (first use this function)
main.cpp:85: error: `AREAL_TREKANT' undeclared (first use this function)
main.cpp:86: error: `ArealTrekant' undeclared (first use this function)

main.cpp:89: error: `AREAL_TRAPEZ' undeclared (first use this function)
main.cpp:90: error: `ArealTrapez' undeclared (first use this function)

main.cpp:93: error: `RUMFANG_PRISME' undeclared (first use this function)
main.cpp:94: error: `RumfangPrisme' undeclared (first use this function)
main.cpp:95: error: `volumen' undeclared (first use this function)
main.cpp:97: error: `RUMFANG_CYLINDER' undeclared (first use this function)
main.cpp:98: error: `RumfangCylinder' undeclared (first use this function)

main.cpp:101: error: `RUMFANG_KEGLE' undeclared (first use this function)
main.cpp:102: error: `RumfangKegle' undeclared (first use this function)

main.cpp:105: error: `RUMFANG_KEGLE_STUB' undeclared (first use this function)

main.cpp:106: error: `RumfangKegleStub' undeclared (first use this function)

main.cpp:109: error: `RUMFANG_PYRAMIDE' undeclared (first use this function)
main.cpp:110: error: `RumfangPyramide' undeclared (first use this function)

main.cpp:113: error: `RUMFANG_PYRAMIDE_STUB' undeclared (first use this function)
main.cpp:114: error: `RumfangPyramideStub' undeclared (first use this function)

main.cpp:117: error: `RUMFANG_KUGLE' undeclared (first use this function)
main.cpp:118: error: `RumfangKugle' undeclared (first use this function)

main.cpp:121: error: `KVADRATROD' undeclared (first use this function)
main.cpp:122: error: `Kvadratrod' undeclared (first use this function)

main.cpp:123: error: `kvadratrod' undeclared (first use this function)
main.cpp:125: error: `DIAMETERTILRADIUS' undeclared (first use this function)
main.cpp:126: error: `DiameterTilRadius' undeclared (first use this function)
main.cpp:127: error: `radius' undeclared (first use this function)
main.cpp:129: error: `RADIUSTILDIAMETER' undeclared (first use this function)
main.cpp:130: error: `RadiusTilDiameter' undeclared (first use this function)
main.cpp:133: error: `OHMS_LOV' undeclared (first use this function)
main.cpp:134: error: `OhmsLov' undeclared (first use this function)
main.cpp:136: error: `HJAELP' undeclared (first use this function)
main.cpp:137: error: `Hjaelp' undeclared (first use this function)
main.cpp:139: error: `ABOUT' undeclared (first use this function)
main.cpp:140: error: `Om' undeclared (first use this function)
main.cpp:142: error: `AFSLUT' undeclared (first use this function)

make.exe: *** [main.o] Error 1

Execution terminated


Mvh. Jan Arni Jacobsen



Og du skal inkludere math.h i math.cpp



Og du skal tilføje prototyper til dine funktioner, i stil med:
double Gange();
double Dividere();
I math.h

Og du skal inkludere iostream i dine cpp filer.

(Og du bør kalde math.h noget andet, kompileren kunne finde på at inkludere sin egen math.h.)


Hvorfor vil du inkludere prototyperne i en *.h fil? jeg mente ellers at den kun var til definationer...

Mvh. Jan Arni Jacobsen



Hvis du i main.cpp vil kalde en funktion der findes i math.cpp skal main.cpp vide hvordan den ser ud, så den kan kalde den rigtig.

Så du skal have en prototype i math.h (dvs double whatever(); ).



Hvis du i main.cpp vil kalde en funktion der findes i math.cpp skal main.cpp vide hvordan den ser ud, så den kan kalde den rigtig.

Så du skal have en prototype i math.h (dvs double whatever(); ).

oki doki... er i gang med at rette det nu...Finder du flere fejl så post da venligst her tak..


Mvh. Jan Arni Jacobsen



Der mangler en using namespace std;

Der er to funktioner der hedder double Massefylde()

Der mangler et ; og r er ukendt i HastighedTilTid



I "gamle" C dage skulle man ikke have en prototype, man skulle "bare" sikre sig at man brugte funktionerne rigtigt. Det kunne give mange sjove fejl.



<< < 12 > >>
t