Posts

Showing posts with the label command line

Create C Program with Dynamic Link Library (DLL) using Command Line (Implicit Link) in Windows

Image
The following procedure is to create a C program with a dynamic link library using Developer Command Prompt for VS2012. Brief Introduction to Dynamic Link Library (DLL) The important difference between DLL and static library is that the code of external function is stored in the DLL file, whereas when linking with static library, the code of the external functions is copied to the execution file of the application program. With static library, you just need an execution file whereas with DLL you need both the execution file and the DLL file for the program to work. Implicit or Explicit Link When creating DLL, we have the choice of implicit linking or explicit linking. Since implicit linking is easier and common, this article will focus on implicit linking. For additional information please refer to the following: Linking Implicitly Linking Explicitly Determining Which Linking Method to Use Examples: The following example is a normal C program with functions.  ...

Create C Program with Static Library using Command Line in Windows

Image
The following procedure is to create C program with static library using Microsoft Visual Studio Express 2012 command prompt. For brief introduction to software library, please refer to the previous post Create C Program with Static Library using Visual Studio . Click here for procedure of creating a C program using Visual Studio . Example: The following example is a normal C program with functions without using any custom static library.  #include <stdio.h> #define PI 3.1415; double PowerOf2 (double UserNumber); double PowerOf3 (double UserNumber); double CircleArea (double UserRadius); double CircleCircum (double UserRadius); int main ( ) { double p2 = 10.0; double p3 = 5.0; double radius = 4.0; printf ("The number %.2f to the power of 2 is %.2f. \n", p2, PowerOf2(p2)); printf ("The number %.2f to the power of 3 is %.2f. \n", p3, PowerOf3(p3)); printf ("A circle with a radius of %.2f, the area is %.2f. \n", radius, CircleArea(...

C Programming in Mac OS X

Image
Programming C in Mac OS X requires you to install Xcode. Fortunately, this development tool is available free. Go to your App Store and search for Xcode. Install Xcode by clicking on " Free " or " Install ". Please note that the installation will take quite some time. There are two methods of writing and compiling a C program. The first method is using Xcode and the second method is using command line. Both methods require installation of Xcode. Using Command Line  To use command line to compile a C program, we need to enable gcc (or llvm-gcc). Under Xcode, select Xcode >> Preferences ,  click on the Downloads tab. You should see a line " Command Line Tools ". Click on the install button on the right. Close Xcode when you are done. You can use TextEdit to create a simple C program. Alternatively, you can also use vim from the Terminal. Open the Terminal and navigate to the folder you would like to store the program. C...