Problem compiling SMILE with GCC on Windows

The engine.
Post Reply
Quirijn
Posts: 7
Joined: Sun May 02, 2010 6:43 pm

Problem compiling SMILE with GCC on Windows

Post by Quirijn »

I am having trouble compiling the tutorial code with GCC on windows. I tried to compile the code with Visual C++ 2008 and the VC 9.0 SP1 library and that gives no problem. However I need to use GCC for compilation.

My GCC version is:

Code: Select all

gcc (TDM-2 mingw32) 4.4.1
I first got the error:

Code: Select all

c:\Bayes\smile/smile.h:26:6: error: #error SMILE : in debug build the runtime li
brary must be set to Multi-threaded Debug DLL
The next thing I did was to specify -DNDEBUG in my GCC command but I still got errors. I deleted this part out of the smile.h file.

Code: Select all

#ifdef _WIN32
    #if (_MSC_VER >= 1400) && defined(NDEBUG) && (!defined(_SECURE_SCL) || _SECURE_SCL != 0)    
		#error SMILE : in release build _SECURE_SCL must be defined and set to zero for VS.NET 2005 or later
    #endif

    #ifndef SMILE_VC_NO_AUTOLINK
        // automatically link with SMILE library
        #ifdef NDEBUG
            #ifdef _DLL
                #pragma comment(lib, "smile_dyn")
            #else
                #pragma comment(lib, "smile")
            #endif 
        #else
			#ifdef _DLL
				#pragma comment(lib, "smile_dbg")
			#else
				#error SMILE : in debug build the runtime library must be set to Multi-threaded Debug DLL 
			#endif
        #endif
    #endif
#endif
I did this because I only saw the libsmile.a file in the smile directory. The GCC command I used:

Code: Select all

g++ -D_DLL -I C:\Bayes -o c:\Bayes\bayes.exe c:\Bayes\bayes.cpp
This gives the errors of this kind:

Code: Select all

C:\DOCUME~1\Quirijn\LOCALS~1\Temp\ccJKOTuf.o:bayes.cpp:(.text$_ZN11DSL_idArrayD1
Ev[DSL_idArray::~DSL_idArray()]+0xb): undefined reference to `vtable for DSL_idA
rray'
C:\DOCUME~1\Quirijn\LOCALS~1\Temp\ccJKOTuf.o:bayes.cpp:(.rdata$_ZTV18DSL_sysCoor
dinates[vtable for DSL_sysCoordinates]+0x8): undefined reference to `DSL_object:
:CleanUp(int)'
collect2: ld returned 1 exit status
I really have no idea what gcc command and procedures I should use to succesfully compile the library. I assume I have to link the libsmile.a file but I have no idea how to do that!

Thanks in advance for the help!
Quirijn
Posts: 7
Joined: Sun May 02, 2010 6:43 pm

Post by Quirijn »

A small update. I changed my GCC version to 4.4.0 to make it compatible with the compiled libsmile.a file.

I use the following command:

Code: Select all

H:\>d:\qlandman\mingw\bin\g++ -O3 -static smilebin.cpp -o try -LD:\qlandman\smilebin -ID:\qlandman\smilebin -lsmile
this gives me errors:

Code: Select all

D:/qlandman/smilebin\libsmile.a(lsnode.o):lsnode.cxx:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
D:/qlandman/smilebin\libsmile.a(messagehybrid.o):messagehybrid.cxx:(.text+0x4d8) : undefined reference to `_Unwind_Resume'
D:/qlandman/smilebin\libsmile.a(messagehybrid.o):messagehybrid.cxx:(.text+0x718) : undefined reference to `_Unwind_Resume'
D:/qlandman/smilebin\libsmile.a(messagehybrid.o):messagehybrid.cxx:(.text+0x75e) : undefined reference to `_Unwind_Resume'
D:/qlandman/smilebin\libsmile.a(messagehybrid.o):messagehybrid.cxx:(.text+0x8d4) : undefined reference to `_Unwind_Resume'
D:/qlandman/smilebin\libsmile.a(messagehybrid.o):messagehybrid.cxx:(.text+0x9ac) : undefined reference to `_Unwind_Resume'
D:/qlandman/smilebin\libsmile.a(messagehybrid.o):messagehybrid.cxx:(.text+0xc1b): more undefined references to `_Unwind_Resume' follow
D:/qlandman/smilebin\libsmile.a(messagehybrid.o):messagehybrid.cxx:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
I really have no idea what I should do to get it working with GCC...
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Post by shooltz[BayesFusion] »

Can you try compiling with -DNDEBUG on the command line?
Quirijn
Posts: 7
Joined: Sun May 02, 2010 6:43 pm

Post by Quirijn »

Code: Select all

D:\qlandman>d:\qlandman\mingw\bin\gcc -DNDEBUG -static smilebin.cpp -o try -LD:\qlandman\smilebin -ID:\qlandman\smilebin -lsmile -lstdc++
It still gives me problems with linking the library. I get errors for "_Unwind_resume" and "gxx_personality_v0". The -DNDEBUG option does not make any difference. Shooltz what is the command that you use to compile and link with GCC?
Quirijn
Posts: 7
Joined: Sun May 02, 2010 6:43 pm

Post by Quirijn »

By the way: Using GCC 4.0.0 or 4.4.1 does not make any difference and gives the same compiler errors.
Quirijn
Posts: 7
Joined: Sun May 02, 2010 6:43 pm

Post by Quirijn »

I managed to get it working! The problem was that I was using the TDM MinGW version of GCC. They use SJLJ Unwinding standard. To get SMILE working however, you have to use Dwarf-2 Unwinding.

Hopefully this can save someone a lot of time when he tries to compile the library on windows with GCC.
Post Reply