compile a c program with gcc in cmd ( .c, .cpp and .h) -


i have 3 files:

 mainoperations.cpp  operations.c  operations.h 

(does functions, not importat in, looking)

i trying run cmd gcc this: "gcc -o c:...\ mainoperations.cpp operations.c operations.h" "no such file or directory" of them. so, question run gcc cmd? (windows 7)thx!

the command have written in worst case overwrite mainoperations.cpp.

there several things might have missed.

  1. you have cpp file, c++ , not c, not need gcc, g++ (g++ able handle c code! if have mixed code, use g++).

  2. the parameter -o specifies output file, have pointed cpp file, thus, if compiler gets work, overwrites file binary code , gives fuzzy errors.

  3. you dont need pass .h or .hpp files compiler, need tell compiler find them

the easiest way achieve want be:

g++ -o "c:\mybinary.exe" "c:\path\to\files\*.cpp" "c:\path\to\files\*.c" -i"c:\path\to\files\" 

what does: generetes file c:\mybinary.exe out of cpp , c files in c:\path\to\files whilst searching headerfiles (not only) in c:\path\to\files, .h files lie.

all of have been told manpage or documentation, next time, show research effort. there plenty of resources telling how use compiler!


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -