How to pass multiple commands arguments in visual studio?
Asked Answered
B

1

3

I am working on a compession/decompression project using the LZMA SDK.

The main program contains some arguments that I must use to run the application

To run it from the command line, I use :

./LzmaUtil.exe e input.elf output.elf

I'm using VS 2013 , so i have added e in.elf out.elf to the commands arguments, I rebuild the project (the executable file in generated) but nothing seems to happen when I press RUN.

Note that I have the input.elf in the debug folder were the .exe is present there, and the , the flag e is used to compress the file and output.elf is the compressed file.

Issue VS 2013

The main function contains :

int MY_CDECL main(int numArgs, const char *args[])
{
    char rs[800] = { 0 };
    int res = main2(numArgs, args, rs);
    fputs(rs, stdout);
    return res;
}

The complete source code is available at : http://www.7-zip.org/sdk.html

Debugging :

With no arguments at all I get :

The program '[5284] LzmaUtil.exe' has exited with code 0 (0x0).

With the arguments I have mentionned I get :

The program '[5284] LzmaUtil.exe' has exited with code 1 (0x1).

so something is happenning !!!

With breakpoint at the main I get :

numArgs 4   int
args    0x007eaca8 {0x007eacbc "E:\\1PFE\\LZMA\\LzmaUtil\\Debug\\LzmaUtil.exe"} const char * *

Any help will be appreciated, thanks.

Baal answered 4/2, 2016 at 8:50 Comment(13)
What happens if you put a breakpoint at the beginning of main? What happens if the Command Arguments field iks empty?Phagocyte
@MichaelWalz thanks , I added the debugginf part , it seems that the arguments are well recognized because the variable args contains 4 but i didn't understand the line belowBaal
args[0] points to "E:\\1PFE\\LZMA\\LzmaUtil\\Debug\\LzmaUtil.exe", args[1] points to "e", args[2] points to "in.elf" etc. Pretty basic C stuff.Phagocyte
@MichaelWalz yes i know this but i don't get any output !!!Baal
you did not give the complete code, the link goes to LZMA SDK.Catullus
@Frankenstein if main receives the command line arguments correctly, then the problem is somewhere in main2.Phagocyte
@MichaelWalz don't thing that there is a problem in the source code , that's because when running the generated application from command line it works just fineBaal
@Frankenstein well, step into main2 and you'll find out. This should be too hard.Phagocyte
ok let's see c = args[1][0]; using the warch i get 'Ì' as a value !!! but it must be eBaal
@Frankenstein and after char *p` = args[1], what does p`point to ?Phagocyte
` Read 0x00cfa080 {lzmaUtil.exe!FileSeqInStream_Read(void *, void *, unsigned int *)} int (void *, void *, unsigned int *) *` but for *p it tell me that it's undefinedBaal
@Catullus the source code is very long ! yes the LZMA SDK contains the complete source codeBaal
Does the output window show anything useful? (View -> Output -> Show output from: Debug)Luben
B
1

The output was empty because I had put the file in the debug folder which is the same folder as the executable.

However, when I put the file in the parent directory (or the solution folder), it finally worked.

Baal answered 5/2, 2016 at 23:15 Comment(1)
You should make a well formatted answer for your question.Piker

© 2022 - 2024 — McMap. All rights reserved.