Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to build Qt project with auto tools
Forum Updated to NodeBB v4.3 + New Features

How to build Qt project with auto tools

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SulfredLeeS Offline
    SulfredLeeS Offline
    SulfredLee
    wrote on last edited by
    #1

    I have a project built from autotool and I would like to add an ui for it. I would like to combine Qt's stuff into my original project. I make a new Qt Designer Form Class with default setting, mainwindow.cpp, mainwindow.h and mainwindow.ui, but I don't know how to build it. Any one knows how to do it?

    File sturcture
    root/mainwindow.cpp
    root/mainwindow.h
    root/mainwindow.ui

    I have tried to add the following into configure.ac

    # Check for Qt libraries
    PKG_CHECK_MODULES(QT, [QtCore, QtGui, QtNetwork], [], [AC_MSG_ERROR([Qt libraries are required.])])
    
    # Retrieve Qt compilation and linker flags
    CPPFLAGS="`$PKG_CONFIG --cflags-only-I QtCore QtGui QtNetwork` $CPPFLAGS"
    LDFLAGS="`$PKG_CONFIG --libs-only-L QtCore QtGui QtNetwork` $LDFLAGS"
    LIBS="`$PKG_CONFIG --libs-only-l QtCore QtGui QtNetwork` $LIBS"
    
    if ! `$PKG_CONFIG --atleast-version=4.6.0 QtCore`; then
       AC_MSG_ERROR([Qt >= 4.6.0 is required.])
    fi
    
    AC_CHECK_PROGS(MOC, [moc-qt5 moc-qt4 moc])
    AC_CHECK_PROGS(UIC, [uic-qt5 uic-qt4 uic])
    AC_CHECK_PROGS(RCC, [rcc])
     if test -z "$MOC" || test -z "$UIC" || test -z "$RCC"; then
       AC_MSG_ERROR([Qt utility programs moc, uic, and rcc are required.])
    fi
    

    I added the following into Makefile.am

    # qt project stuff
    moc_%.cpp: %.h
    	@MOC@ -o$@ $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(MOC_CPPFLAGS) $<
    
    ui_%.h: %.ui
    	@UIC@ -o $@ $<
    
    qrc_%.cpp: %.qrc
    	@RCC@ -o $@ $<
    

    But I get error

    undefined reference to `vtable for MainWindow'
    

    I found that people said those moc_ files are missing but I don't know how to fix it.

    Anyway, can anyone teach me how to build a Qt project with autotool?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Qt Creator has a plugin for working with Autotools (http://doc.qt.io/qtcreator/creator-projects-autotools.html). Never used this myself but maybe it does what you want.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved