Home > database >  compile c file from outside of workspace
compile c file from outside of workspace

Time:12-09

I have a c file that it's located in the folder /my_test as shown below. I can run the command below successfully if I'm located on the "my_test" directory.

~/my_test$ strace -e write -f gcc -I/home/user/my_test/headers -fsyntax-only mymainfile.c  

is it possible to run the same command from a different directory? Let's say I'm in /home/user/new_test instead.

~/new_test$ strace -e write -f gcc -I/home/user/my_test/headers -fsyntax-only -I/home/user/my_test/mymainfile.c  

I believe the "-I" flag only works for header files only correct? is there an equivalent flag for the c file?

CodePudding user response:

The -I mean adding extras headers path, the same thing for -L but for precompiled objects (libraries).

So you need to remove -I you did, the command should be like this:

~/new_test$ strace -e write -f gcc -I/home/user/my_test/headers -fsyntax-only /home/user/my_test/mymainfile.c

  • Related