Compiling a gcc library with 1.0 in name from powershell - powershell

I am trying to compile a project using the libusb-1.0 library. When i compile from cmd with the following command
gcc -g main.c -o test.exe -lusb-1.0
my program compiles just fine. However if I try to use the Powershell window inside VSC i get this error
gcc.exe: error: .0: No such file or directory
I've run the same code from both terminals.
While I still can compile and run my code, it would be convenient if I could do it from within VSC.
How can i fix this error?

Try with (double) quotes around the -lusb-1.0 parameter.

Related

Using -fsanitizer on vscode

Using -fsanitizer while compiling programs helps in finding location of memory leaks easily. But how to use this with vscode.
I only know that for compiling a program in vscode through terminal we need to type in g++ file_name.cpp -o executable_name.exe and for running .\program_name
Adding -fsanitizer to this command as an argument does not work for me. How to compile your program using fsanitizer on vscode?
Edit: I have been trying to use it as
g++ -std=c++17 -O2 -Wall -fsanitize=address
tempCodeRunnerFile.cpp -o tempcodeRunnerfile.exe
But this keeps giving me some kind of error:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan: No such file or directory
collect2.exe: error: ld returned 1 exit status
This is unrelated to VSCode. The problem is your platform - MinGW traditionally has poor sanitizer support.
Your MSYS2 environment, MINGW64, only supports UBSAN (with stripped-down error reporting, compile with -fsanitize=undefined -fsanitize-undefined-trap-on-error).
There's also CLANG64 environment, which does have ASAN. Install its Clang (pacman -S mingw-w64-clang-x86_64-clang), and compile using clang++ located at C:\msys64\clang64\bin. If you're compiling from MSYS2 terminal, make sure you start the right one: launch it with clang64.exe, or the "MSYS2 Clang x64" shortcut (I don't remember the exact name).

swift on visual studio code using windows

I'm using visual studio code to code swift on my windows pc i installed the latest swift version which is swift 5.3
after that i downloaded the extension of swift on visual studio code called Swift language and i downloaded code runner, i made a .swift file and started coding on it when i press on run code
this is the error that show up
C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\shims/SwiftStdint.h:28:10: error: 'stdint.h' file not found
#include <stdint.h>
^
:0: error: could not build C module 'SwiftShims'
try putting these commands in the terminal, it should work.
set SDKROOT=%SystemDrive%/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk
set SWIFTFLAGS=-sdk %SDKROOT% -I %SDKROOT%/usr/lib/swift -L %SDKROOT%/usr/lib/swift/windows
swiftc -o example.exe example.swift %SWIFTFLAGS%
Note - For the last command replace example before .swift and .exe with the name of your file.

How to use npcap in VSCode

I am trying to use npcap SDK in VScode on Windows 10 computer.
I've written the correct path to Include directory and Lib directory of the SDK in file c_cpp_properties.json and proper command in file tasks.json.
But when I ran my test.c file, it didn't compile successfully.
Here is the output of the console:
Executing task: D:\Software\MinGW\mingw-w64\mingw64\bin\gcc.exe -g d:\workspace\c\npcapTest\test.c -I D:\Software\wireshark\npcap_sdk\npcap-sdk-1.05\Include -L D:\Software\wireshark\npcap_sdk\npcap-sdk-1.05\Lib\X64 -o d:\workspace\c\npcapTest\test.exe <
C:\Users\Aoki\AppData\Local\Temp\cch72D04.o: In function `main':
d:/workspace/c/npcapTest/test.c:16: undefined reference to `pcap_findalldevs_ex'
d:/workspace/c/npcapTest/test.c:38: undefined reference to `pcap_freealldevs'
collect2.exe: error: ld returned 1 exit status
It seems that something went wrong when linking to the .dll file. I've tried many methods, but I still don 't know how to solve this problem.
I'm new here, I can't upload pictures...

How to enable c++17 on vscode(MAC)

I am currently using vscode on mac.
when using pair on .cpp file, the error message comes;
error: a space is required between consecutive right angle
brackets (use '> >')
on doing g++ -std=c++17 -g filename.cpp, error never comes out. But using g++ filename.cpp however, can't use this templates.
I can't even try tuple so have trouble working on it.
my current c_cpp_properties.json is like this;
enter image description here
and my launch.json is like this:
enter image description here
and lastly my tasks.json is like this:
enter image description here
How can i use g++ filename.cpp without those warning?
Using two consecutive > to close out nested template declarations is not legal in C++98/03, but is legal in C++11 (and later).
Your command g++ filename.cpp is (presumably) defaulting to C++98, while when you try g++ -std=c++17 -g filename.cpp you are expressly indicating that you want to compile for C++17.
Click on the bottom right button that says C++ (File type is automatically detected by vscode otherwise you have to select Language Mode for the file) and select Configure 'C++' language-based settings... - it will open settings.json file
Change field "C_Cpp.default.cppStandard" to "c++17"
To compile on the command line I used the following command - note here I am using Apple clang version 12.0.0
clang some_file.cpp -std=c++11 -lstdc++
In my vscode editor I added no changes and do not need any spaces between consecutive '>'.

ndk-build.cmd: command not found

(sorry for my bad english...)
I'm trying to build my .so library in Eclipse, with the CDT plugin. (It's an android project, with native code...)
Because I'm on windows, I replaced the build command in [Project->Properties->C/C++ build] with this one:
[absolute_path_to_android-ndk]\ndk-build.cmd V=1
But I got this message in the console:
C:\SDK\android-ndk-r8\ndk-build.cmd
Cannot run program "C:\SDK\android-ndk-r8\ndk-build.cmd": Le fichier spécifié est introuvable.
Error: Program "C:/SDK/android-ndk-r8/ndk-build.cmd" is not found in PATH
I tried with only "ndk-build.cmd" in the eclipse's build command, and the path to this command in my PATH environment variable, but I still have the same error.
In fact, I can't execute any program from the eclipse's build command.
I have no problem to build the library when I call ndk-build in cmd.exe, or in cygwin, but when I try to automate the library's build in Eclipse, it doesn't work...
Does anyone have a solution to my problem?
I found the solution by adding the NDK-path to the path variable, in the ubuntu terminal as well as in eclipse. Then I had to DELETE THE ".cmd" in "ndk-build.cmd" because the terminal says that I have no permission with this file ending.