Git Product home page Git Product logo

c-programming-examples's Introduction

#To Compile

Glib Examples

To run the GLIB examples you require the Library glib-2.0.

One of the pain points of C is linking libraries and using them, so how do we get glib into our project the simple recommended way is to use pkg-config like so

gcc `pkg-config --cflags --libs glib-2.0` -o ex-compile ex-compile.c

To fully understand getting the library we can link it using the common -l approach.

We can can use pkg-config to find the locations and the dependent libraries required to get the library imported.

pkg-config will commonly be installed, but on a mac if not use

brew install pkg-config

Then you can search for the required library paths and header paths to compile your example with the required glib-2.0 library. This does the equivalent of the command above specifying the --cflags --libs part.

$ pkg-config --cflags glib-2.0
-I/usr/local/Cellar/glib/2.56.0/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.0/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.44/include
$ pkg-config --libs glib-2.0
-L/usr/local/Cellar/glib/2.56.0/lib -L/usr/local/opt/gettext/lib -lglib-2.0 -lintl -Wl,-framework -Wl,CoreFoundation

Then the results of these two commands can be used as so

gcc ex-compile.c -o compile -lglib-2.0 -lintl -I/usr/local/Cellar/glib/2.56.0/include/glib-2.0 -I/usr/local/Cellar/glib/2.56.0/lib/glib-2.0/include

Libcurl Example Against ElasticSearch

A nice example of very basic interaction with ElasticSearch via Rest and libCurl with C.

Programming Pearls Examples

You will find code examples and solutions for programming pearls in the relevant directories.

To run:

gcc <filename> -o <wanted-name>

Weak References

c-programming-examples's People

Contributors

perkss avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.