Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7863635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:32:44+00:00 2026-06-02T23:32:44+00:00

I’m trying to compile a small application using Qt but without using QMake, but

  • 0

I’m trying to compile a small application using Qt but without using QMake, but whenever I try to run it, I get the following error message:

g++ -c -g -pg -Wall -Wextra -pipe   -c -o ../../MOCFiles/moc_projectModel.o ../../MOCFiles/moc_projectModel.cpp
In file included from ../../MOCFiles/moc_projectModel.cpp:10:0:
../../MOCFiles/../Src/ProjectStructure/projectModel.h:4:30: fatal error: QAbstractItemModel: No such file or directory
compilation terminated.
make: *** [../../MOCFiles/moc_projectModel.o] Error 1

This would seem to suggest that I haven’t constructed my $(INCLUDE) variable properly, but it is as follows:

INCLUDE   = -I/usr/include/qt4 \
            -I/usr/include/qt4/QtGui \
            -I/usr/include/qt4/QtCore \
            -I/usr/include/qt4/QtXml \
            -I/usr/share/qt4/mkspecs/linux-g++ \
            -I../../Src/ProjectStructure 

and I am able to locate the QAbstractItemModel file in /usr/include/qt4/QtCore/, a directory which is part of my include variable. This is my first time writing a GNU Makefile and I’m not sure what it is I’m doing wrong. For reference, the entire file is included here:

CXX       = g++
CXXFLAGS  = -c -g -pg -Wall -Wextra -pipe
LINK      = g++

LIBS      = -L/usr/lib \
            -L/usr/lib/i386-linux-gnu \
            -lgtest \
            -lQtGui \
            -lQtCore \
            -lQtXml \
            -lpthread

INCLUDE   = -I/usr/include/qt4 \
            -I/usr/include/qt4/QtGui \
            -I/usr/include/qt4/QtCore \
            -I/usr/include/qt4/QtXml \
            -I/usr/share/qt4/mkspecs/linux-g++ \
            -I../../Src/ProjectStructure

OBJECTS = ../Objects/main.o \
          ../Objects/test_projectEntity.o \
          ../Objects/moc_test_projectModel.o \
          ../../Objects/projectEntity.o \
          ../../Objects/projectModel.o \
          ../../MOCFiles/moc_projectModel.o

../../Binaries/tests: $(OBJECTS)
  $(LINK) $^ $(LIBS) -o $@

../Objects/main.o : ../Src/main.cpp
  $(CXX) $(CXXFLAGS) $(INCLUDE) ../Src/main.cpp -o ../Objects/main.o

../Objects/moc_test_projectModel.o : ../MOCFiles/moc_test_projectModel.cpp
  $(CXX) $(CXXFLAGS) $(INCLUDE) ../MOCFiles/moc_test_projectModel.cpp -o ../Objects/moc_test_projectModel.o

../../MOCFiles/moc_test_projectModel.cpp :  ../Src/test_projectModel.cpp
  moc ../Src/test_projectModel.cpp -o ../MOCFiles/moc_test_projectModel.cpp

../Objects/test_projectEntity.o : ../Src/test_projectEntity.cpp
  $(CXX) $(CXXFLAGS) $(INCLUDE) ../Src/test_projectEntity.cpp -o ../Objects/test_projectEntity.o

clean:
  rm -f ../Objects/main.o ../Objects/test_projectEntity.o ../Objects/test_projectModel.o
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:32:45+00:00Added an answer on June 2, 2026 at 11:32 pm

    It looks as if you’re trying to build ../../Binaries/tests. One of the preqs is ../../MOCFiles/moc_projectModel.o, but there’s no explicit rule for building that, so Make uses the implicit rule and attempts this:

    g++ -c -g -pg -Wall -Wextra -pipe   -c -o ../../MOCFiles/moc_projectModel.o ../../MOCFiles/moc_projectModel.cpp
    

    Notice that there’s no mention of INCLUDE there. So g++ doesn’t know to look in /usr/include/qt4/QtCore/. The simple solution is to add a rule:

    ../../MOCFiles/moc_projectModel.o : ../../MOCFiles/moc_projectModel.cpp
        $(CXX) $(CXXFLAGS) $(INCLUDE) $< -o $@
    

    Notice that I used automatic variables $< and $@ there, to reduce redundancy and clutter. We could also make it into a pattern rule:

    ../../MOCFiles/%.o : ../../MOCFiles/%.cpp
        $(CXX) $(CXXFLAGS) $(INCLUDE) $< -o $@
    

    This takes care of moc_projectModel.o and anything else that has the same pattern (source and object both in MOCFiles/). We could make other improvements, but that should be enough to get you up and running.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.