Jump to content

C++ compiling problems


Guest davemandrake
 Share

Recommended Posts

Guest davemandrake

can someone please tell me what I am doing wrong?

 

I keep getting errors when I try to compile the following code:

 

I'm using one of the examples in the QT3 examples help file to find out what is wrong.

 

error message:

[dave@dave metricsource]$ /usr/lib/qt3/bin/qmake -o makefile metric.pro

[dave@dave metricsource]$ make

/bin/uic conversionform.ui -o .ui/conversionform.h

make: /bin/uic: Command not found

make: *** [.ui/conversionform.h] Error 127

[dave@dave metricsource]$

 

Makefile:

#############################################################################

# Makefile for building: metric

# Generated by qmake (1.04a) (Qt 3.1.1) on: Mon Jul 28 21:43:17 2003

# Project:  metric.pro

# Template: app

# Command: $(QMAKE) -o makefile metric.pro

#############################################################################



####### Compiler, tools and options



CC       = gcc

CXX      = g++

LEX      = flex

YACC     = yacc

CFLAGS   = -pipe -Wall -W -O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro  -DQT_NO_DEBUG

CXXFLAGS = -pipe -Wall -W -O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro  -DQT_NO_DEBUG

LEXFLAGS = 

YACCFLAGS= -d

INCPATH  = -I/usr/lib/qt3//mkspecs/default -I. -I$(QTDIR)/include -I.ui/ -I.moc/

LINK     = g++

LFLAGS   = 

LIBS     = $(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm

AR       = ar cqs

RANLIB   = 

MOC      = $(QTDIR)/bin/moc

UIC      = $(QTDIR)/bin/uic

QMAKE    = qmake

TAR      = tar -cf

GZIP     = gzip -9f

COPY     = cp -f

COPY_FILE= $(COPY) -p

COPY_DIR = $(COPY) -pR

DEL_FILE = rm -f

SYMLINK  = ln -sf

DEL_DIR  = rmdir

MOVE     = mv -f

CHK_DIR_EXISTS= test -d

MKDIR    = mkdir -p



####### Output directory



OBJECTS_DIR = .obj/



####### Files



HEADERS = 

SOURCES = main.cpp

OBJECTS = .obj/main.o 

 .obj/conversionform.o

FORMS = conversionform.ui

UICDECLS = .ui/conversionform.h

UICIMPLS = .ui/conversionform.cpp

SRCMOC   = .moc/moc_conversionform.cpp

OBJMOC = .obj/moc_conversionform.o

DIST    = metric.pro

QMAKE_TARGET = metric

DESTDIR  = 

TARGET   = metric



first: all

####### Implicit rules



.SUFFIXES: .c .cpp .cc .cxx .C



.cpp.o:

$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<



.cc.o:

$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<



.cxx.o:

$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<



.C.o:

$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<



.c.o:

$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<



####### Build rules



all: makefile $(TARGET)



$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) 

$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)



mocables: $(SRCMOC)



$(MOC): 

( cd $(QTDIR)/src/moc; $(MAKE) )



makefile: metric.pro  /usr/lib/qt3//mkspecs/default/qmake.conf 

$(QMAKE) -o makefile metric.pro

qmake: 

@$(QMAKE) -o makefile metric.pro



dist: 

@mkdir -p .obj/metric && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .obj/metric/ && $(COPY_FILE) --parents conversionform.ui.h .obj/metric/ && ( cd `dirname .obj/metric` && $(TAR) metric.tar metric && $(GZIP) metric.tar ) && $(MOVE) `dirname .obj/metric`/metric.tar.gz . && $(DEL_FILE) -r .obj/metric



mocclean:

-$(DEL_FILE) $(OBJMOC)

-$(DEL_FILE) $(SRCMOC)



uiclean:

-$(DEL_FILE) $(UICIMPLS) $(UICDECLS)



yaccclean:

lexclean:

clean: mocclean uiclean

-$(DEL_FILE) $(OBJECTS) 

-$(DEL_FILE) *~ core *.core





####### Sub-libraries



distclean: clean

-$(DEL_FILE) $(TARGET) $(TARGET)





FORCE:



####### Compile



.obj/main.o: main.cpp .ui/conversionform.h

$(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/main.o main.cpp



.ui/conversionform.h: conversionform.ui 

$(UIC) conversionform.ui -o .ui/conversionform.h



.ui/conversionform.cpp: .ui/conversionform.h conversionform.ui 

$(UIC) conversionform.ui -i conversionform.h -o .ui/conversionform.cpp



.obj/conversionform.o: .ui/conversionform.cpp conversionform.ui.h 

 .ui/conversionform.h

$(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/conversionform.o .ui/conversionform.cpp



.obj/moc_conversionform.o: .moc/moc_conversionform.cpp .ui/conversionform.h 

$(CXX) -c $(CXXFLAGS) $(INCPATH) -o .obj/moc_conversionform.o .moc/moc_conversionform.cpp



.moc/moc_conversionform.cpp: $(MOC) .ui/conversionform.h

$(MOC) .ui/conversionform.h -o .moc/moc_conversionform.cpp



####### Install



install: all 



uninstall:

 

Project file:

SOURCES	+= main.cpp

unix {

 UI_DIR = .ui

 MOC_DIR = .moc

 OBJECTS_DIR = .obj

}

FORMS	= conversionform.ui

TEMPLATE	=app

CONFIG	+= qt warn_on release

LANGUAGE	= C++

 

 

Conversionform.ui

<!DOCTYPE UI><UI version="3.1" stdsetdef="1">

<class>ConversionForm</class>

<widget class="QDialog">

   <property name="name">

       <cstring>ConversionForm</cstring>

   </property>

   <property name="geometry">

       <rect>

           <x>0</x>

           <y>0</y>

           <width>328</width>

           <height>221</height>

       </rect>

   </property>

   <property name="caption">

       <string>Metric Conversion</string>

   </property>

   <vbox>

       <property name="name">

           <cstring>unnamed</cstring>

       </property>

       <widget class="QLayoutWidget">

           <property name="name">

               <cstring>layout4</cstring>

           </property>

           <grid>

               <property name="name">

                   <cstring>unnamed</cstring>

               </property>

               <widget class="QSpinBox" row="4" column="5">

                   <property name="name">

                       <cstring>decimalsSpinBox</cstring>

                   </property>

                   <property name="maxValue">

                       <number>6</number>

                   </property>

                   <property name="value">

                       <number>3</number>

                   </property>

               </widget>

               <spacer row="3" column="1" rowspan="1" colspan="4">

                   <property name="name">

                       <cstring>spacer8</cstring>

                   </property>

                   <property name="orientation">

                       <enum>Horizontal</enum>

                   </property>

                   <property name="sizeType">

                       <enum>Expanding</enum>

                   </property>

                   <property name="sizeHint">

                       <size>

                           <width>51</width>

                           <height>20</height>

                       </size>

                   </property>

               </spacer>

               <widget class="QLabel" row="3" column="0">

                   <property name="name">

                       <cstring>textLabel4</cstring>

                   </property>

                   <property name="text">

                       <string>Results:</string>

                   </property>

                   <property name="buddy" stdset="0">

                       <cstring>resultLineEdit</cstring>

                   </property>

               </widget>

               <widget class="QLineEdit" row="0" column="5">

                   <property name="name">

                       <cstring>numberLineEdit</cstring>

                   </property>

                   <property name="alignment">

                       <set>AlignRight</set>

                   </property>

               </widget>

               <widget class="QLabel" row="0" column="0" rowspan="1" colspan="4">

                   <property name="name">

                       <cstring>textLabel1</cstring>

                   </property>

                   <property name="text">

                       <string>Enter &Number:</string>

                   </property>

                   <property name="buddy" stdset="0">

                       <cstring>numberLineEdit</cstring>

                   </property>

               </widget>

               <widget class="QComboBox" row="2" column="5">

                   <item>

                       <property name="text">

                           <string>Miles</string>

                       </property>

                   </item>

                   <item>

                       <property name="text">

                           <string>Yards</string>

                       </property>

                   </item>

                   <item>

                       <property name="text">

                           <string>Feet</string>

                       </property>

                   </item>

                   <item>

                       <property name="text">

                           <string>Inches</string>

                       </property>

                   </item>

                   <property name="name">

                       <cstring>toComboBox</cstring>

                   </property>

               </widget>

               <widget class="QLabel" row="1" column="0" rowspan="1" colspan="4">

                   <property name="name">

                       <cstring>textLabel2</cstring>

                   </property>

                   <property name="text">

                       <string>Convert &From:</string>

                   </property>

                   <property name="buddy" stdset="0">

                       <cstring>fromComboBox</cstring>

                   </property>

               </widget>

               <widget class="QComboBox" row="1" column="5">

                   <item>

                       <property name="text">

                           <string>Kilometers</string>

                       </property>

                   </item>

                   <item>

                       <property name="text">

                           <string>Meters</string>

                       </property>

                   </item>

                   <item>

                       <property name="text">

                           <string>Centimeters</string>

                       </property>

                   </item>

                   <item>

                       <property name="text">

                           <string>Millimeters</string>

                       </property>

                   </item>

                   <property name="name">

                       <cstring>fromComboBox</cstring>

                   </property>

               </widget>

               <spacer row="0" column="4">

                   <property name="name">

                       <cstring>spacer7</cstring>

                   </property>

                   <property name="orientation">

                       <enum>Horizontal</enum>

                   </property>

                   <property name="sizeType">

                       <enum>Expanding</enum>

                   </property>

                   <property name="sizeHint">

                       <size>

                           <width>21</width>

                           <height>20</height>

                       </size>

                   </property>

               </spacer>

               <widget class="QLabel" row="2" column="0" rowspan="1" colspan="3">

                   <property name="name">

                       <cstring>textLabel3</cstring>

                   </property>

                   <property name="text">

                       <string>Convert &To:</string>

                   </property>

                   <property name="buddy" stdset="0">

                       <cstring>toComboBox</cstring>

                   </property>

               </widget>

               <spacer row="2" column="3" rowspan="1" colspan="2">

                   <property name="name">

                       <cstring>spacer9</cstring>

                   </property>

                   <property name="orientation">

                       <enum>Horizontal</enum>

                   </property>

                   <property name="sizeType">

                       <enum>Expanding</enum>

                   </property>

                   <property name="sizeHint">

                       <size>

                           <width>30</width>

                           <height>20</height>

                       </size>

                   </property>

               </spacer>

               <spacer row="4" column="2" rowspan="1" colspan="3">

                   <property name="name">

                       <cstring>spacer2</cstring>

                   </property>

                   <property name="orientation">

                       <enum>Horizontal</enum>

                   </property>

                   <property name="sizeType">

                       <enum>Expanding</enum>

                   </property>

                   <property name="sizeHint">

                       <size>

                           <width>40</width>

                           <height>20</height>

                       </size>

                   </property>

               </spacer>

               <widget class="QLineEdit" row="3" column="5">

                   <property name="name">

                       <cstring>resultLineEdit</cstring>

                   </property>

                   <property name="paletteBackgroundColor">

                       <color>

                           <red>249</red>

                           <green>249</green>

                           <blue>0</blue>

                       </color>

                   </property>

                   <property name="alignment">

                       <set>AlignRight</set>

                   </property>

               </widget>

               <spacer row="1" column="4">

                   <property name="name">

                       <cstring>spacer10</cstring>

                   </property>

                   <property name="orientation">

                       <enum>Horizontal</enum>

                   </property>

                   <property name="sizeType">

                       <enum>Expanding</enum>

                   </property>

                   <property name="sizeHint">

                       <size>

                           <width>21</width>

                           <height>20</height>

                       </size>

                   </property>

               </spacer>

               <widget class="QLabel" row="4" column="0" rowspan="1" colspan="2">

                   <property name="name">

                       <cstring>textLabel5</cstring>

                   </property>

                   <property name="text">

                       <string>&Decimals:</string>

                   </property>

                   <property name="buddy" stdset="0">

                       <cstring>decimalsSpinBox</cstring>

                   </property>

               </widget>

           </grid>

       </widget>

       <widget class="QLayoutWidget">

           <property name="name">

               <cstring>layout6</cstring>

           </property>

           <grid>

               <property name="name">

                   <cstring>unnamed</cstring>

               </property>

               <spacer row="1" column="3">

                   <property name="name">

                       <cstring>spacer11</cstring>

                   </property>

                   <property name="orientation">

                       <enum>Horizontal</enum>

                   </property>

                   <property name="sizeType">

                       <enum>Expanding</enum>

                   </property>

                   <property name="sizeHint">

                       <size>

                           <width>20</width>

                           <height>20</height>

                       </size>

                   </property>

               </spacer>

               <spacer row="1" column="1">

                   <property name="name">

                       <cstring>spacer5</cstring>

                   </property>

                   <property name="orientation">

                       <enum>Horizontal</enum>

                   </property>

                   <property name="sizeType">

                       <enum>Expanding</enum>

                   </property>

                   <property name="sizeHint">

                       <size>

                           <width>20</width>

                           <height>20</height>

                       </size>

                   </property>

               </spacer>

               <spacer row="0" column="2">

                   <property name="name">

                       <cstring>spacer6</cstring>

                   </property>

                   <property name="orientation">

                       <enum>Vertical</enum>

                   </property>

                   <property name="sizeType">

                       <enum>Expanding</enum>

                   </property>

                   <property name="sizeHint">

                       <size>

                           <width>20</width>

                           <height>20</height>

                       </size>

                   </property>

               </spacer>

               <widget class="QPushButton" row="1" column="2">

                   <property name="name">

                       <cstring>calculatePushButton</cstring>

                   </property>

                   <property name="text">

                       <string>Calculate</string>

                   </property>

                   <property name="default">

                       <bool>true</bool>

                   </property>

               </widget>

               <widget class="QPushButton" row="1" column="0">

                   <property name="name">

                       <cstring>clearPushButton</cstring>

                   </property>

                   <property name="text">

                       <string>&Clear</string>

                   </property>

               </widget>

               <widget class="QPushButton" row="1" column="4">

                   <property name="name">

                       <cstring>quitPushButton</cstring>

                   </property>

                   <property name="text">

                       <string>&Quit</string>

                   </property>

               </widget>

           </grid>

       </widget>

   </vbox>

</widget>

<connections>

   <connection>

       <sender>clearPushButton</sender>

       <signal>clicked()</signal>

       <receiver>numberLineEdit</receiver>

       <slot>clear()</slot>

   </connection>

   <connection>

       <sender>clearPushButton</sender>

       <signal>clicked()</signal>

       <receiver>resultLineEdit</receiver>

       <slot>clear()</slot>

   </connection>

   <connection>

       <sender>clearPushButton</sender>

       <signal>clicked()</signal>

       <receiver>numberLineEdit</receiver>

       <slot>setFocus()</slot>

   </connection>

   <connection>

       <sender>quitPushButton</sender>

       <signal>clicked()</signal>

       <receiver>ConversionForm</receiver>

       <slot>close()</slot>

   </connection>

   <connection>

       <sender>calculatePushButton</sender>

       <signal>clicked()</signal>

       <receiver>ConversionForm</receiver>

       <slot>convert()</slot>

   </connection>

   <connection>

       <sender>decimalsSpinBox</sender>

       <signal>valueChanged(int)</signal>

       <receiver>ConversionForm</receiver>

       <slot>convert()</slot>

   </connection>

   <connection>

       <sender>fromComboBox</sender>

       <signal>activated(int)</signal>

       <receiver>ConversionForm</receiver>

       <slot>convert()</slot>

   </connection>

   <connection>

       <sender>toComboBox</sender>

       <signal>activated(int)</signal>

       <receiver>ConversionForm</receiver>

       <slot>convert()</slot>

   </connection>

</connections>

<tabstops>

   <tabstop>numberLineEdit</tabstop>

   <tabstop>fromComboBox</tabstop>

   <tabstop>toComboBox</tabstop>

   <tabstop>resultLineEdit</tabstop>

   <tabstop>decimalsSpinBox</tabstop>

   <tabstop>clearPushButton</tabstop>

   <tabstop>calculatePushButton</tabstop>

   <tabstop>quitPushButton</tabstop>

</tabstops>

<includes>

   <include location="local" impldecl="in implementation">conversionform.ui.h</include>

</includes>

<slots>

   <slot>convert()</slot>

</slots>

<functions>

   <function access="private" specifier="non virtual">init()</function>

</functions>

<pixmapinproject/>

<layoutdefaults spacing="6" margin="11"/>

</UI>

 

conversionform.ui.h

/****************************************************************************

** ui.h extension file, included from the uic-generated form implementation.

**

** If you wish to add, delete or rename functions or slots use

** Qt Designer which will update this file, preserving your code. Create an

** init() function in place of a constructor, and a destroy() function in

** place of a destructor.

*****************************************************************************/





void ConversionForm::convert()

{

       enum MetricUnits {

           Kilometers,

           Meters,

           Centimeters,

           Millimeters

       };

       enum OldUnits {

           Miles,

           Yards,

           Feet,

           Inches

       };



       // Retrieve the input

       double input = numberLineEdit->text().toDouble();

       double scaledInput = input;



       // internally convert the input to millimeters

       switch ( fromComboBox->currentItem() ) {

       case Kilometers:

           scaledInput *= 1000000;

           break;

       case Meters:

           scaledInput *= 1000;

           break;

       case Centimeters:

           scaledInput *= 10;

           break;

       }



       //convert to inches

       double result = scaledInput * 0.0393701;



       switch ( toComboBox->currentItem() ) {

       case Miles:

           result /= 63360;

           break;

       case Yards:

           result /= 36;

           break;

       case Feet:

           result /= 12;

           break;

       }



       // set the result

       int decimals = decimalsSpinBox->value();

       resultLineEdit->setText( QString::number( result, 'f', decimals ) );

       numberLineEdit->setText( QString::number( input, 'f', decimals ) );

}



void ConversionForm::init()

{

   numberLineEdit->setValidator( new QDoubleValidator( numberLineEdit ) );

   numberLineEdit->setText( "10" );

   convert();

   numberLineEdit->selectAll();

}

 

main.cpp

#include <qapplication.h>

#include "conversionform.h"



int main( int argc, char ** argv )

{

   QApplication a( argc, argv );

   ConversionForm w;

   w.show();

   a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );

   return a.exec();

}

Link to comment
Share on other sites

uic is a program that comes with the QT development library. Check to make sure you have the proper libqtX-devel library installed. replace the X with 2 or 3 as appropriate for the version of QT you have installed.

 

Glitz.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...