General Flow
Build static library and link it
Build static library
Link static library
OR
OR
Build dynamic library and link
Build dynamic library
Build executable file with dynamic link
OR
OR
Attached source files
#define RETURN_IF(expr, code) { if(expr) {return code;}}
int isEven(int num);
#include "test.h"
#include <iostream>
using namespace std;
int isEven(int num)
{
if (num % 2 == 0)
{
cout << num << " is Even" << endl;
}
else
{
cout << num << " is not Even" << endl;
}
return 0;
}
#include "test.h"
#include <iostream>
using namespace std;
int main()
{
return isEven(99);
}
Attached common commands options
command option | mean |
---|---|
-E | stop after preprocessor, generate .i files. |
-S | Stop after compile and generate .s files. |
-c | Stop after assemble and generate .o files. |
-o | add output file after option. |
-shared | Generate dynamic library. |
-L | Add search path for libraries. For example -L./ means add current path to library search path. |
-l | Add link needed library. For example -ltest means add libtest.a or libtest.so to link. |