Posts Tagged ‘Windows XP’

How To Set Environment Variable When Debugging Using Microsoft Visual Studio 2008

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.

  1. Open your project.
  2. Go to Project>Properties or pres Alt+F7
  3. 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.

  1. Right click “My Computer”, Select properties
  2. Select the “advanced” tab
  3. Click the “environment variables” button
  4. In the “System variables” section, add the new environment variable that you desire
  5. “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

Number of View :1976

Tags: , ,

No Comments


Debugging Fortran Programs Using IDB How To Debug Fortran Code Ifort Commands

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

Number of View :5724

Tags: , , ,

1 Comment


How To Run .exe In Debug Mode Microsoft Visual Studio 2008

How to run .exe in debug mode microsoft visual studio 2008?
Here are few solutions I got for Running .exe in debug mode using the Windows debugger.

Using Devenv

Devenv allows you to set various options for the integrated development environment (IDE);

/DebugExe

Loads a Visual C++ executable under the control of the debugger. This switch is not available for Visual Basic or Visual C# executable.

Example : if your win32 binary executable name is test.exe then, to run this win32 binary in debug mode use this command on windows command prompt.

C:\tmp>devenv /DebugExe test.exe

Your default debugger will start and loads this binary for debug mode. Then just hit F10 Key to go to main function. For Now on your debugging starts, ie to step into function use F11 key, you can put breakpoints and all debugging stuff.
I assume that you have compiled the binary test.exe with debug flag enabled, else debugger will not find the debug symbols and will not load the code.

Using Image File Execution Options

To setup an application to launch the debugger automatically.
How to: Launch the Debugger Automatically
the Image File Execution Options folder, locate the name of the application you want to debug, such as myapp.exe. If you cannot find the application you want to debug:

  1. right-click the Image File Execution Options folder, and on the shortcut menu, click New Key.
  2. Right-click the new key, and on the shortcut menu, click Rename.
  3. Edit the key name to the name of your application; myapp.exe, in this example.

read more
How to open a file, and go to a line number
devenv /edit E:\code.cpp /command “edit.goto 45”

In this example, devenv will open the code.cpp file, and go to line 45.

Number of View :4345

Tags: , ,

No Comments


How To Resolve Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler

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.

Number of View :3006

Tags: , , ,

No Comments


How To _access Function For Long File Names As Path In Winddows Programming Use UNC

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 :1882

Tags: , , ,

No Comments


How To Debug Err This Application Has Failed To Start Because MSVCR90.dll Was Not Found

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.

Number of View :2692

Tags: , ,

No Comments


Fork Implementation In Windows Operating System Vfork Implement in Win32

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

  1. Porting Socket Applications to Winsock
  2. Process and Thread Functions
  3. Winsock Programmer’s FAQ Articles: BSD Sockets Compatibility
  4. LibGW32C for GNU C library for Windows
  5. Unix to Windows Porting Dictionary for HPC
  6. UNIX Application Migration Guide
Number of View :2673

Tags: , ,

No Comments


CreateProcess And fork() In Windows Differences And Implementation

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();
https://i2.wp.com/users.telenet.be/bartl/classicperl/fork/c_code.gifUnix 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.

Number of View :7309

Tags: , , ,

1 Comment


Solution – C Requires That a Struct Or Union Has At Least One Member

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 :4285

Tags: , , , ,

No Comments


Emulate Fortran Function Btest In C Language

Emulate the fortran function btest in C language
BTEST function is as part of Bit Functions library in Fortran,
description of BTEST function

btest( m, i ) Tests bit i in m; returns .true. if the bit is 1, and .false. if it is 0.
Here is C language code implementation of BTEST function, which checks for bit and returns true ie 1 if bit is SET or else returns 0.

int btest(int word, int bit)
{
  unsigned int mask;

  /* Create the bit mask */
  mask = 0x0000001 << bit;

  /* Return TRUE or FALSE*/
  return (( word & mask ) != 0);
}
Number of View :3195

Tags: , ,

No Comments



SetPageWidth
Content Protected Using Blog Protector By: PcDrome.

Mahol Dot Org is Stephen Fry proof thanks to caching by WP Super Cache