---
title: Install the C SDK: Compile and link your code
source: https://docs.newrelic.com/docs/apm/agents/c-sdk/install-configure/install-c-sdk-compile-link-your-code
---

> #### ⚠️ EOL NOTICE
>
> From April 2022, we don't support the C SDK capability. For more details, see our [Support Forum post](https://support.newrelic.com/s/hubtopic/aAX8W0000008d0r/q1-bulk-eol-announcement-fy23).

Our C SDK auto-instruments your code so you can start monitoring applications. You can use our launcher, or follow the instructions in this document to complete a basic C SDK installation.

If you don't have one already, [create a New Relic account](https://newrelic.com/signup). It's free, forever.

[Add C data](https://one.newrelic.com/launcher/nr1-core.settings?pane=eyJuZXJkbGV0SWQiOiJ0dWNzb24ucGxnLWluc3RydW1lbnQtZXZlcnl0aGluZyJ9&cards[0]=eyJuZXJkbGV0SWQiOiJzZXR1cC1uZXJkbGV0cy5zZXR1cC1jLWludGVncmF0aW9uIiwiYWNjb3VudElkIjoyNjQwNDA5fQ==&platform[accountId]=1)

## Add the C SDK to your code [#get-new-relic]

To monitor your application with New Relic's C SDK, instrument the features you want to use:

-   Web transactions, transaction events, non-web transactions
-   Segments (for additional levels of timing details)
-   Attributes
-   Errors

Then compile and link your app against the C SDK static library.

To install the C SDK into your application's code library, follow this procedure.

**1. Verify requirements.**

1.  Make sure your application meets New Relic's [compatibility and requirements for the C SDK](https://docs.newrelic.com/docs/c-agent-compatibility-requirements).
2.  Make sure you have a license key.

**2. Include the provided header file.**

````c
#include "libnewrelic.h"
```

````

**3. Configure logging.**

Follow the procedures to [configure logging](https://docs.newrelic.com/docs/generate-logs-troubleshooting-c-sdk) for both the C SDK and the daemon. For example:

````c
if (!newrelic_configure_log("./c_sdk.log", NEWRELIC_LOG_INFO)) {
  printf("Error configuring logging.\n");
  return -1;
}
```

````

**4. Be ready to provide a meaningful app name.**

Be prepared to provide a [meaningful app name](https://docs.newrelic.com/docs/agents/manage-apm-agents/app-naming/name-your-application) in your initial application configuration; for example:

````c
newrelic_app_config_t* config;
/* ... */
config = newrelic_create_app_config("Your Application Name", "LICENSE_KEY_HERE");
```

You may give your application up to three different names, separated by `;`. [Giving your application multiple names](/docs/agents/manage-apm-agents/app-naming/use-multiple-names-app) allows you to aggregate metrics for multiple agents across an entire app or service; for example:

```c
config = newrelic_create_app_config("YOUR_APP_NAME;APP_GROUP_1;ALL_APPS", "LICENSE_KEY_HERE");
```

With the application configured, you can create a new application to connect to the daemon.

```c
newrelic_app_t* app;

/* ... */

if (!newrelic_init(NULL, 0)) {
  printf("Error connecting to daemon.\n");
  return -1;
}

/* Wait up to 10 seconds for the SDK to connect to the daemon */
app = newrelic_create_app(config, 10000);
newrelic_destroy_app_config(&config);
```

````

**5. Finish instrumenting your code.**

To finish instrumenting your code, refer to the example programs in the [C SDK **Examples** documentation on GitHub](https://github.com/newrelic/c-sdk/tree/master/examples). For more information about source code and features, see the [C SDK's source documentation for `libnewrelic.h` on GitHub](https://newrelic.github.io/c-sdk/libnewrelic_8h_source.html).

**6. Compile and link your app.**

The C SDK's `libnewrelic.a` is a static library that is already linked with the `libpcre` and `libpthread` libraries. To avoid symbol collisions in this linking step, be sure to link against each of these libraries.

In addition, to take full advantage of error traces in APM's [**Error analytics** page](https://docs.newrelic.com/docs/apm/applications-menu/error-analytics/introduction-error-analytics), link your application using GNU's `-rdynamic` linker flag. This will allow more meaningful information to appear in the stack trace for the error recording on a transaction using the C SDK's `newrelic_notice_error` API call.

For example:

````sh
gcc -o test_app test_app.c -L. -lnewrelic -lpcre -lm -pthread -rdynamic
```

````

**7. Start the daemon and check logs.**

1.  Start the C SDK's daemon. For example:

    ```sh
    ./newrelic-daemon -f -logfile newrelic-daemon.log -loglevel debug
    ```
2.  Check the output in the `c_sdk.log` and `newrelic-daemon.log` files.

    The C SDK's architecture requires that the daemon must be invoked first **before** your instrumented application is invoked.

    > #### 💡 TIP
    >
    > To see all of the available options for the C daemon: At the command line, type:
    >
    > ```sh
    > ./newrelic-daemon --help
    > ```

For more information, see the C SDK [GUIDE.md](https://github.com/newrelic/c-sdk/blob/master/GUIDE.md#getting-started).

## View app performance in New Relic [#view-apm]

To view your app's performance with [APM](https://docs.newrelic.com/docs/apm/new-relic-apm/getting-started/introduction-new-relic-apm):

1.  Generate some traffic for your app, then wait a few minutes for your app to send data to New Relic.
2.  Explore your app's data in the [APM UI](https://docs.newrelic.com/docs/apm/applications-menu/monitoring/apm-overview-page).

If no data appears within a few minutes, check your `c_sdk.log` and `newrelic-daemon.log` files for errors. If you still have problems, follow the [troubleshooting tips](https://docs.newrelic.com/docs/apm/agents/c-sdk/troubleshooting/no-data-appears-c-sdk).
