473,651 Members | 2,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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] DerivedFieldInf o.h(132): W8022
'DerivedFieldIn fo::match(const MyData *,unsigned int) const' hides
virtual function 'FieldInfo::mat ch(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\b asecode\SharedF ieldInfo.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 'AccessViolatio n'".

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 2291
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**********@g mail.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**********@g mail.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] DerivedFieldInf o.h(132): W8022
'DerivedFieldIn fo::match(const MyData *,unsigned int) const' hides
virtual function 'FieldInfo::mat ch(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\b asecode\SharedF ieldInfo.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 'AccessViolatio n'".

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
2160
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 on Windows. Please don't bother telling me to use "the right tool for the right job, that is PHP (since it works there)" type of response. I'm sure PHP is great and all that but I really need a hand here ion compiling ... I'm a lowly apps...
6
6168
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 itself. Everything you need is available at no costs (except download hassle and installation time). Once your system is set up properly its just a matter of running 'python setup.py build'. No longer waiting for someone else to build binaries and a...
0
2061
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 Unfortunately the binary for Python-2.4 isn't available yet and I'd hate to step back to a previous version. I'm glad I managed to set up my XP machine to being able to compile extensions using the VC++ toolkit which freely availbale from MS. See
2
2190
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 see if we are compiling with debug turned on? thanx, Søren
3
1457
by: raghavendra | last post by:
while compiling windows service Project configuration skipped because it is not selected in this solution configuration Regards, Raghavendra
2
2114
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 my other includes then I get lots of errors like C2011: 'fd_set' : 'struct' type redefinition warning C4005: 'FD_CLR' : macro redefinition which I understand are due to the fact that windows.h is being included in another header file as well as...
3
2061
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. I've noticed several obstacles with the compilation. For example this environment insists that we put all headers under a stdafx header, which I managed to find a way to get around. But there are other issues. For example, Visual Studio claims...
2
1781
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 incompatibilities for several compilers). In theory, you can create a Windows-executable but in practice this rarely works or requires too much time and energy.
37
9043
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 across two projects that have the appeal of striving for simple, pythonic APIs: PyGUI and wax. The latter is a wrapper around wxPython. It is lacking documentation but actually quite usable and concise. The other, PyGUI, has an even nicer API and...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.