473,382 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Compiling C++ on MS Windows

Hi,
I am trying to port a C++ program which is supposed to be standards
compliant. It works fine on Linux with GCC (4.x). But as I try to
compile it on Windows, all hell breaks loose. I have been struggling
with several free (as beer) compilers on windows, but none of them
does the job. I am not sure how much of the blame goes to our code and
how much to the compilers. By the way the platform is Windows XP and
all the softwares mentioned below are their latest versions.

Here are my experiences:

Visual C++ 2005 Express ( Microsoft C compiler ) :
It does not seem to have sufficient template support. The
particular, the problem is, we have some template overloading. I do
not know if it is a violation of C++ standards to overload template
parameters ( could not find any instance of it in Lippman ), but it
compiles fine with gcc. The functions definitions are like:
bool set( MyData* e, const FieldInfo* f ){...}
bool set( MyData* e, const string& f ){...}
template < class T bool set( MyData* e, const FieldInfo* f, T v )
{...}
template < class T bool set( MyData* e, const string& f, T v ){...}
template < class T1, class T2 bool set(MyData* e, const FieldInfo*
f, T1 v1, T2 v2 ){...}
template < class T1, class T2 bool set(MyData* e, const string& f,
T1 v1, T2 v2 ){...}

I could work-around this by renaming the overloaded functions but I
would really hate to do so unless I am sure that we are violating
standards here, because boreland C++ and mingw do not have any problem
with these definitions.

Borland C++ Builder (Developer Studio-2006)/ Free command line
tools :
It compiles fine in debug build, though giving a lot of unwanted
warnings for derived classes overloading some virtual function in
baseclass.
"[C++ Warning] DerivedFieldInfo.h(132): W8022
'DerivedFieldInfo::match(const MyData *,unsigned int) const' hides
virtual function 'FieldInfo::match(MyData *,const string &) const'"

But when I try to do a release build the compiler fails without much
information:
"[Linker Fatal Error] Fatal: Illegal SEGMENT fixup index in module
'E:\myproject\basecode\SharedFieldInfo.cpp'"
I have no idea how to resolve this error.

MingW - 5.1.3 (mingw-runtime 3.12):
Compiles fine both with and without -g in CFLAGS.

Now, although borland and mingw can compile and link it, the
executable seems to have some problem. There are some assertions for
testing that fails in the same place for executable generated by both
compilers. In mingw it just says assertion failed, with line number
etc. and borland pops up a message window saying:
"Project myproject.exe raised an exception class EAccessVioltion with
message 'AccessViolation'".

It may be some problem with static initializations that I have to look
at. But right now it will be nice if somebody could cast some light on
what is the most standard compliant and full featured C++ compiler for
windows. So I could embark on the wild-goose-chase with the most
reliable tool ( which itself does not camouflage as the wild goose).
Please note that I am not bothered about compilation speed or
executable size at this point. I just want to make sure the problem
lies with the code or with the build process / windows platform itself
( without getting into too much of a flame war).
I would appreciate any feedback from the community.

Thanks in advance,
Ray S.

May 4 '07 #1
8 2263
rays wrote:
I am trying to port a C++ program which is supposed to be standards
compliant. It works fine on Linux with GCC (4.x). But as I try to
compile it on Windows, all hell breaks loose. [..]
FAQ 5.8.
It may be some problem with static initializations that I have to look
at. But right now it will be nice if somebody could cast some light on
what is the most standard compliant and full featured C++ compiler for
windows. [..]
Comeau C++ is good. Microsoft Visual C++ Express is close, but check
out their "Code Name Orcas", it's not in alpha, IIRC.

If you think your problem is specific to MS Windows (I don't know, and
I don't think so, but still...) try posting to a Windows newsgroup.
Who knows, maybe somebody there knows more?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 4 '07 #2
ajk
On 4 May 2007 06:56:57 -0700, rays <ra**********@gmail.comwrote:
>Hi,
I am trying to port a C++ program which is supposed to be standards
compliant. It works fine on Linux with GCC (4.x). But as I try to
compile it on Windows, all hell breaks loose. I have been struggling
with several free (as beer) compilers on windows, but none of them
does the job. I am not sure how much of the blame goes to our code and
how much to the compilers. By the way the platform is Windows XP and
all the softwares mentioned below are their latest versions.
gcc for windows would be a good bet :)
May 4 '07 #3
On Fri, 04 May 2007 14:26:26 +0000, ajk wrote:
On 4 May 2007 06:56:57 -0700, rays <ra**********@gmail.comwrote:
>>Hi,
I am trying to port a C++ program which is supposed to be
standards
>>compliant. It works fine on Linux with GCC (4.x). But as I try to
compile it on Windows, all hell breaks loose. I have been struggling
with several free (as beer) compilers on windows, but none of them does
the job. I am not sure how much of the blame goes to our code and how
much to the compilers. By the way the platform is Windows XP and all
the softwares mentioned below are their latest versions.
gcc for windows would be a good bet :)
MinGW *is* gcc for Windows.

--
Lionel B
May 4 '07 #4
rays wrote:
Here are my experiences:

Visual C++ 2005 Express ( Microsoft C compiler ) :
It does not seem to have sufficient template support.
That's funny, my experience is that visual studio 2005 is much more
compliant than gcc 4.

And another experience is that I tried this code:

#include <iostream>
#include <string>

using namespace std;

typedef int MyData;
typedef char FieldInfo;
bool set( MyData* e, const FieldInfo* f )
{
std::cout << "version 1\n";
return false;
}
bool set( MyData* e, const string& f )
{
std::cout << "version 2\n";
return false;
}
template < class T bool set( MyData* e, const FieldInfo* f, T v )
{
std::cout << "version 3\n";
return false;
}
template < class T bool set( MyData* e, const string& f, T v )
{
std::cout << "version 4\n";
return false;
}
template < class T1, class T2 bool set(MyData* e, const FieldInfo* f,
T1 v1, T2 v2 )
{
std::cout << "version 5\n";
return false;
}
template < class T1, class T2 bool set(MyData* e, const string& f, T1
v1, T2 v2 )
{
std::cout << "version 6\n";
return false;
}

int main()
{
int a = 0;
char b = 0;
std::string c;
double dummyType1 = 0;
bool dummyType2 = false;
set(&a,&b);
set(&a, c);
set(&a, &b, dummyType1);
set(&a, c, dummyType1);

set(&a, &b, dummyType1, dummyType2);
set(&a, c, dummyType1, dummyType2);

std::cout << "hello world!\n";
return 0;
}


the produced result is:

version 1
version 2
version 3
version 4
version 5
version 6

as expected.

Try to post a minimal example that is not compiled in visual studio
2005, and we'll try to sort it out.

But don't do like those people that are really convinced about
something, and when they check in the encyclopaedia and they find out
that it doesn't agree with them, they conclude that the encyclopaedia
must be wrong! ;)

Regards,

Zeppe
May 4 '07 #5
On 2007-05-04 15:56, rays wrote:
Hi,
I am trying to port a C++ program which is supposed to be standards
compliant. It works fine on Linux with GCC (4.x). But as I try to
compile it on Windows, all hell breaks loose. I have been struggling
with several free (as beer) compilers on windows, but none of them
does the job. I am not sure how much of the blame goes to our code and
how much to the compilers. By the way the platform is Windows XP and
all the softwares mentioned below are their latest versions.

Here are my experiences:

Visual C++ 2005 Express ( Microsoft C compiler ) :
It does not seem to have sufficient template support. The
particular, the problem is, we have some template overloading. I do
not know if it is a violation of C++ standards to overload template
parameters ( could not find any instance of it in Lippman ), but it
compiles fine with gcc. The functions definitions are like:
bool set( MyData* e, const FieldInfo* f ){...}
bool set( MyData* e, const string& f ){...}
template < class T bool set( MyData* e, const FieldInfo* f, T v )
{...}
template < class T bool set( MyData* e, const string& f, T v ){...}
template < class T1, class T2 bool set(MyData* e, const FieldInfo*
f, T1 v1, T2 v2 ){...}
template < class T1, class T2 bool set(MyData* e, const string& f,
T1 v1, T2 v2 ){...}

I could work-around this by renaming the overloaded functions but I
would really hate to do so unless I am sure that we are violating
standards here, because boreland C++ and mingw do not have any problem
with these definitions.

Borland C++ Builder (Developer Studio-2006)/ Free command line
tools :
It compiles fine in debug build, though giving a lot of unwanted
warnings for derived classes overloading some virtual function in
baseclass.
"[C++ Warning] DerivedFieldInfo.h(132): W8022
'DerivedFieldInfo::match(const MyData *,unsigned int) const' hides
virtual function 'FieldInfo::match(MyData *,const string &) const'"

But when I try to do a release build the compiler fails without much
information:
"[Linker Fatal Error] Fatal: Illegal SEGMENT fixup index in module
'E:\myproject\basecode\SharedFieldInfo.cpp'"
I have no idea how to resolve this error.

MingW - 5.1.3 (mingw-runtime 3.12):
Compiles fine both with and without -g in CFLAGS.

Now, although borland and mingw can compile and link it, the
executable seems to have some problem. There are some assertions for
testing that fails in the same place for executable generated by both
compilers. In mingw it just says assertion failed, with line number
etc. and borland pops up a message window saying:
"Project myproject.exe raised an exception class EAccessVioltion with
message 'AccessViolation'".

It may be some problem with static initializations that I have to look
at. But right now it will be nice if somebody could cast some light on
what is the most standard compliant and full featured C++ compiler for
windows. So I could embark on the wild-goose-chase with the most
reliable tool ( which itself does not camouflage as the wild goose).
Please note that I am not bothered about compilation speed or
executable size at this point. I just want to make sure the problem
lies with the code or with the build process / windows platform itself
( without getting into too much of a flame war).
I would appreciate any feedback from the community.
As Zeppe pointed out, try to localize the code that does not compile as
much as possible and then post it here and someone might tell you if
it's the code of not. Another thing to check is you use any compiler-
specific extensions when compiling it on Linux.

--
Erik Wikström
May 4 '07 #6
rays wrote:
I am trying to port a C++ program which is supposed to be standards
compliant. It works fine on Linux with GCC (4.x). But as I try to
compile it on Windows, all hell breaks loose. I have been struggling
with several free (as beer) compilers on windows, but none of them
does the job.
Try the Digital Mars C++ compiler for Windows.

-------
Digital Mars
http://www.digitalmars.com
C, C++, D programming language compilers
May 4 '07 #7
Thank you all, Victor, ajk, Lionel, Zeppe, Erik and Walter for your
prompt and helpful response . I have partially got around the VC++
problem, as it turned out that it needed inlining for template
specializations somewhere else in the code.Now all three are in the
same rank with the same assertion failing in the executable. I guess
it something goes wrong with windows executable layout that is
generated, may be the code has some bug that is not visible in linux
or may be I am missing something in the build setting. I shall
peacefully set on debugging now.
And by the way, I was trying to use make file for building, instead
of using the IDE, which made life more frustrating and perhaps
generated some unkind comments from my part. I should retract it. The
Visual Studio Express GUI is amazing and it works quite automagically
- making me feel a bit stupid.

Thanks and regards,
Ray S.

May 4 '07 #8
I am trying to port a C++ program which is supposed to be standards
compliant. It works fine on Linux with GCC (4.x). But as I try to
compile it on Windows, all hell breaks loose. I have been struggling
with several free (as beer) compilers on windows, but none of them
does the job. I am not sure how much of the blame goes to our code and
how much to the compilers. By the way the platform is Windows XP and
all the softwares mentioned below are their latest versions.
Did you try the free open source compiler, Open Watcom C++,
at http://www.openwatcom.org/ ?

You may have template problems there also as template partial
specialization is still being worked on. Version 1.7 in a month
or so will improve this.

Lynn

May 4 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jmdeschamps | last post by:
Hello to all, I'm trying to get binaries for Ming but can't find them FOR PYTHON... Yes I know its a PHP group, but i believe someone as made a binary of Ming that is symbolically linked to PHP...
6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
0
by: Martin Bless | last post by:
I need to access a MSSQL database (MS-Sql, not MySQL!)and would very much like to use mssql-0.09.tar.gz which is available from http://www.object-craft.com.au/projects/mssql/download.html ...
2
by: Søren Grønbech | last post by:
I'm using Codewarrior for Windows and for example I can check the peephole option to see if we are currently compiling with peephole optimization on... #if __option(peephole) Is there a way to...
3
by: raghavendra | last post by:
while compiling windows service Project configuration skipped because it is not selected in this solution configuration Regards, Raghavendra
2
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before...
3
by: RS | last post by:
Hi all, My code compiles well with gcc on linux and OS X, but now I have to run it at work, and my only choice is Visual Studio .Net 2003 environment on windows, which I had never used before....
2
by: sterten | last post by:
I often see scientific programs for Linux written in C which come with several files, are "zipped" with gzip and packked as .tar , they contain a "makefile" and several instructions (and...
37
by: Michael Palmer | last post by:
As anyone knows, the state of Python GUI programming is a little fractured at this time, with many toolkits, wrappers and meta-wrappers dead and alive, with or without documentation. I've come...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.