Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Porting code from windows over to linux

ankit_m_
Beginner
440 Views

Hello, 

I am using icpc compiler on both windows (visual studio 2012) and linux (which has g++ 4.8.2 installed). I am running into issues with porting the code from one OS to another. Code that compiles on windows without any major modifications, fails to compile of linux (having me make significant changes, especially at places where I am working with templates, specialized templates and template inheritance) , so I tried comparing compiler switches/triggers generated by windows(in VS2012 ) and the one that I provide in my cmake (CMakeLists.txt) but none of my combination seem to help.

e.g

Following is command line (generated by VS2012) on windows

/GS /W3 /Zc:wchar_t /I"C:\Program Files (x86)\Intel\Composer XE\tbb\include" /I"..\..\..\..\ThirdParty\boost\boost_1_55_0" /Zi /Od /Fd"C:\SomeDir\msvs\obj\Debug\vc110.pdb" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "TBB_USE_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /D "_MBCS" /Qstd=c++0x /WX /Zc:forScope /arch:SSE3 /Gd /Oi /MDd /Fa"C:\SomeDir\msvs\obj\Debug\" /EHa /nologo /Fo"C:\SomeDir\msvs\obj\Debug\" /Fp"C:\SomeDir\msvs\obj\Debug\FilterDemo.pch"  

 

Following is what I have tried in linux (in my CMakeLists.txt)

 set(CMAKE_CXX_FLAGS " -w3 -std=c++11")

 set(CMAKE_CXX_FLAGS " -W -Werror -Wall -std=c++11")

 

 

 set(CMAKE_CXX_FLAGS " -W -Werror -std=c++11")

Can anyone kindly help me with this porting issue, specifically, could you please advise what common compiler flags are supposed to be set on windows and linux for the ease of porting the code from one OS to another. 

Thank you in advance. 

Sincerely, 

A

0 Kudos
3 Replies
Judith_W_Intel
Employee
440 Views

 

On Linux you can try these:

-fms-dialect[=<arg>]
          enable compatibility with a specific Microsoft* Visual Studio
          version
            9   - Microsoft* Visual Studio 2008 compatibility
            10  - Microsoft* Visual Studio 2010 compatibility
            11  - Microsoft* Visual Studio 2012 compatibility
 

Or on Windows you can try these:

/Qgcc-dialect:<version>
          enable a limited gcc-compatible dialect on Windows. The gcc
          version may be specified as 440, 450 or 460.
            Example: /Qgcc-dialect:440 -> gcc 4.4 compatibility

This won't guarantee you won't still have some porting isss, but it should help.

Judy

0 Kudos
ankit_m_
Beginner
440 Views

Thank you for your help Judith. Neither of them help in terms of reducing the number of changes that  I have to make to windows generated code nevertheless, it is good to know that there is such an option. 

0 Kudos
SergeyKostrov
Valued Contributor II
440 Views
>>...Code that compiles on windows without any major modifications, fails to compile of linux ( having >>me make significant changes, especially at places where I am working with templates... This is a clear indication that your Windows codes are Not portable and please provide some example ( a small one ).
0 Kudos
Reply