I'm making the switch from windows to macOS and most seems to be going well. I will be producing terminal applications for my own use only. I can use Xcode IDE but its file system seems overly-complicated and I'd just prefer compiling from the terminal command line. Personal preference I guess.
I have created a program main.cpp that contains one function outside the "main" section of the program. It compiles and runs with just fine with g++ main1.cpp -o main1.app.
I separated the external function into its own 'externalfunction.cpp' file and left the prototype in the main program. g++ main2.cpp external function.cpp -o main2.app compiles and works just fine.
I moved the function prototype declaration to its own .h file ('jjdate.h'). and I removed the function prototype declaration from the main3.cpp file. and I added #include "jjdate.h" to the main3.cpp
All files are in the same directory ./cprograms
I moved to the ./cprograms directory (cd./cprograms)
I expected g++ main3.cpp external function.cpp -I jjdate.h to work. Not so.
I've tried multiple different arguments to the -I such "./cpgrograms/jjdate.h" and "./" with and without file name,
I've also tried eliminating the -I altogether.
Including the -I seems to come closest but I always get the following error
Here's the command line Jon--Kathys-MBP:cprograms jon$ g++ main3.cpp externalfunction.cpp -I "jjdate.h" -o main3.app
I get the same error no matter what I put in after the -I (ex. jjdate.h with or without quotes, with or without path etc.) All files are in the same directory.
main3.cpp:16:10: error: expected "FILENAME" or
include “jjdate.h”
I haven't included the code because the question is already long. The code works. But making a library file and ".h" file is not. I think I'm close.