compiling and running code in terminal

Hey everyone!

I was hoping to get some tips on compiling c++ using the terminal.

I have the following files:

main.cpp abs.cpp calcDofs.cpp dbcs.cpp delta.cpp global.h gradient.cpp height.cpp intForce.cpp kuele.cpp kueta.cpp makeB.cpp makeC.cpp makeStress.cpp myfuncs.h sols.cpp weights.cpp

Note that there are header files and cpp files there.

How do I compile this using the terminal? I was trying

g++ -o elasticity main.cpp abs.cpp calcDofs.cpp dbcs.cpp delta.cpp global.h gradient.cpp height.cpp intForce.cpp kuele.cpp kueta.cpp makeB.cpp makeC.cpp makeStress.cpp myfuncs.h sols.cpp weights.cpp

but I'm getting errors (it says pretty much all my variables are not defined).

Also, assuming I get everything to compile, how do I run the elasticity.exe file?

Thanks!
Don't list your header files. If you want the executable to have the .exe file extension you should say so.
g++ -o elasticity.exe main.cpp abs.cpp calcDofs.cpp dbcs.cpp delta.cpp gradient.cpp height.cpp intForce.cpp kuele.cpp kueta.cpp makeB.cpp makeC.cpp makeStress.cpp sols.cpp weights.cpp

Something like this might also work
g++ -o elasticity.exe *.cpp
This should automatically list all the .cpp files.
hmm... so I'm still getting errors. Is there any reason why the code would be able to compile in one program but not be able to do so in another?

All the files compile and run when I use xcode, but I want to be able to run them using terminal, so that I can send the job to a server and not run it on my own machine.

Any thought?
Oh! I figured it out! One of my files had <global.h> instead of "global.h" at the top, and that was screwing everything up. Weird that the Xcode compiler didn't care about it.

Thanks for your help!
Topic archived. No new replies allowed.