I keep getting this error:

debug/moc_funccntrlparams.o: In function `qt_noop()':
/home/f07/xxx/QT/include/QtCore/qglobal.h:1425: multiple definition of `FuncCntrlParams::type_pairPotList'
debug/interpotcntrlparams.o:/net/home/f07/xxx/workspace/tramontoGUI/interpotcntrlparams.cpp:95: first defined here

But I'm not defining type_pairPotList any where in the interpotcntrlparams.cpp file. This is what my code looks like at line 95 in interpotcntrlparams.cpp.

#include "funccntrlparams.h"
.
.
//line 91
void InterPotCntrlParams::surfUpdate(int newSurfNum)
{
	confIpot_wf_nLayout(newSurfNum);
}

The only place i ever reference type_pairPotList in interpotcntrlparams.cpp is here:

void InterPotCntrlParams::confIpot_wf_nLayout(int newNumOfSurfaces)
{
.
.
for(int i=ipot_wf_nComboVector->size(); i<newNumOfSurfaces; i++)
		{
			surfNumCombo->addItem(QString("Surface %1").arg(i+1));

			ipot_wf_nComboVector->push_back(new QComboBox());
			(ipot_wf_nComboVector->back())->addItems(FuncCntrlParams::type_pairPotList);
			ipot_wf_nGrid->addWidget(ipot_wf_nComboVector->back(),0,1);
			ipot_wf_nComboVector->back()->hide();
		}
.
.
}

This is where I actually declare and define type_pairPotList:

//funccntrlparams.h
.
.
.
class FuncCntrlParams : public QWidget
{
	Q_OBJECT
	
public:
	/**
	 * Constructs a new FuncCntrlParams QWidget.
	 */
	FuncCntrlParams(QWidget *parent=0);
	static QStringList type_pairPotList;
};

QStringList FuncCntrlParams::type_pairPotList = QStringList() << "Pair LJ12-6 CS" << "Pair Coulomb CS" << "Pair Coulomb" << "Pair Yukawa CS";

Does anyone know why I am getting this error?

It's a shot in the dark, but if you include a .h or .cpp file more than once and don't do something like this:

#ifndef ...
#define ...
// code
#endif

you could get that error. I'm not saying that is the cause here, but it's something to consider.

Yea, I already have those in the .h file. I tried something new though. I took the reference to type_pairPotList out of interpotcntrlparams.cpp and I still got the error. This time it was this:

debug/mymetawindow.o: In function `qt_noop()':
/home/f07/xxx/QT/include/QtCore/qglobal.h:1425: multiple definition of `FuncCntrlParams::type_pairPotList'
make[1]: Leaving directory `/net/home/f07/xxx/workspace/tramontoGUI'
debug/funccntrlparams.o:/home/f07/xxxx/QT/include/QtCore/qglobal.h:1425: first defined here
debug/moc_funccntrlparams.o: In function `qt_noop()':
/home/f07/xxx/QT/include/QtCore/qglobal.h:1425: multiple definition of `FuncCntrlParams::type_pairPotList'
debug/funccntrlparams.o:/home/f07/xxx/QT/include/QtCore/qglobal.h:1425: first defined here

So it would seem like the problem is squarely located in my funcctnrlparams.h file. Here's that file with a little more detail:

#ifndef FUNCCNTRLPARAMS_H_
#define FUNCCNTRLPARAMS_H_

#include <QWidget>
#include <QStringList>
class FuncCntrlParams : public QWidget
{
	Q_OBJECT
	
public:
	/**
	 * Constructs a new FuncCntrlParams QWidget.
	 */
	FuncCntrlParams(QWidget *parent=0);
	static QStringList type_pairPotList;
};

QStringList FuncCntrlParams::type_pairPotList = QStringList() << "Pair LJ12-6 CS" << "Pair Coulomb CS" << "Pair Coulomb" << "Pair Yukawa CS";
#endif /*FUNCCNTRLPARAMS_H_*/

Move the definition of QStringList FuncCntrlParams::type_pairPotList into the respective .cpp file.

I can't do that. I have to define it in the header file or else I get this error:

net/home/f07/xxx/workspace/tramontoGUI/interpotcntrlparams.cpp:48: undefined reference to `FuncCntrlParams::type_pairPotList'

I can't do that. I have to define it in the header file or else I get this error:

You need to #include the respective header file in interpotcntrlparams.cpp.

You need to #include the respective header file in interpotcntrlparams.cpp.

Yea I did do that.
interpotcntrlparams.cpp

//interpotcntrlparams.cpp
#include "interpotcntrlparams.h"
#include "surfcntrlparams.h"
#include "funccntrlparams.h"
.
.
.

And I still get the error:

net/home/f07/xxx/workspace/tramontoGUI/interpotcntrlparams.cpp:48: undefined reference to `FuncCntrlParams::type_pairPotList'

I figured it out. The problem was that I was defining type_pairPotList in the constructor of FuncCntrlParams. Like this:

//funcntrlparams.cpp
.
.
FuncCntrlParams::FuncCntrlParams(QWidget *parent)
	:QWidget(parent)
{
	QStringList type_pairPotList = QStringList() << "Pair LJ12-6 CS" << "Pair Coulomb CS" << "Pair Coulomb" << "Pair Yukawa CS";
.
.
}
.
.

Once I took it out of the constructor like this:

//funcntrlparams.cpp
.
.
QStringList type_pairPotList = QStringList() << "Pair LJ12-6 CS" << "Pair Coulomb CS" << "Pair Coulomb" << "Pair Yukawa CS";
FuncCntrlParams::FuncCntrlParams(QWidget *parent)
	:QWidget(parent)
{
.
.
}
.
.

Everything worked.
Thanks for bearing with me mitrmkar. I'm still transitioning from Java and I think because of my Java mindset I figured since I'd already declared the variable outside of the constructor, the only place to define it now would be in the constructor.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.