undefined reference



  • Hallo Community,

    ichse bin gewaltig Anfänger und habe ein Problem mit einer eigenen erstellten header datei. Bei jedem compilen bekomme ich :

    main.cpp: undefined reference to `analyse_options(int, char**)`

    --options.hpp--

    int analyse_options(int argc, char *argv[]);
    void usage();
    

    --options.cpp--

    #include <getopt.h>
    #include <iostream>
    using namespace std;
    
    int analyse_options (int argc, char *argv[])
    {
            /*
                    -v verbose
                    -h help
            */
            int option;
            bool VERBOSE = false;
            bool USAGE   = false;
            std::string table;
            /* initialize the parser */
            while (( option = getopt (argc, argv, "vh")) != EOF) {
                    switch(option) {
                            case 'v': VERBOSE = true; break;
                            case 'h': USAGE = true; break;
                            default: break;
                    }
            }
    
    }
    void usage ()
    {
            cout << "\n Syntax:\n";
    }
    

    --main.cpp--

    #include <iostream> /* wegen cout */
    #include <iomanip> /* tabellarischer output */
    #include "options.hpp"
    
    int main () {
            analyse_options(argc, argv);
    }
    

    Kann mir hier jemand möglicherweise unter die Arme greifen ?
    Danke.



  • hi,
    es wäre noch hilfreich wie wissen wie du deinen compiler aufrufst - wahrscheinlich liegt der fehler dort.

    blan



  • verzeihung, my fault:

    --Makefile--

    C = g++
    CCFLAGS = -g -O2 -Wall          # debugging and optimizing
    LD = g++                        # oder: LD = ld
    LDFLAGS =
    YACC = yacc
    LOADLIBS = -L/usr/lib64/mysql -l mysqlclient -l boost_regex
    LOADHEADER = -I/usr/include
    MAKE = make
    MAKEARGS = 'SHELL=/bin/sh'
    SHELL = /bin/sh
    RM = /bin/rm
    
    EXE=query
    
    all: $(EXE)
    
    clean:
            # -rm *.o q_query
            -$(RM) *.o $(EXE)
    
    query: q_query.o
            $(LD) $(CCFLAGS) $(LOADLIBS) $? -o $@
            -chmod 700 query
    
    .SUFFIXES: .cpp .hpp .o
    %.o: %.cpp
            $(CC) $(CCFLAGS) -c $< -o $@
    %.o: %.cpp %.h
            $(CC) $(CCFLAGS) -c $< -o $@
    


  • *räusper*

    tpais schrieb:

    verzeihung, my fault:

    --Makefile--

    C = g++
    CCFLAGS = -g -O2 -Wall          # debugging and optimizing
    LD = g++                        # oder: LD = ld
    LDFLAGS =
    YACC = yacc
    LOADLIBS = -L/usr/lib64/mysql -l mysqlclient -l boost_regex
    LOADHEADER = -I/usr/include
    MAKE = make
    MAKEARGS = 'SHELL=/bin/sh'
    SHELL = /bin/sh
    RM = /bin/rm
    
    EXE=query
    
    all: $(EXE)
    
    clean:
            -$(RM) *.o $(EXE)
    
    main: main.o
            $(LD) $(CCFLAGS) $(LOADLIBS) $? -o $@
            -chmod 700 main
    
    .SUFFIXES: .cpp .hpp .o
    %.o: %.cpp
            $(CC) $(CCFLAGS) -c $< -o $@
    %.o: %.cpp %.h
            $(CC) $(CCFLAGS) -c $< -o $@
    


  • Bei main: fehlt die options.o



  • Sehr viele Dank.


Anmelden zum Antworten