← Back to team overview

kicad-developers team mailing list archive

Re: Compiling Kicad using MSVC

 

--- In kicad-devel@xxxxxxxxxxxxxxx, Dick Hollenbeck <dick@...> wrote:
>
> 
> > Hi,
> >
> > I have successfully compiled the last two releases of Kicad using 
> > Microsoft compilers. There are a number of things I have to do to 
> > make it work. My goal here is to make a minimal impact on the source 
> > code.
> > You may ask "what is my motivation for doing this?", the following 
> > directory listings demonstate the answer clearly.
> >
> > mingw
> > 11/29/2007 11:51 AM 6,303,776 cvpcb.exe
> > 11/29/2007 11:51 AM 6,274,696 gerbview.exe
> > 11/29/2007 11:51 AM 7,471,808 eeschema.exe
> > 11/30/2007 08:16 AM 5,825,800 kicad.exe
> > 11/29/2007 11:51 AM 7,974,909 pcbnew.exe
> > msvc 7.1
> > 12/10/2007 01:02 PM 2,383,872 cvpcb.exe
> > 12/10/2007 11:33 AM 2,359,296 gerbview.exe
> > 12/10/2007 10:31 AM 2,928,640 eeschema.exe
> > 12/10/2007 02:45 PM 2,199,552 kicad.exe
> > 12/10/2007 11:53 AM 3,141,632 pcbnew.exe
> >   
> 
> This seems unlikely to be an apples to apples comparison. I know that:
> 
> 1) the mingw build is a static linking of the wxWidgets library to the 
> executable. Is the msvc a static or dynamic linking? I'll assume 
> dynamic. Therefore, you would have to add the size of the
wxWidgets.DLL 
> to each exe file to get an apples to apples comparison.
> 
> 2) the mingw build seems to have debugging symbols in the *.exe files.  
> Run the mingw strip.exe program on your windows binaries *.exe to
remove 
> another ~3 mbytes per binary.
> 
> > When running kicad on a Terminal Server, size does matter.
> >   
> 
> I thought a terminal server ran the app on the server, so the app does 
> not need to travel accross the wire? Are you saying the RAM footprint 
> within the terminal server is an issue? Realize that the 3 mbytes per 
> *.exe of symbols may not be loaded into process space under windows. I 
> don't know why it should be.
> 
> Also, it is likely that the sum of the dynamic wxWidgets.DLL and msvc 
> EXE is larger than the size of the statically linked g++ exe simply 
> because the static linking builds in only code that is actually used.  
> Whereas the DLL has to be built as a worse case binary, incorporating 
> everything.
> 
> 
> If this still does not persuade you, maybe you can:
> 
> 1) file a bug report with Microsoft, saying their free compiler is less 
> than free (negative free = expensive), in that it won't compile a 
> program that g++ does and it is costing people time. They have more 
> man-hours available to support their compiler than I do.
> 
> 2) maintain your own patches and apply them each time you need to build.
> 
> 3) get SVN write permission from Igor and apply them yourself.
> 
> 4) Pray that someone else who does have write access and has time to 
> spend on a Microsoft problem will do this for you.
> 
> 
> Dick
>
Dick,
These windows programs are linked to static wxWidgets libraries, the
code produced by the compiler is just more efficient. The only DLL
used is the MSVC runtime. I have seen similar file sizes using g++ in
SuSE Linux. Mingw produces fat code for some reason. The mingw
binaries in the list are the ones downloaded from your website, not
compiled by myself. If debugging symbols are in the code, that is a
problem you need to look at.
The biggest problem I have with the MS compiler is there is no typeof
operator. I have to include the boost library typeof emulation to
compile kicad. I would not call the problems I have bugs. The MS
compiler is apparently more strict on typing than g++ or the gnu math
libraries do not have the same overloaded trig functions.
Here is a list of the changes I have to make, fairly trivial.

The change of dynamic cast to static cast is done in conditional code
#ifdef __MSVC__ do static cast #else do dynamic cast #endif

I have one problem with porting kicad to 64-bit compiler, the implicit
type casting of time_t to a long. The code in kicad uses a long to
store the type, perhaps the code could be made more portable and
predictable if time_t types were stored in time_t objects.

**** COMMON ****

1) macros.h line 60 --

need a space between typeof(a) and __temp__

change #define EXCHG( a, b ) { typeof(a)__temp__ = (a); (a) = (b);
(b) = __temp__; }

to #define EXCHG( a, b ) { typeof(a) __temp__ = (a); (a) = (b);
(b) = __temp__; }


2) eeschema/symbdraw.cpp - Line 584

change ( (LibDrawCircle*) CurrentDrawItem )->m_Rayon = (int) sqrt(
(dx * dx) + (dy * dy) );

to ( (LibDrawCircle*) CurrentDrawItem )->m_Rayon = (int) sqrt(
(double)(dx * dx) + (double)(dy * dy) );



3) eeschema/symbdraw.cpp - Line 754

change angle = (int) (atan2( dy, dx ) * 1800 / M_PI);

to angle = (int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);



4) eeschema/symbdraw.cpp - Line 768

change DrawItem->m_Rayon = (int) sqrt( (dx * dx) + (dy * dy) );

to DrawItem->m_Rayon = (int) sqrt( (double)(dx * dx) +
(double)(dy * dy) );



5) eeschema/symbdraw.cpp - Line 770

change DrawItem->t1 = (int) (atan2( dy, dx ) * 1800 / M_PI);

to DrawItem->t1 = (int) (atan2( (double)dy, (double)dx ) *
1800 / M_PI);



6) eeschema/symbdraw.cpp - Line 775

change DrawItem->t2 = (int) (atan2( dy, dx ) * 1800 / M_PI);

to DrawItem->t2 = (int) (atan2( (double)dy, (double)dx ) *
1800 / M_PI);



7) eeschema/locate.cpp - Line 830

change ii = (int) sqrt( dx * dx + dy * dy );

to ii = (int) sqrt( (double)(dx * dx + dy * dy) );



8) eeschema/locate.cpp - Line 843

change ii = (int) sqrt( dx * dx + dy * dy );

to ii = (int) sqrt( (double)(dx * dx + dy * dy) );



9) eeschema/cleanup.cpp - Line 259

change atan2( RefSegm->m_Start.x - RefSegm->m_End.x,
RefSegm->m_Start.y -

RefSegm->m_End.y )

to atan2( (double)(RefSegm->m_Start.x - RefSegm->m_End.x),
(double)(RefSegm->m_Start.y -

RefSegm->m_End.y) )

10) eexchema/cleanup.cpp - Line 260

change atan2( TstSegm->m_Start.x - TstSegm->m_End.x,
TstSegm->m_Start.y - TstSegm->m_End.y ) )

to atan2( (double)(TstSegm->m_Start.x - TstSegm->m_End.x),
(double)(TstSegm->m_Start.y - TstSegm->m_End.y) ) )



11) pcbnew/graphpcb.cpp

change	angle = (int) (atan2( dy, dx ) * 1800 / M_PI);

to angle = (int) (atan2( (double)dy, (double)dx ) * 1800 / M_PI);



12) pcbnew/cotation.cpp Line 333

change angle = atan2( deltay, deltax ) + (M_PI / 2);

to angle = atan2( (double)deltay, (double)deltax ) + (M_PI / 2);



13) kicad/treeprj.datas.cpp line 408

change return dynamic_cast<TreePrjItemData*>(
m_TreeProject->GetItemData( m_TreeProject->GetSelection() ) );

to return static_cast<TreePrjItemData*>(
m_TreeProject->GetItemData( m_TreeProject->GetSelection() ) );


14) kicad/treeprj.datas.cpp line 188

change if( dest == dynamic_cast<TreePrjItemData*>(
m_Parent->GetItemData( parent ) ) )

to if( dest == static_cast<TreePrjItemData*>(
m_Parent->GetItemData( parent ) ) )


15) kicad/treeprj.datas.cpp line 

change dynamic_cast<WinEDA_TreePrj*>( m_Parent
)->GetParent()->m_Parent->OnRefresh( dummy );

to static_cast<WinEDA_TreePrj*>( m_Parent
)->GetParent()->m_Parent->OnRefresh( dummy );





Windows x64 issues

pcbnew\class_module.cpp 

change strcpy( Line, ctime( &m_LastEdit_Time ) );

to strcpy( Line, ctime( (const time_t *)&m_LastEdit_Time ) );

	

Thanks
Carl 







Follow ups

References