Facing issue while running my first C program in VS Code - powershell

I have written my first C program and while running facing problem,Below is the code.
#include<stdio.h>
void main()
{
printf("Hello World");
}
While running the program getting below warning in terminal.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.
PS D:\C_Program> & 'c:\Users\azhar.vscode\extensions\ms-vscode.cpptools-1.11.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-kultbrgv.bxw' '--stdout=Microsoft-MIEngine-Out-tvw2mt1p.wdr' '--stderr=Microsoft-MIEngine-Error-lhguvkjt.xrj' '--pid=Microsoft-MIEngine-Pid-vho11bhr.z5a' '--dbgExe=C:\MinGW\bin\gdb.exe' '--interpreter=mi'
PS D:\C_Program>
enter image description here

Related

Abaqus UMAT subroutine - error after execution (warning LNK4210?)

I am trying to run my first UMAT subroutine with an ABAQUS job.
Fortran compiler seems to be linked to ABAQUS, since Abaqus command
abaqus verify -user_std
results to pass the check
Abaqus/Standard with user subroutines
...PASS
Continuing...
But trying to run the subroutine, an error occurs. The message file of the job reports:
Abaqus/Standard Analysis exited with an error - Please see the message file for possible error messages if the file exists.*
No message file (.msg) is produced by the software for the job.
The .log file reports the following:
Analysis initiated from SIMULIA established products
Abaqus JOB JOB NAME
Abaqus 2020
Abaqus License Manager checked out the following licenses:
Abaqus/Standard checked out 5 tokens from Flexnet server COMPUTER NAME
<1019 out of 1024 licenses remain available>.
Begin Compiling Abaqus/Standard User Subroutines
21/09/2021 12:15:52
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.3.0 Build ***************
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.
End Compiling Abaqus/Standard User Subroutines
Begin Linking Abaqus/Standard User Subroutines
Creazione della libreria standardU.lib e dell'oggetto standardU.exp
libirc.lib(fast_mem_ops.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
End Linking Abaqus/Standard User Subroutines
21/09/2021 12:16:00
Begin Analysis Input File Processor
21/09/2021 12:16:00
Run pre.exe
21/09/2021 12:16:05
End Analysis Input File Processor
Begin Abaqus/Standard Analysis
21/09/2021 12:16:05
Run standard.exe
21/09/2021 12:16:06
Abaqus Error: Abaqus/Standard Analysis exited with an error - Please see the
message file for possible error messages if the file exists.
Begin SIM Wrap-up
21/09/2021 12:16:06
Run SMASimUtility.exe
21/09/2021 12:16:06
End SIM Wrap-up
Abaqus/Analysis exited with errors
I have checked some previous questions on the web, but it's hard to get further for me.
Any contribution is welcome.
Try adding the following to your environment file:
link_sl='LINK /NODEFAULTLIB:LIBCMT.LIB /dll /def:%E /out:%U %F %A %L %B'
Source

Redirect stderr to file on network driver is very slow since VC++ 2015 / 14.0

We experience a strange performance issue when using Visual C++ 2013 (also known as Visual C++ 12.0) compared to more recent versions like Visual C++ 2015 (also known as Visual C++ 14.0):
The same C code is much slower when writing to stderr and redirecting this stream to a file on a network drive (Server is Linux Debian 8 / Samba).
C:\tmp> myprog.exe 2>X:\devel\fgl\tests\zz
When redirecting to a file on the local disk, or when redirecting to nul, the execution is fast.
We have also tested with VC++ 2017 / 15.0, same problem.
The reason seams to be the /MD option (link with MSVCRT.LIB), I could reproduce with a simple program:
#include <stdio.h>
int main(int argc, char **argv)
{
int n;
system("echo %TIME%");
for (n=0; n<200; n++) {
fprintf(stderr,"aaaaaaaaaaaaaaaaaaaaaaaaaaaa %d\n", n);
}
system("echo %TIME%");
return 0;
}
Then compile with and without /MD option:
C:\tmp>cl /O1 myprog.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25507.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
myprog.c
Microsoft (R) Incremental Linker Version 14.11.25507.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:myprog.exe
myprog.obj
C:\tmp>myprog.exe 2>X:\devel\fgl\tests\zz
9:32:27.96
9:32:27.97
C:\tmp>cl /O1 /MD myprog.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.11.25507.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
myprog.c
Microsoft (R) Incremental Linker Version 14.11.25507.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:myprog.exe
myprog.obj
C:\tmp>myprog.exe 2>X:\devel\fgl\tests\zz
9:32:37.15
9:32:40.12
C:\tmp>myprog.exe 2>c:\tmp\zz
9:32:47.15
9:32:47.20
Is there any known issue related to stderr / network drives with VC++?
Notes:
No problem when writing to stdout
No problem when using /MDd option (MSVCRTD.lib)
No problem with Visual C++ 2013 (Visual C++ 12.0, cl version 18.00.40629)
Thanks for reading!
Er, we have been experiencing the same issue with our C++ code so I added my comment using C++, initially. Sorry about that.
For C, the same "remedy" would look like this:
char buf[4096];
setvbuf(stderr, _IOLBF/*or _IOFBF*/, buf, sizeof(buf));
Initial response:
Try this at the beginning of your program:
static char buf[16384];
cerr.rdbuf()->pubsetbuf(buf, sizeof(buf));
cerr.unsetf(std::ios_base::unitbuf);
You can decrease the buffer size (to 4096 or less) and still see the speed boost -- the thing is that cerr is completely unbuffered by default, and having unitbuf set on it causes even more slowdown by implicit flush operations injected after each output to the stream.

Running PowerShell terminal in 2.0 mode

VSCode Version: 1.16.1
OS Version: Windows Server 2012 R2 Standard
Is it possible to run the PowerShell terminal using PowerShell v2.0? I have an older SharePoint farm that requires earlier version of PowerShell and would like to run that version instead of more current versions. When I open VS Code on my server the PowerShell terminal crashes.
Here is the log of the crash.
9/18/2017 10:09:24 AM [NORMAL] - Visual Studio Code v1.16.1 64-bit
9/18/2017 10:09:24 AM [NORMAL] - PowerShell Extension v1.4.3
9/18/2017 10:09:24 AM [NORMAL] - Operating System: Windows 64-bit
9/18/2017 10:09:24 AM [NORMAL] - Language server starting --
9/18/2017 10:09:24 AM [NORMAL] - exe: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
9/18/2017 10:09:24 AM [NORMAL] - args: C:\Users\me\.vscode\extensions\ms-vscode.powershell-1.4.3\scripts\Start-EditorServices.ps1 -EditorServicesVersion '1.4.1' -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.4.3' -AdditionalModules #('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\me\.vscode\extensions\ms-vscode.powershell-1.4.3\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\me\.vscode\extensions\ms-vscode.powershell-1.4.3\logs\1505754564-f1d3cfae-50af-4f74-9503-061208469b8d1505754561535\EditorServices.log' -SessionDetailsPath 'C:\Users\me\.vscode\extensions\ms-vscode.powershell-1.4.3\sessions\PSES-VSCode-10764-479503' -FeatureFlags #()
9/18/2017 10:09:25 AM [NORMAL] - powershell.exe started, pid: 6412
9/18/2017 10:09:25 AM [NORMAL] - powershell.exe terminated or terminal UI was closed
9/18/2017 10:10:25 AM [NORMAL] - Language server startup failed.
9/18/2017 10:10:25 AM [ERROR] - The language service could not be started:
9/18/2017 10:10:25 AM [ERROR] - Timed out waiting for session file to appear.
I experienced the same symptoms after updating VS Code (1.25.1) and PowerShell extension (1.8.2). Discovered that C:\Users\USERNAME.vscode\extensions\ms-vscode.powershell-1.8.2\modules\PowerShellEditorServices\Start-EditorServices.ps1 was failing to launch by looking at the logs and trying to launch it manually from a separate PowerShell instance with the same arguments. It returned the following prompt: Do you want to run software from this untrusted publisher? [V] Never run [D] Do not run [R] Run once [A] Always run [?] Help (default is "D"): indicating that the digital signature was not trusted.
To remedy this I performed the following:
Browse to the file noted in the error message above. (ex. C:\Users\USERNAME.vscode\extensions\ms-vscode.powershell-1.8.2\modules\PowerShellEditorServices\Start-EditorServices.ps1)
Right click on the file and choose Properties | Digital Signatures
Select the signature and click Details | View Certificate
Choose the Details tab and click Copy to File...
Save the file with a .CER extension.
Using the Certificates MMC Snapin, import this file into the Trusted Publishers Certificate Store on the Local Machine.
(original solution post in https://github.com/PowerShell/vscode-powershell/issues/1360 )

nunit-console hangs in remote powershell session after finishing test run

I'm running NUnit tests using the following PS line:
& 'D:\tools\nunit-console.exe' D:\MyApplication.Specs.dll /run=MyApplication.MyTest /framework=net-4.5 /nothread
This line is working fine.
After that I'm running the same test in remote session on the same PC with following line:
Invoke-Command -ComputerName MyHost -ScriptBlock { & 'D:\tools\nunit-console.exe' D:\MyApplication.Specs.dll /run=MyApplication.MyTest /framework=net-4.5 /nothread } -credential MyUser
After the test execution is finished nunit-console hangs with following output:
NUnit-Console version 2.6.3.13283
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
CLR Version: 2.0.50727.5477 ( Net 3.5 )
ProcessModel: Default DomainUsage: Single
Execution Runtime: net-4.5
Selected test(s): MyApplication.MyTest
.
Tests run: 1, Errors: 0, Failures: 0, Inconclusive: 0, Time: 6.96245315227513 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
I have noticed nunit-agent process in task manager. If I kill this process test execution is finished successfully.
The tests are running in separate manually created ASP.NET application domain via Remoting. The solution is to unload this app domain when all tests are passed. Global NUnit TearDown method is useful in this case :)

Ghostscript error with print function in Matlab

I am trying to save images in Matlab by using the print function:
myImage = magic(500);
myFigure = figure('visible','off');
r = 1;
set(myFigure, 'PaperUnits', 'inches', 'PaperPosition', [0 0 1920 1080]/r);
% the program works fine on both computers without the line above
% however, the program runs fine on one computer only with this line
imagesc(myImage); axis image;
print(myFigure, '-dpng', sprintf('-r%d',r), 'myOutput.png');
When I run this program locally with Matlab R2012b, it works as expected. However, if I try to run it on a remote machine with Matlab R2011b, I get the following error message:
Error using ghostscript (line 188)
Problem converting PostScript. System returned error: -1.Failed to convert to
output format; Ghostscript status: -100.**** Unable to open the initial device,
quitting.
and the following error which is triggered by the line with the call to print():
Error in print>LocalPrint (line 311)
pj = ghostscript( pj );
Error in print (line 237)
LocalPrint(pj);
The code is more specifically:
if pj.GhostDriver
pj = ghostscript( pj );
elseif strcmp( pj.Driver, 'hpgl' )
hpgl( pj );
end
On my laptop, pj.GhostDriver is '' and pj.Driver is png.
One possible explanation is that I can launch ghostscript locally from the terminal:
$ ghostscript
GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>
but not remotely from the terminal (since I do not have any graphical interface on the remote computer):
$ ghostscript
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GPL Ghostscript 9.05: Cannot open X display `(null)'.
**** Unable to open the initial device, quitting.
I would have thought Matlab already knew about it, since I launch Matlab on both computers by using:
matlab -nosplash -nodesktop -singleCompThread
Moreover, this problem is easily fixed as far as the terminal is concerned by adding the following line to ~/.bashrc:
export GS_DEVICE=display
Any hint at a solution?