I want to run this command with execvp

gcc file1.o file2.o file3.o

I created a tab wich contain this :

char * tab = {"file1.o", "file2.o", "file3.o", NULL };

when I call execvp like that :

 execvp("gcc",tab);

I have this error :

file1.o: erreur fatale: -fuse-linker-plugin, but liblto_plugin.so not found

When I compile the files using :

gcc file1.o file2.o file3.o

there is no problem.

Note my program is not like that I wrote it like that to simplify. for the complete code look visit http://pastebin.com/zQ8pwmZd

有帮助吗?

解决方案

The first element of the argv array passed to execvp (i.e., the second argument passed to execvp) should be (just like with the argv array passed to the main function of any C program) the name of the program being executed, with the element after that being the first command-line argument. Thus, tab should be:

char * tab[] = {"gcc", "file1.o", "file2.o", "file3.o", NULL };
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top