Thank you very much - that's understood,

Hago

Am 20.03.2024 um 13:03 schrieb Lex Trotman via Users:
On Wed, 20 Mar 2024 at 21:45, Hago Ziegler via Users
<users@lists.geany.org> wrote:
Hi Lex,

finally I got it. Now everything is compiled, I got the *.exe and it
works as expected. :-)

But I'd like to have this done automatically.
Is there a way to tell Geany respectively
<https://dict.leo.org/englisch-deutsch/respectively> g++ to compile
_and_ link all *.o files in a certain directory?

If you make a Geany project you can set a Geany build command for that
project that runs the proper command, but you have to manually update
it when you add another file.

But in general there are many complexities with building C/C++
software with files spread over different directories, and libraries
to link, and documentation (you _do_ do that don't you? ;-) tools
needing to be run and translation tools run etc.  A "compile and link
all files in a directory" will get old very quickly in any realistic
project and Geany can only run one command per menu item.

There are specialist tools for building software, make, cmake, meson,
etc etc, choose your poison(s) and set up their control files.
Learning about build tools is part of learning C/C++ and most other
languages.

You can then set the Geany build command to run your choice from the
menu or toolbar or shortcut.

Cheers
Lex

Regards,  Hago


Am 19.03.2024 um 12:50 schrieb Lex Trotman via Users:
You havn't compiled and linked bus.cpp with DBus.cpp so the linker is
correctly complaining it can't find the constructor.

Its not anything to do with Geany specifically, thats how the gcc
tools work.  You need to compile bus.cpp and link the result with the
compiled result of DBus.cpp.

You said had used cmake with VS, and Geany is no different.  If you
want you can use cmake, just edit the command for the make menu entry
to cmake and provide the CMakeLists.txt file(s).

Cheers
Lex

On Tue, 19 Mar 2024 at 20:52, Hago Ziegler via Users
<users@lists.geany.org> wrote:
Hello,

I'm trying to learn C++.
For the moment, I'm exploring classes and objects.
I want to split my program into 3 files: DBus.cpp - bus.h - bus.cpp
With Geany this doesn't work (mingw32/8.3). It only compiles, if I
integrate bus.cpp into bus.h.
I tried the same with Visual Studio (CMake) and it compiles the
splittend files without problems.

I want generally use Geany, because VS is too complex for learning, not
uncomplicated to handle.
What can I do?

    Below the 3 Files: DBus.cpp - bus.h - bus.cpp and the error file.
---------DBus.cpp------------------
#include "bus.h"
#include <iostream>

int main() {
       DBus dbus1(130, 25000, "rot");
       DBus dbus2(180, 40000, "blau");
       dbus1.ausgabeDBus();
       dbus2.ausgabeDBus();
}
---------bus.h--------------------------
#pragma once
#include <string>
#include <iostream>

class DBus {
     private:
         int kw;
         int preis;
         std::string farbe;
     public:
         DBus(int KW, int Pr, std::string Far);
         void ausgabeDBus();
         int getPreis();
         std::string getFarbe();
};
----------bus.cpp--------------------------
#include <iostream>
#include "bus.h"

DBus::DBus(int KW, int Pr, std::string Far) {
       kw = KW;
       preis = Pr;
       farbe = Far;
}
void DBus::ausgabeDBus() {
       std::cout << "der " << farbe << "e Campingbus hat " << kw << " KW
und kostete " << preis << " Euro" << std::endl;
}
int DBus::getPreis() {
       return preis;
}
std::string DBus::getFarbe() {
       return farbe;
}
-------------error----------------------
g++ -Wall -o "DBus"  "DBus.cpp" (im Verzeichnis:
C:\Users\hz\Documents\C++\Class)
C:/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
C:\Users\hz\AppData\Local\Temp\ccrZlTnk.o:DBus.cpp:(.text+0x54):
undefined reference to `DBus::DBus(int, int,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >)'
C:/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
C:\Users\hz\AppData\Local\Temp\ccrZlTnk.o:DBus.cpp:(.text+0xaf):
undefined reference to `DBus::DBus(int, int,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >)'
C:/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
C:\Users\hz\AppData\Local\Temp\ccrZlTnk.o:DBus.cpp:(.text+0xd3):
undefined reference to `DBus::ausgabeDBus()'
C:/c/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
C:\Users\hz\AppData\Local\Temp\ccrZlTnk.o:DBus.cpp:(.text+0xdf):
undefined reference to `DBus::ausgabeDBus()'
collect2.exe: error: ld returned 1 exit status
Kompilierung fehlgeschlagen.


_______________________________________________
Users mailing list -- users@lists.geany.org
To unsubscribe send an email to users-le...@lists.geany.org
_______________________________________________
Users mailing list -- users@lists.geany.org
To unsubscribe send an email to users-le...@lists.geany.org
_______________________________________________
Users mailing list -- users@lists.geany.org
To unsubscribe send an email to users-le...@lists.geany.org
_______________________________________________
Users mailing list -- users@lists.geany.org
To unsubscribe send an email to users-le...@lists.geany.org

_______________________________________________
Users mailing list -- users@lists.geany.org
To unsubscribe send an email to users-le...@lists.geany.org

Reply via email to