Error in running functions of C++ package at command line - c++

I am new to packages in C++ and I am using Visual Studio to build the package. I have done that successfully but I can't run the functions of that package at the command line.
Error is
'graphgen' is not recognized as an internal or external command,
operable program or batch file.
I am following the instructions from this link
https://snap.stanford.edu/snap/install.html
where it says
After the code is compiled, as shown above, it can be executed. The graphgen application is used here as an example.
To run the graphgen example, open a command line application and execute the following command:
cd examples/graphgen
./graphgen -g:w -n:1000 -k:4 -p:0.1 -o:smallworld.txt
The command generates a Watts-Strogatz small-world graph where each node is connected to k=4 closest nodes and with the rewiring probability of p=0.1.
What to do?

Related

How to compile c++ in vs code?

Hi I'm a beginner at c++, I was trying to compile some code in vs code and I got this error: 'g++' is not recognized as an internal or external command,
operable program or batch file.
I'm just wondering how to fix this, whenever I try to compile in the command line I get a similar error?
First, you need to install a compiler(MinGW).
Now RightClick on My Computer
goto Advanced System Settings
Environment Variables
now there in system variable goto path
in that add the file location of MinGW\bin folder
save it and restart VScode

cppcheck from command line not recognized

I downloaded cppcheck to analyze my C++ programs, successfuly got to work it´s gui environment but I would also like to use it from command line.
In C:\users\me\documents\main.cpp
is my cpp program that I try to analyze with cppcheck. When I type cppcheck main.cpp in cmd, I only get a message saying 'cppcheck' is not recognized as an internal or external command,
operable program or batch file.
Is there anything I should link my cppcheck with in order to get recognized by command line?
The directory where cppcheck is installed needs to be added to your PATH if not present, or in alternative you have to give the full-pathname to the execution command.

C++ executable, sh 1:not found

I created a c++ programm that works with ros. The first step would be to open a roscore in a terminal and move on from there. I do so with system("roscore &");
I compiled my file and can run it just fine with ./file.
However, I want to be able to run it as an application (double click). I created a .desktop file and the program shows up in my application list. When i start it though, all I get is a terminal that opens with the message
sh: 1: roscore: not found
etc.
The same applies for the roslaunch commands. I also fork and exec a roslaunch command, which does not work as well.
I tried system("ls"); which worked. All cout messages work as well.
Any idea what is wrong here?
roscore executable is not located in std paths (/bin:/usr/bin:). Use the absolute path - system("/path/to/roscore &")

how to execute the 'net use' command from the c++ code by system() method in visula studio 2012?

i use the following way to execute it
system("net use * /del /yes");
but it gives the following
`'net' is not recognized as an internal or external command, operable program or batch file.`
but when i run the same command on the CMD it is executed successfully. as
You have these remote connections:
Z: \\x.x.x.x\x
Continuing will cancel the connections.
The command completed successfully.
The issue was of Environment Path add the Path "C:\Windows\System32" then it will execute properly and give the output correctly.

What needs to be done to get a distributable program from Eclipse?

I’ve produced a C++ program in Eclipse running on Redhat, which compiles and runs fine through Eclipse.
I thought that to run it separately to Eclipse you use the build artifact which is in the directory set via the project’s properties.
However this executable doesn’t run (I know it’s an executable as I’ve set it to be an executable via the project’s properties and it shows up as such via the ls command and the file explorer).
When attempting to run it using the executable’s name, I get the error:
bash: <filename>: command not found
When attempting to run it as a bash file:
<filename>: <filename>: cannot execute binary file
And when running it with "./" before the file name, nothing happens. Nothing new appears in the running processes and the terminal just goes to the next line as though I’d just pressed enter with no command.
Any help?
You've more or less figure out the first error yourself. when you just run <filename> , it is not in your PATH environment variable, so you get "command not found". You have to give a full or relative path when to the program in order to run it, even if you're in the same directory as the program - you run it with ./<filename>
When you do run your program, it appears to just exit as soon as you start it - we can't help much with that without knowing what the program does or see some code.
You can do some debugging, e.g. after the program just exits run echo $? to see if it exited with a particular exit value, or run your program using the strace tool to see what it does (or do it the usual way, insert printf debugging, or debug it with gdb)