Re: [gtkmm] Compiling my first gtkmm program - HELP!!



Thanks Matthew for the tip! It worked!
It got rid of all the warnings about not linking against certain files. However, I am still stock at the errors messages problem. Perhaps if it was an error in my code I would be able to do something about it, but the linker tells me that the errors are in some functions I don't even have in my code. I am sorry if I sound as if I am drowning in a cup of water but this is not only my first GTKmm program, it is also my first GUI program. As you can imagine I feel a bit confused about... EVERYTHING!! The program I'm trying to compile is very simple; it is just a window. Because of its simplicity I feel that it is OK to post it within this message and not affect the bandwidth of the its subscribers.

Again, thanks for the helping me before and I hope you will be able to pull me out of the hole... one more time



MAKEFILE
~~~~~~~~
# GTKmm Make file

# Compiler name
CPP=g++

#Libraries to be included
LDLIBS=`pkg-config gtkmm-2.0 --libs`

#Flagas
CFLAGS= -Wall -g `pkg-config gtkmm-2.0 --cflags`

#Objects
OBJS = main.o wimm.o

#Executable
EXEC = wimm.exe

$(EXEC): $(OBJS)
   $(CPP) $(OBJS) $(LDLIBS) -o $(EXEC)

main.o: main.cpp wimm.hpp
   $(CPP) $(CFLAGS) -c main.cpp

wimm.o: wimm.hpp
   $(CPP) $(CFLAGS) -c wimm.cpp
clean:
   rm -f $(OBJS)
   rm -f $(EXEC)

PHONY: clean

MAIN.CPP
~~~~~~~~
#include <gtkmm/main.h>
#include "wimm.hpp"

int main (int argc, char *argv[]){
 Gtk::Main kit(argc, argv);
 jme::Wimm wimm;
 //Shows the window and returns when it is closed.
 Gtk::Main::run(wimm);
 return 0;
}
WIMM.HPP
~~~~~~~~~
#ifndef WIMM_H
#define WIMM_H

#include <gtkmm/button.h>
#include <gtkmm/window.h>
#include <iostream>
namespace jme{
  class Wimm : virtual public Gtk::Window {
     public:
        virtual ~Wimm();

     protected:
  }; //Wimm
} //Namespace
#endif

WIMM.CPP
~~~~~~~~
#ifndef WIMM_H
  #include "wimm.hpp"
#endif
jme::Wimm::~Wimm(){}

Errors
~~~~~~~
wimm.o(.rdata$_ZTVN3jme4WimmE+0x2d8): In function `_ZN3jme4WimmD1Ev':
/home/admin/dev/lib/jme/wimm/wimm.cpp:22: undefined reference to `virtual thunk [v:0,-28] to Gtk::Object::destroy_notify_()' wimm.o(.rdata$_ZTCN3jme4WimmE4_N3Gtk6WindowE+0x2bc):/home/admin/dev/lib/jme/wimm/wimm.cpp:22: undefined reference to `virtual thunk [v:0,-28] to Gtk::Object::destroy_notify_()' wimm.o(.rdata$_ZTCN3jme4WimmE4_N3Gtk3BinE+0x168): In function `_ZN3jme4WimmD2Ev': /home/admin/dev/lib/jme/wimm/wimm.cpp:22: undefined reference to `virtual thunk [v:0,-28] to Gtk::Object::destroy_notify_()' wimm.o(.rdata$_ZTCN3jme4WimmE4_N3Gtk9ContainerE+0x168):/home/admin/dev/lib/jme/wimm/wimm.cpp:22: undefined reference to `virtual thunk [v:0,-28] to Gtk::Object::destroy_notify_()' wimm.o(.rdata$_ZTCN3jme4WimmE4_N3Gtk6WidgetE+0x140):/home/admin/dev/lib/jme/wimm/wimm.cpp:22: undefined reference to `virtual thunk [v:0,-28] to Gtk::Object::destroy_notify_()' wimm.o(.rdata$_ZTCN3jme4WimmE4_N3Gtk6ObjectE+0x50):/home/admin/dev/lib/jme/wimm/wimm.cpp:22: more undefined references to `virtual thunk [v:0,-28] to Gtk::Object::destroy_notify_()' follow Info: resolving vtable for SigC::ObjectBaseby linking to __imp___ZTVN4SigC10ObjectBaseE (auto-import)
collect2: ld returned 1 exit status
make: *** [wimm.exe] Error 1






matthew alledora co uk wrote:

Maya wrote:

Hi folks!!
I have been trying to compile an example program included in the gtkmm documentation, but for some reason I am having a lot of errors and/or warnings displayed.
The Makefile I wrote is this:
------
CPP=g++
LDLIBS=`pkg-config gtkmm-2.0 --libs`
CFLAGS= -Wall -g `pkg-config gtkmm-2.0 --cflags --libs`
OBJS = main.o wimm.o
EXEC = wimm.exe

$(EXEC): $(OBJS)
[TAB]    $(CPP) $(OBJS) $(LDLIBS) -o $(EXEC)

main.o: main.cpp wimm.hpp
[TAB]    $(CPP) $(CFLAGS) -c main.cpp

wimm.o: wimm.hpp
[TAB]    $(CPP) $(CFLAGS) -c wimm.cpp
  clean:
   rm -f $(OBJS)
   rm -f $(EXEC)

PHONY: clean


Change your CFLAGS to:

CFLAGS= -Wall -g `pkg-config gtkmm-2.0 --cflags`

If you use --libs as well, you import the linker flags, which gcc doesn't really like when you're not linking anything - as the messages you posted indicate. They're also completely unnecessary when compiling the object files - you just need the cflags for that.


--
* The media's the most powerful entity on earth. They have the power to make the innocent guilty and to make the guilty innocent, and that's power. - Malcom X

* You cannot exercise your power to a point of humiliation.
                              - Jean Chretien

* It's amazing how the small seeds of distrust and misunderstanding
 can yield a crop of hate and death...

* E-Mail Policy
    http://www.vif.com/users/escalante/Email_Policy.html





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]