Re: separate compilation

Sorry, I intended to write my former post using HTML by I forgot to break the


My question is simple. Suppouse we've got three files: two containing the
code for the main window and its header file and another one containing the
main procedure. Our goal is to create the main window's object file and the
execuble file with a makefile this way:

GTKMM_INCLUDE=`pkg-config --cflags gtkmm-2.4`
GTKMM_LIB=`pkg-config --libs gtkmm-2.4`

main: main.cpp mainwindow.o
   $(CXX) $(GTKMM_INCLUDE) $(GTKMM_LIB) $^ -o $@
mainwindow.o: mainwindow.cpp mainwindow.h
   $(CXX) -c $(GTKMM_INCLUDE) $^ -o $@

Main windows's files are like these:


#include class MainWindow : public Gtk::Window
      virtual ~MainWindow();


#include "mainwindow.h"
using namespace Gtk;

MainWindow::MainWindow() : public Window() { }
MainWindow::~MainWindow() { }


#include <gtkmm/main.h>
#include "mainwindow.h"
using namespace Gtk;

int main(int argc, char* argv[])
   Main app(argc, argv);
   MainWindow wnd;;
   return 0;

Well, gcc v4.3.3 compiles correctly the main windows's files and creates the
corresponding object file but the linker complains. This is the error that
the linker reports:
mainwindow.o: file not recognized : File format not recognized
collect2: ld returned 1 exit status.

¿Why on earth such a simple example fails to compile?

Thanks in advance.
View this message in context:
Sent from the Gtkmm mailing list archive at

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