Fehlermeldung beim Kompilieren



  • #include<iostream>
    using namespace std;
    #include <stdio.h>
    #include "plotter.h"
    
    int main( int argc, char** argv )
    {
    	GIFPlotter plotter(stdin, stdout, stderr);
    
    	/* set Plotter parameters */
    	void* p="150x100";
    	plotter.parampl ("BITMAPSIZE", p);
    	plotter.parampl ("BG_COLOR", "orange");
    	plotter.parampl ("TRANSPARENT_COLOR", "orange");
    	plotter.parampl ("GIF_ITERATIONS", "100");
    	plotter.parampl ("GIF_DELAY", "5");
    
    	plotter.openpl();			/* begin page of graphics */
    	plotter.space (0, 0, 149, 99);	/* specify user coordinate system */
    
    	plotter.pencolorname ("red");      /* objects will be drawn in red */
    	plotter.linewidth (5);             /* set the line thickness */
    	plotter.filltype (1);              /* objects will be filled */
    	plotter.fillcolorname ("black");   /* set the fill color */
    
    	for (int i = 0; i < 180 ; i += 15)
    	{
    		plotter.erase ();              /* begin new GIF image */
    		plotter.ellipse (75, 50, 40, 20, i); /* draw an ellipse */
    	}
    	plotter.closepl ();                /* end page of graphics */
    
    	return 0;
    }
    

    Fehlermeldung:

    **** Build of configuration Debug for project Plotter ****
    
    make all 
    Building file: ../plotter.cpp
    Invoking: GCC C++ Compiler
    g++ -I/usr/include -I/usr/include/opencv -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"plotter.d" -MT"plotter.d" -o"plotter.o" "../plotter.cpp"
    ../plotter.cpp: In function »int main(int, char**)«:
    ../plotter.cpp:18: Fehler: ungültige Umwandlung von »const void*« in »void*«
    ../plotter.cpp:20: Fehler: ungültige Umwandlung von »const void*« in »void*«
    ../plotter.cpp:20: Fehler:   Argument 2 von »static int Plotter::parampl(const char*, void*)« wird initialisiert
    ../plotter.cpp:21: Fehler: ungültige Umwandlung von »const void*« in »void*«
    ../plotter.cpp:21: Fehler:   Argument 2 von »static int Plotter::parampl(const char*, void*)« wird initialisiert
    ../plotter.cpp:22: Fehler: ungültige Umwandlung von »const void*« in »void*«
    ../plotter.cpp:22: Fehler:   Argument 2 von »static int Plotter::parampl(const char*, void*)« wird initialisiert
    ../plotter.cpp:23: Fehler: ungültige Umwandlung von »const void*« in »void*«
    ../plotter.cpp:23: Fehler:   Argument 2 von »static int Plotter::parampl(const char*, void*)« wird initialisiert
    make: *** [plotter.o] Fehler 1
    


  • const_cast:

    plotter.parampl("BITMAPSIZE", const_cast<char*>("150x100"));
    

    und bitte noch mal kompilieren und posten.



  • **** Build of configuration Debug for project Plotter ****
    
    make all 
    Building file: ../src/plotter.cpp
    Invoking: GCC C++ Compiler
    g++ -I/usr/include -I/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/ -I/usr/include/opencv -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/plotter.d" -MT"src/plotter.d" -o"src/plotter.o" "../src/plotter.cpp"
    Finished building: ../src/plotter.cpp
    
    Building target: Plotter
    Invoking: GCC C++ Linker
    g++ -L/usr/lib -L/usr/local/lib -L/lib -o"Plotter"  ./src/plotter.o   -lcv -lhighgui
    ./src/plotter.o: In function `main':
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:15: undefined reference to `GIFPlotter::GIFPlotter(_IO_FILE*, _IO_FILE*, _IO_FILE*)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:18: undefined reference to `Plotter::parampl(char const*, void*)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:19: undefined reference to `Plotter::parampl(char const*, void*)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:20: undefined reference to `Plotter::parampl(char const*, void*)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:21: undefined reference to `Plotter::parampl(char const*, void*)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:22: undefined reference to `Plotter::parampl(char const*, void*)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:24: undefined reference to `Plotter::openpl()'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:25: undefined reference to `Plotter::space(int, int, int, int)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:27: undefined reference to `Plotter::pencolorname(char const*)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:28: undefined reference to `Plotter::linewidth(int)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:29: undefined reference to `Plotter::filltype(int)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:30: undefined reference to `Plotter::fillcolorname(char const*)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:34: undefined reference to `Plotter::erase()'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:35: undefined reference to `Plotter::ellipse(int, int, int, int, int)'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:37: undefined reference to `Plotter::closepl()'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:39: undefined reference to `GIFPlotter::~GIFPlotter()'
    /home/user/Daten/Workspace/Plotter/Debug/../src/plotter.cpp:39: undefined reference to `GIFPlotter::~GIFPlotter()'
    collect2: ld gab 1 als Ende-Status zurück
    make: *** [Plotter] Fehler 1
    


  • Du musst das *.lib File linken. Nur die Header einbinden reicht natürlich nicht.

    GCC - Linking with external libraries
    Bei G++ dürfte es nicht viel anders sein.



  • und wie heisst die lib?

    libplotter klappt nicht?



  • hab_ne_frage schrieb:

    und wie heisst die lib?
    libplotter klappt nicht?

    Wie? Du musst doch wissen wie die Library heißt. Was hast du denn für Files? Wenn du nur die Header hast, dann wird dir das recht wenig nützen, denn irgendwo muss das ganze ja implementiert sein.

    EDIT:
    Ich kenn plotutils selbst nicht. Ich hab jetzt mal vermutet, dass es eine lib ist. Wenn du die Implementationsdateien (*.cpp) hast, dann muss der Compiler die natürlich auch finden können.



  • ja ich denke es ist die libplotter.la bei mir unter /usr/lib

    oder mache ich da was falsch



  • hab_ne_frage schrieb:

    oder mache ich da was falsch

    Welche Header (von plotutils) bindest du überhaupt ein?



  • die plotter.h



  • hab_ne_frage schrieb:

    die plotter.h

    NOTE: Neither the `pic2plot' program nor the `libplotter' C++ class library
    is built by default, since they require a working C++ compiler.  But it is
    easy to request that they be built.  For details, see INSTALL.pkg.  Also, a
    standalone version of the `libxmi' scan-conversion library isn't built by
    default, since `libxmi' is distributed as a separate package.
    

    Lies dir mal die Readme durch.



  • also meines erachtens ist die lib doch kompiliert ich arbeite unter linux:

    --- replaced obj /usr/lib/libxmi.so.0.1.3
    --- replaced sym /usr/lib/libxmi.so.0
    --- replaced sym /usr/lib/libxmi.so
    --- replaced obj /usr/lib/libxmi.la
    --- replaced obj /usr/lib/libxmi.a
    --- replaced obj /usr/lib/libplotter.so.2.2.3
    --- replaced sym /usr/lib/libplotter.so.2
    --- replaced sym /usr/lib/libplotter.so
    --- replaced obj /usr/lib/libplotter.la
    --- replaced obj /usr/lib/libplotter.a
    --- replaced obj /usr/lib/libplot.so.2.2.3
    --- replaced sym /usr/lib/libplot.so.2
    --- replaced sym /usr/lib/libplot.so
    --- replaced obj /usr/lib/libplot.la
    --- replaced obj /usr/lib/libplot.a
    

    nur das linken klappt irgentwie nicht?



  • Wenn du ein lib File hast, dann musst du das auch (ggf. vollqualifiziert) linken.



  • Ok also mit diesem "hack":

    const_cast<char*>()
    

    kompiliert es jetzt zwar, aber es werden die gecasteten Sachen nicht angenommen.
    Dh es werden die initialen (standard) belegungen verwendet.

    WIe funktioniert denn das richtig? Kann doch eigentlich nicht sein?

    Mfg



  • hab_ne_frage schrieb:

    Ok also mit diesem "hack":

    const_cast<char*>()
    

    kompiliert es jetzt zwar, aber es werden die gecasteten Sachen nicht angenommen.
    Dh es werden die initialen (standard) belegungen verwendet.

    Das kann nicht stimmen. Zeig mal den Code.



  • // set Plotter parameters
    	plotter.parampl ("BITMAPSIZE", const_cast<char*>("600x600") );
    	plotter.parampl ("BG_COLOR", const_cast<char*>("yellow") );              // background color for window
    	plotter.parampl ("USE_DOUBLE_BUFFERING", const_cast<char*>("yes") );
    

Anmelden zum Antworten