This guide presumes you have [cf4ocl installed in your system](Build-and-install-from-source). ### Include header Source files should first include the _cf4ocl_ header: ```c #include ``` ### Compiling and linking The following assumes a working installation of the [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/) build tool, which is usually bundled with `GLib`. If this is not the case, or if you prefer not to use this tool, click [here](Using-cf4ocl-in-a-new-project-without-pkg-config) for an alternative approach. If `pkg-config` can't find _cf4ocl_, make sure the `cf4ocl2.pc` file is in its search path. For example, if _cf4ocl2_ was installed in `/usr/local/` (which is not a default library search path in some OSes), one would first set the `PKG_CONFIG_PATH` environment variable with the appropriate value: $ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig There are two ways of using _cf4ocl_ in your project: * Using the [CMake](http://www.cmake.org/) build framework. * Manually specifying compiler options in the command line. The latter option gives a good idea of how to specify these dependencies with other build systems. #### CMake If client code uses CMake as its build system, then it's very simple to integrate _cf4ocl_. Simply add the following lines to your `CMakeLists.txt` file: ```cmake # Find required libraries find_package(PkgConfig REQUIRED) pkg_check_modules(CF4OCL2 REQUIRED cf4ocl2>=2.0.0) # Library include directories include_directories(${CF4OCL2_INCLUDE_DIRS}) ``` Then, for each target, specify _cf4ocl_ as a link library: ```cmake add_executable(myprog myprog.c) target_link_libraries(myprog ${CF4OCL2_LIBRARIES}) ``` CMake can then create the project or build files for several targets such as Unix Makefiles, Visual Studio, Xcode, Eclipse, etc. The [cf4ocl-examples](https://github.com/fakenmc/cf4ocl-examples) project follows this approach. #### Manually If you prefer to manually set build options, directly in the compiler/linker options, in a makefile or in your IDE, follow these guidelines. ##### Compiling Depending on how _cf4ocl_ was installed, it may be necessary to specify the location of the _cf4ocl_ header (and the headers of the _cf4ocl_ dependencies) with the `-I` flag. These can be obtained with `pkg-config`: pkg-config --cflags cf4ocl2 ##### Linking It is necessary to specify _cf4ocl_ (and other libraries) with the `-l` (and possibly `-L`) flags. Using `pkgconfig`, this is again a simple process: pkg-config --libs cf4ocl2 ##### Example with gcc or Clang For example, to compile and link a simple program which uses _cf4ocl_ with gcc or clang, one could do: $ gcc `pkg-config --cflags cf4ocl2` myprog.c -o myprog `pkg-config --libs cf4ocl2` ### Additional notes You can try this with the `mysum` program described in the [tutorial](http://www.fakenmc.com/cf4ocl/docs/latest/tut.html).