Anfängerprobleme
-
Mag mal jemand einem autodidaktischem Hobbyprogrammierer aufs Pferd helfen?
// ********************************************************************* // test.cpp // ********************************************************************* #include <iostream> #include "test_sp.cpp" int main() { double pi = 3.14; pi = mal2(pi); std::cout << "Tüdelüt " << pi << "\n"; return 0; }// ********************************************************************* // test_sp.cpp // ********************************************************************* #include "test_sp.hpp" double mal2(double wert) { double x; x =wert*2; return x; }// ********************************************************************* // test_sp.hpp // ********************************************************************* #ifndef test_sp_h #define test_sp_h double mal2(double wert); #endif# makefile all: test.o test_sp.o g++ -o main.exe test.o test_sp.o test.o: test.cpp g++ -c -Wall test.cpp test_sp.o: test_sp.cpp g++ -c test_sp.cppSind bestimmt ne Menge Fehler, ich veruche gerade dem grundsätzlichen Konzept des Ganzen auf die Spur zu kommen:
make all (im Verzeichnis: G:\Daten) g++ -c test_sp.cpp g++ -o main.exe test.o test_sp.o --- errorlevel 1 test_sp.o:test_sp.cpp:(.text+0x0): multiple definition of `mal2(double)' test.o:test.cpp:(.text+0xfe): first defined here collect2: ld returned 1 exit status Kompilierung fehlgeschlagen.Für jeden Tip dankbar
Gruß Stefan
-
Mann inkludiert immer nur die Header-Dateien und nicht die Cpp-Dateien

-
Oh ja, danke, nu läuft's
