Link error with extern PI

Hi all-

I'm trying to compile an app that links to OCC on MinGW. When linking I get the following error:

g++ -c -g -g -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -D_DEBUG -DWNT -DWIN32 -D_WINDOWS -DQT_NEEDS_QMAIN -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD
_SUPPORT -I"C:/Qt/4.2.2/include/QtCore" -I"C:/Qt/4.2.2/include/QtCore" -I"C:/Qt/4.2.2/include/QtGui" -I"C:/Qt/4.2.2/include/QtGui" -I"C:/Qt/4.2.2/include" -I"C:/occ/win32
/ros/inc" -I"C:/Qt/4.2.2/include/ActiveQt" -I"debug" -I"." -I"c:\Qt\4.2.2\mkspecs\default" -o debug\aavApplication.o aavApplication.cpp
In file included from C:/occ/win32/ros/inc/Standard_PrimitiveTypes.hxx:23,
from C:/occ/win32/ros/inc/Handle_Standard_Transient.hxx:10,
from C:/occ/win32/ros/inc/Handle_MMgt_TShared.hxx:33,
from C:/occ/win32/ros/inc/Handle_AIS_InteractiveContext.hxx:33,
from C:/occ/win32/ros/inc/AIS_InteractiveContext.hxx:30,
from aavInclude.h:18,
from aavApplication.h:5,
from aavApplication.cpp:3:
C:/occ/win32/ros/inc/Standard_Real.hxx:28: error: duplicate `extern'
C:/occ/win32/ros/inc/Standard_Real.hxx:29: error: duplicate `extern'
C:/occ/win32/ros/inc/Standard_Real.hxx:30: error: duplicate `extern'
C:/occ/win32/ros/inc/Standard_Real.hxx:31: error: duplicate `extern'

The error are pointing to the places in Standard_Real.hxx with the following lines:

#ifdef WNT
extern "C" __Standard_API Standard_Real PI;
extern "C" __Standard_API Standard_Real PI180;
extern "C" __Standard_API Standard_Real Standard_PI;
extern "C" __Standard_API Standard_Real Standard_PI180;
#else

I can't determine where these externs are also being defined. Any help would be greatly appreciated.

Thanks.

P Dolbey's picture

They're defined in Standard_Real.cxx strangely enough.

Have you through about using Qt/Win on sourceforge to "coerce" the GPL'd Qt4 onto VS2003/2005.

Pete

ajselvig's picture

Pete-

I've tried it, but couldn't get it working after several hours, then began to wonder why I was doing it in the first place if it worked just fine on MinGW. Perhaps this is my reason.

Thanks.

P Dolbey's picture

I had no problem with this - what wouldn't work? I may be able to help.

As with some of the other responses, OCC is not supported on MinGW and this may be at the heart of your problem.

Pete

Bearloga's picture

If you compile using g++ then you probably should not define WNT macro. Try instead LINUX.

ajselvig's picture

Ok, I tried defining LINUX instead but it seemed to not want to link to anything anymore. I something like this:

make[1]: Entering directory `M:/avalanche'
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,windows -o "debug\avalanche.exe" debug\aavApp
lication.o debug\main.o debug\mainwindow.o debug\mdichild.o debug\moc_mainwindow.o debug\moc_mdichild.o debug\qrc_mdi.o -L"c:\Qt\4.2.2\lib" -lmingw32 -lqtma
ind -Lc:\occ\win32\ros\win32\lib -lTKCDF -lTKernel -lTKLCAF -lQtGuid4 -lQtCored4
debug\aavApplication.o(.text+0x14b): In function `ZN14aavApplication7FormatsER32TColStd_SequenceOfExtendedString':
M:/avalanche/aavApplication.cpp:9: undefined reference to `TCollection_ExtendedString::TCollection_ExtendedString(char*)'
debug\aavApplication.o(.text+0x164):M:/avalanche/aavApplication.cpp:9: undefined reference to `TColStd_SequenceOfExtendedString::Append(TCollection_ExtendedS
tring const&)'
debug\aavApplication.o(.text$_ZN26TCollection_ExtendedStringD1Ev[TCollection_ExtendedString::~TCollection_ExtendedString()]+0xd): In function `ZNK18Standard_
Transient11GetRefCountEv':
M:/avalanche/aavApplication.cpp: undefined reference to `TCollection_ExtendedString::Destroy()'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x8):M:/avalanche/aavApplication.cpp: undefined reference to `Standard_Transien
t::This() const'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0xc):M:/avalanche/aavApplication.cpp: undefined reference to `Standard_Transien
t::Delete() const'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x18):M:/avalanche/aavApplication.cpp: undefined reference to `TDocStd_Applicat
ion::DynamicType() const'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x1c):M:/avalanche/aavApplication.cpp: undefined reference to `TDocStd_Applicat
ion::IsKind(Handle_Standard_Type const&) const'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x20):M:/avalanche/aavApplication.cpp: undefined reference to `Standard_Transie
nt::HashCode(int) const'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x24):M:/avalanche/aavApplication.cpp: undefined reference to `Standard_Transie
nt::ShallowDump(std::ostream&) const'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x2c):M:/avalanche/aavApplication.cpp: undefined reference to `Standard_Transie
nt::Initialize()'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x30):M:/avalanche/aavApplication.cpp: undefined reference to `TDocStd_Applicat
ion::Resources()'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x34):M:/avalanche/aavApplication.cpp: undefined reference to `CDM_Application:
:MessageDriver()'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x38):M:/avalanche/aavApplication.cpp: undefined reference to `CDM_Application:
:BeginOfUpdate(Handle_CDM_Document const&)'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x3c):M:/avalanche/aavApplication.cpp: undefined reference to `CDM_Application:
:EndOfUpdate(Handle_CDM_Document const&, unsigned int, TCollection_ExtendedString const&)'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x40):M:/avalanche/aavApplication.cpp: undefined reference to `CDF_Application:
:Retrieve(Handle_CDM_MetaData const&, unsigned int)'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x44):M:/avalanche/aavApplication.cpp: undefined reference to `CDF_Application:
:DocumentVersion(Handle_CDM_MetaData const&)'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x4c):M:/avalanche/aavApplication.cpp: undefined reference to `CDF_Application:
:Activate(Handle_CDM_Document const&, CDF_TypeOfActivation)'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x54):M:/avalanche/aavApplication.cpp: undefined reference to `TDocStd_Applicat
ion::NewDocument(TCollection_ExtendedString const&, Handle_TDocStd_Document&)'
debug\aavApplication.o(.rdata$_ZTV14aavApplication[vtable for aavApplication]+0x58):M:/avalanche/aavApplication.cpp: undefined reference to `TDocStd_Applicat
ion::InitDocument(Handle_TDocStd_Document const&) const'
debug\aavApplication.o(.text$_ZN14aavApplicationD1Ev[aavApplication::~aavApplication()]+0x16):M:/avalanche/aavApplication.cpp: undefined reference to `TDocSt
d_Application::~TDocStd_Application()'
debug\aavApplication.o(.text$_ZN19TDocStd_ApplicationdlEPv[TDocStd_Application::operator delete(void*)]+0x13):M:/avalanche/aavApplication.cpp: undefined refe
rence to `Standard::Free(void*&)'
debug\aavApplication.o(.text$_ZN14aavApplicationD0Ev[aavApplication::~aavApplication()]+0x16):M:/avalanche/aavApplication.cpp: undefined reference to `TDocSt
d_Application::~TDocStd_Application()'
debug\main.o(.text$_ZN10MainWindowD1Ev[MainWindow::~MainWindow()]+0x5d): In function `ZN7QStringC1EPKc':
C:/Qt/4.2.2/include/QtCore/../../src/corelib/arch/qatomic_windows.h: undefined reference to `Handle_TDocStd_Application::~Handle_TDocStd_Application()'
debug\mainwindow.o(.text+0x458): In function `ZN10MainWindowC2Ev':
M:/avalanche/mainwindow.cpp:52: undefined reference to `Handle_TDocStd_Application::~Handle_TDocStd_Application()'
debug\mainwindow.o(.text+0x808): In function `ZN10MainWindowC1Ev':
M:/avalanche/mainwindow.cpp:52: undefined reference to `Handle_TDocStd_Application::~Handle_TDocStd_Application()'
debug\mainwindow.o(.text$_ZN14aavApplicationC1Ev[aavApplication::aavApplication()]+0xd): In function `ZNK5QListIP7QWidgetE5beginEv':
C:/Qt/4.2.2/include/QtCore/../../src/corelib/tools/qlist.h: undefined reference to `TDocStd_Application::TDocStd_Application()'
debug\mainwindow.o(.text$_ZN19TDocStd_ApplicationnwEj[TDocStd_Application::operator new(unsigned int)]+0xd):C:/Qt/4.2.2/include/QtCore/../../src/corelib/tool
s/qlist.h: undefined reference to `Standard::Allocate(int)'
debug\moc_mainwindow.o(.text$_ZN10MainWindowD0Ev[MainWindow::~MainWindow()]+0x5d): In function `ZThn8_N10MainWindowD1Ev':
M:/avalanche/debug/moc_mainwindow.cpp: undefined reference to `Handle_TDocStd_Application::~Handle_TDocStd_Application()'
collect2: ld returned 1 exit status
make[1]: *** [debug\avalanche.exe] Error 1
make[1]: Leaving directory `M:/avalanche'
make: *** [debug] Error 2

Has no one ever compiled OCC with Qt on MinGW? That would seem amazing. I think there's something we're missing here.

Thanks, Bearloga.