Hello, Guest the thread was viewed511 times and contains 2 replies

last post from isifloh at the

Wie linkt man richtig in G++?

  • Ich krieg das gerade nicht auf die Reihe. Das Einbinden per #include verursacht noch keinen Fehler, erst wenn ich auch etwas aus der Bibliothek aufrufe bekomme ich das Problem. Hier ein Beispielcode exemplarisch mit zlib, tritt aber auch mit anderen auf:

    Wenn ich die Zeilen mit compress und decompress auskommentiere, kompiliert es ohne zu meckern.

    Kompiliere ich das aber so mit g++ zlib_test.cpp, bekomme ich folgende Fehler:

    /usr/bin/ld: /tmp/ccehDWF3.o: in function `main':

    zlib_test.cpp:(.text+0x7a): undefined reference to `compress'

    /usr/bin/ld: zlib_test.cpp:(.text+0xc5): undefined reference to `uncompress'

    collect2: error: ld returned 1 exit status


    Was mache ich da falsch?

    Ich nutze Linux Mint 21.2.