Archive for the ‘Unix2Win32_Porting’ Category
How To Set Environment Variable When Debugging Using Microsoft Visual Studio 2008
Posted by admin in Unix2Win32_Porting on October 18th, 2010
Set up project properties environment variable
I am new to microsoft windows visual studio 2008 IDE , Was looking for How to set environment variables when debugging in Visual Studio?
My project is in c/c++ windows console application.
Set Environment Variables in VS2008
Here are few simple steps to add environment variable.
- Open your project.
- Go to Project>Properties or pres Alt+F7
- Under Configuration Properties>Debugging, edit the ‘Environment’ value to set environment variables.
I wanted to set and add the directory “C:\Program Files\Hummingbird\Connectivity\13.00\Exceed” to the path when debugging app X applications, set the ‘Environment’ value to
PATH=%PATH%;C:\Program Files\Hummingbird\Connectivity\13.00\Exceed;C:\Program Files\Intel\Compiler\Fortran\10.1.021\IA32\Bin
And done.
Set System Wide Environment Variables in Windows PC
Other way to set up this is using system wide environment variable.
- Right click “My Computer”, Select properties
- Select the “advanced” tab
- Click the “environment variables” button
- In the “System variables” section, add the new environment variable that you desire
- “Ok” all the way out to accept your changes
Note : Visual Studio 2003 doesn’t allow you to set environment variables for debugging. In this case one can use _putenv function.
source – Windows Sysinternals: Documentation, downloads and additional resources
Debugging Fortran Programs Using IDB How To Debug Fortran Code Ifort Commands
Posted by admin in Tips & Tricks, Unix2Win32_Porting on October 6th, 2010
how to debug fortran code using idb
debugging Fortran programs.
Compiling your Fortran program for debugging
To prepare your program for debugging when using the command line (ifort command):
In a command window, (such as the Fortran command window available from the Intel Fortran program folder), compile and link the program with full debug information and no optimization:
ifort -g file.f90 (Linux OS and Mac OS X) ifort /debug:full file.f90 (Windows OS)
On Windows OS, specify the /debug:full compiler option to produce full debugging information. It produces symbol table information needed for full symbolic debugging of unoptimized code and global symbol information needed for linking.
How to use Intel idb as debugger.
IDB comes with good help information
eg, (idb) help run
Run the debugger program.
Usage: run (arguments) (redirections) Arguments: Run the program with the specified arguments. Run the program with the specified input and output redirections.
If no arguments and redirections are specified, program is run with arguments
and redirections specified by previous “run” command with arguments or by “set
args” command.
Synonyms: “r”.
To run the exe in debug mode from command line, use devenv with debugexe option.. read more for How To Run .exe In Debug Mode Microsoft Visual Studio.
Eg. > devenv /DebugExe r280test01.exe
After windows debugger starts Hit F10 key to start debugging.
Check out How to use dbx as debugger for fortan debugging here.
Check out Debugging Fortran programs with gdb here
Intel® Debugger (IDB) Manual
How To Resolve Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler
Posted by admin in Tips & Tricks, Unix2Win32_Porting on September 16th, 2010
Was getting Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler.
check out complete man pgcpp – The Portland Group Inc. C++ compiler
Building an application software using pgcc compiler, developed by C++ Language generates two external references of symbols [__curr_eh_stack_entry] and [__eh_curr_region], and results in kink error. Why?
How To Resolve Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler?
Answer:
Compiler automatically generates these symbols when -exception (C++ exception handling) and -rtti=on (Runtime type information) options are used. If these option is not required to use, Please do not enable them.
source
-rtti(default) –no_rtti An pgcc compiler option switch.
Enable (disable) support for RTTI (runtime type Information) features: dynamic_cast, typeid.
How To _access Function For Long File Names As Path In Winddows Programming Use UNC
Posted by admin in Tips & Tricks, Unix2Win32_Porting on September 15th, 2010
I use the function _access to check for file/directory existence in my program,
Problem definition: I have noticed that the function can’t deal with long file names. I wanted to check if file is available or not at path located “C:\Documents and Settings\0001”, did Google search on how to give long file names in windows..
How To _access Function For Long File Names As Path In Winddows Programming make Use of UNC standards
Solution use the UNC(Universal Naming Convention) conventions for path to be specified while working with windows programs.
ie the path should be “C:\\Documents and Settings\\0001”
Now The next problem is wanted to use period ie . in file name path,
Eg. I need to use the path as “C:\\Documents and Settings\\.test\\0001”
So tried with something like “\\.\” But The “\\.\” prefix will access the Win32 device namespace instead of the Win32 file namespace.
Then how to Turns off automatic expansion of the path string? Use the “\\?\” prefix also allows the use of “..” and “.” in the path names. To specify an extended-length path, use the “\\?\” prefix. For example, “\\?\D:\<very long path>”. Read more about Naming Files, Paths, and Namespaces
That did not help much, and tried directly with “C:\\Documents and Settings\\.test\\0001” It works.
you can also try the PathFileExists function
access function Return Value
Each function returns 0 if the file has the given mode. The function returns –1 if the named file does not exist or is not accessible in the given mode;
Do share your questions and views..
Number of View :3257How To Debug Err This Application Has Failed To Start Because MSVCR90.dll Was Not Found
Posted by admin in Unix2Win32_Porting on September 8th, 2010
Debugging for MSVCR90.DLL was not found error
This application has failed to start because MSVCR90.dll was not found. Re-installing the application may fix this problem.
why is it looking for MSVCR90.DLL while running debug? Shouldn’t it be looking for MSVCR90D.DLL?
While I did not compile it in debug mode.
A quick look using Dependency Walker
And doing windows dog sniffing got the location of msvcr90.dll location, at
C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\dll\x86
If your application linking to both MSVCR90D.DLL and MSVCR90.DLL, then solution is simple, you need to ignore MSVCR90 (and if necessary, MSVCRT) when linking.
Now getting coredll.dll error, since msvcd90.dll links to this dll..
Well What is coredll.dll? I can’t find this dll on my PC and Windows CE device too. coredll.dll is roughly equivalent to kernel32.dll on a PC,
then its asking for mmvcr70.dll and mmvcp70.dll ;
Got downloaded all these dll from this site.
You may also use “dumpbin /imports” to debug dll in windows imports API list and find the category for any dll.
Fork Implementation In Windows Operating System Vfork Implement in Win32
Posted by admin in Tips & Tricks, Unix2Win32_Porting on September 3rd, 2010
With little understanding of fork basics here are few more findings on how to vfork implementation in windows operating system and
fork implementation on win32
AT&T Labs Research – Software Tools pick out UWIN: Unix on Windows 95 and NT Machines
Major difference in Linux/Unix functionality and WIN32 applications
Process control and management:
Fork implementation
processes can be created using the fork(2) function, in win32 includes a spawn family of functions that combines the functionality of fork/exec for efficiency.
File descriptor
Open files, pipes, sockets, fifos, and character and block special devices files have file descriptors associated with them. In windows it is called handle.
signals
Most of the unix/linux signals are absent in windows, like SIGALRM
SIGCHLD
SIGHUP
SIGINT
SIGKILL
SIGPIPE
SIGQUIT
SIGUSR1
SIGUSR2
these can be implemented using replacement methods like SIGALRM Time-out alarm can be implemented using SetTimer – WM_TIMER – CreateWaitableTimer
SIGCHLD Change in status of child can be implemented using WaitForSingleObject
Terminal interface for consoles, sockets, and serial lines
sockets based on WINSOCK:
File control locking:
Memory mapping and shared memory
mmap()
System V IPC
semaphore; Shmget can be implemented using CreateFileMaping or
OpenFileMapping
shmdt can be implemented using UnmapViewOfFile
shmat can be implemented using MapViewOfFile
Pipe to _pipe
Close to _close
Runtime linking of dynamically linked libraries : like The dlopen(), dlsym() interface
Error mapping from Windows to UNIX
Symbolic links
Symbolic links to files and directories can be created and can be implemented as Windows shortcuts.
Few Good References for Unix2Win porting
Number of View :5344CreateProcess And fork() In Windows Differences And Implementation
Posted by admin in Linux, Unix2Win32_Porting on September 2nd, 2010
Although there is a one-to-one mapping between C UNIX APIs and Win32 APIs for most of the APIs like open to CreateFile, read to ReadFile, write to WriteFile, ioctl to DeviceIOControl, close to CloseFile, and so on. Still, While Porting applications from UNIX to Win32 natively,
One of the largest areas of difference is in the process model. UNIX has fork; Win32 does not. Depending on the use of fork and the code base, Win32 has two APIs that can be used: CreateProcess and CreateThread. A UNIX application that forks multiple copies of itself can be reworked in Win32 to have either multiple processes or a single process with multiple threads read Porting from UNIX to Win32 for further study.
What’s the best way to duplicate fork() in windows?
Forking a Win32 Process
Process Creation in cygwin
The fork call in Cygwin is particularly interesting because it does not map well on top of the Win32 API. This makes it very difficult to implement correctly. Currently, the Cygwin fork is a non-copy-on-write implementation similar to what was present in early flavors of UNIX. The first thing that happens when a parent process forks a child process is that the parent initializes a space in the Cygwin process table for the child. It then creates a suspended child process using the Win32 CreateProcess call.
Read further to know why process creation in cygwin is slow? windows fork process; dynamic forking process win32
Here are Some Differences between CreateProcess() in WIn32 and fork()/exec();
Unix has two primitives: fork (create new process identical to calling process) and exec (replace details of current process with those loaded from executable file).
Fork also copies open file descriptors, including network sockets (like filehandles) are inherited by children.
Windows has one primitive: CreateProcess, which is roughly equivalent to fork-then-exec.
Solution – C Requires That a Struct Or Union Has At Least One Member
Posted by admin in Unix2Win32_Porting on August 3rd, 2010
Windows errors are strange,
I have one header file in which one structure is declared,
as
typedef struct {
key_t xyz;
——
}INFO;
For this When I compile using cl.exe I get following list of errors.
: error C2016: C requires that a struct or union has at least one member : error C2061: syntax error : identifier 'key_t' : error C2059: syntax error : '}'
Well I am doing Code migration from Unix system to Windows system so key_t is not known in windows.
It does not make sense for the
Compiler Error C2016
which says no closing single quotation mark. Scratching my head and going around with the error.
I do not see any mistake in struct declaration,
Solution – C requires that a struct or union has at least one member
Just add the declaration of key_t in same header file before structure declaration.
typedef int key_t;
And compile again you are done.
Number of View :9481This USE Statement Is Not Positioned Correctly Within The Scoping Unit
Posted by admin in Unix2Win32_Porting on July 27th, 2010
Error: This USE statement is not positioned correctly within the scoping unit.
check help / man page of IFORT but no luck..
This thread at intel.com also here.
the answer at this thread is
“USE YourModule” must preceed local variable declarations and Your include file is declaring at least one variable.
put your code of USE to preceed the include statements.
But that did not work completely,
and another half part of answer is
Add an only clause to select only the GETENV routine:
use IFPORT, only: GETENV
This will hide any other names in IFPORT;
This post will talk about why added USE IFPORT
This worked fine..
share your experience as well..
USE should be preceded any IMPLICIT statements. They should be after the SUBROUTINE or FUNCTION statement.
We can have USE and IMPORT statements in the same interface body, but the ‘mixing’ forbidden referring to was that of placing any IMPORT statement before USE statement ..
Number of View :11154Ifort -extend-source Option Errors & Fortran Fixed Formatting Use nofree
Posted by admin in Tech-Tips, Unix2Win32_Porting on July 7th, 2010
Problem Definition
Working on FORTRAN source code migrations from Solaris operating system to windows XP. Fortran being most portable code so most of the time we do not see any problems while porting fortran code, but there is always problem with columns length exceeds to default value and while compilations we forgot to take care of option extend-source.
Intel® Fortran compiler(ifort) – Option -extend-source
-extend-source [size] Specifies the column number to use to end the statement field in fixed-form source files. [size] can be 72, 80, or 132. The default behavior is -noextend-source, which implies column 72. If you do not specify size, it is the same as specifying -extend-source 132.
source ifort help or man ifort
Solution
The Makefile has a compiler flag called /extend_source:132, which basically extends the number of columns the Fortran compiler looks at. The default value is 72. /extend_source extends the number of columns that the compiler looks at to 132.
Fortran generally uses something called as Fixed Formatting – which takes 72 valid columns, ignores the rest and also considers tabs and spaces as comments inside a statement field.
/nofree tells the compiler that fixed formatting needs to be used. Most of the time code follows fixed formatting.
TO remove all compiler errors which pertain to syntax errors at Format statement just add some variable in your makefile, like
COLEXTEND=/extend_source:132
And when facing problem while compiling any fortran module in Windows just compile with COLEXTEND= /nofree.
example of make command, assuming windows makefile name as win.make
on command prompt type : nmake /f win.make COLEXTEND=/nofree
Good luck and do comment your experiences as well.
Related problem regarding