You are not logged in.

#1 2009-06-21 06:26:35

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Qt compiler error ('system' was not declared...)[SOLVED]

Hi,

This is a very newbie question, but I don't know where to start smile . I've got somebody else's qt4 application; build instructions: (1) run qmake; (2) run make.

On make there's an error:

$ make
g++ -c -pipe -march=i686 -mtune=generic -O2 -pipe -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -Iobj -I. -o obj/cmdthread.o cmdthread.cpp
cmdthread.cpp: In member function 'virtual void CCommandThread::run()':
cmdthread.cpp:29: error: 'system' was not declared in this scope
make: *** [obj/cmdthread.o] Error 1

This is cmdthread.cpp:

#include "cmdthread.h"

CCommandThread::CCommandThread() : QThread()
{
    // TODO
}

void CCommandThread::SetCommand(QString strCmd)
{
    m_strCmd = strCmd;
}

void CCommandThread::run()
{
    m_nResult = system(m_strCmd.toAscii());
}

cmdthread.h:

#include <QThread>

class CCommandThread : public QThread
{
    Q_OBJECT
public:
    CCommandThread();
    void SetCommand(QString strCmd);
    void run();
   
    int m_nResult;

private:
    QString m_strCmd;
};

The project isn't mine, I don't use any development environment and I now nothing about Qt smile . The project is supposed to be a working release (I know, ask the developer, but there's no contact with him). Probably this isn't a very misterions error, but I don't know where to start...

Last edited by Llama (2009-06-21 08:08:36)

Offline

#2 2009-06-21 07:39:28

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: Qt compiler error ('system' was not declared...)[SOLVED]

First thing you should try is to google the error message you got and see if any other people have come across it and have come up with a solution for it.

In this particular case, it seems that cmdthread.cpp is missing a "#include <cstdlib>" which contains the function prototype for system().

If you do compile the application successfully, consider creating a PKGBUILD for it so it can be tracked and later uninstalled with pacman.

Offline

#3 2009-06-21 08:06:16

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: Qt compiler error ('system' was not declared...)[SOLVED]

foutrelis wrote:

First thing you should try is to google the error message] you got and see if any other people have come across it and have come up with a solution for it.

In this particular case, it seems that cmdthread.cpp is missing a "#include <cstdlib>" which contains the function prototype for system().

Right you are smile . Thanks! I never expected to find a specific recipe for so generic an error.

Offline

Board footer

Powered by FluxBB