PDA

View Full Version : A program perfectly working on Win does not build on Mac



mchome
19th July 2012, 10:43
I have a small program composed by two cpp modules, and a unique signal/slot connection.

It compiles and runs perfectly in Win7 under Qt Creator 2.4.1/qt 4.8.1/MSVC2010.

Instead, in a Max Os X, using QtCreator 2.4.1/qt 4.8.1/gcc, I get the following strange error messages.

In issues:
:-1: error: symbol(s) not found for architecture x86_64
:-1: error: collect2: ld returned 1 exit status

In compile output:
ld: warning: directory not found for option '-L/usr/local/pgsql/lib'
ld: warning: directory not found for option '-L/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib'
ld: warning: directory not found for option '-F/tmp/qt-stuff-85167/source/qt-everywhere-opensource-src-4.8.1/Desktop/Qt/4.8.1/gcc/lib'
Undefined symbols for architecture x86_64:
"vtable for CLineChart", referenced from:
CLineChart::CLineChart(QWidget*)in clinechart.o
CLineChart::CLineChart(QWidget*)in clinechart.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"CLineChart::staticMetaObject", referenced from:
CLineChart::tr(char const*, char const*)in clinechart.o
"CLineChart::valuesChanged(SXYValues, bool, bool)", referenced from:
CLineChart::mouseMoveEvent(QMouseEvent*) in clinechart.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [TestLineChart.app/Contents/MacOS/TestLineChart] Error 1
make: Leaving directory `/Users/ceraolo/Documents/C++/TestLineChartAAA'
11:09:15: The process "/usr/bin/make" exited with code 2.
Error while building project TestLineChart (target: Desktop)
When executing build step 'Make'


I've verified that if I eliminate all slots and signals but leave the QT_OBJECT macro in the code the problem is still there.
When I comment out the QT_OBJECT also the program compiles and links, but, obviously I lose important functionality.

Any suggestions?

wysota
19th July 2012, 11:35
It's Q_OBJECT, not QT_OBJECT. Make distclean, qmake, make.

mchome
19th July 2012, 23:02
My message was wrong but the issue is related to the correct spelling Q_OBJECT.
In fact, as I mentioned, with this keyword included, my program under Windows compiles, builds and runs perfectly.
Under Mac causes that error message.

MC

My message was wrong but the issue is related to the correct spelling Q_OBJECT.
In fact, as I mentioned, with this keyword included, my program under Windows compiles, builds and runs perfectly.
Under Mac causes that error message.

MC

Added after 4 minutes:

My message was wrong but the issue is related to the correct spelling Q_OBJECT.
In fact, as I mentioned, with this keyword included, my program under Windows compiles, builds and runs perfectly.
Under Mac causes that error message.

Make distclean, qmake, make

I will try tomorrow.

Added after 40 minutes:

I could not want until tomorrow.
I tried the cleaning up you suggested and... voilà , it works!

I've also understood what caused that mess.
In the same computer I've Mac OS and Win7 systems. I don' have to reboot to switch between the two, since I use Parallels Desktop that makes windows 7 run in virtual machine.

But I dared too much: I used to recompile the same source code with the two systems, without first copying it into a different folder. It resulted that the two compilation processes created files that were somewhat incompatible

From now I will use a different technique.
Normally I will work in Mac, with files in a folder dedicated to mac compilation. From time to time, to be sure about the program functionality and look and feel under Windows, I will copy the source files in a folder dedicated to Win compilation and compile under Windows.

This way I should avoid to repeat the same mistake.

Thank you for your suggestion.

MC

I could not want until tomorrow.
I tried the cleaning up you suggested and... voilà , it works!

I've also understood what caused that mess.
In the same computer I've Mac OS and Win7 systems. I don' have to reboot to switch between the two, since I use Parallels Desktop that makes windows 7 run in virtual machine.

But I dared too much: I used to recompile the same source code with the two systems, without first copying it into a different folder. It resulted that the two compilation processes created files that were somewhat incompatible

From now I will use a different technique.
Normally I will work in Mac, with files in a folder dedicated to mac compilation. From time to time, to be sure about the program functionality and look and feel under Windows, I will copy the source files in a folder dedicated to Win compilation and compile under Windows.

This way I should avoid to repeat the same mistake.

Thank you for your suggestion.

MC