---
title: "How to Include a file in Erlang?"  
description: "How to Include a file in Erlang?"  
author: "Tarun Kumar"  
published: 2016-03-03  
updated: 2020-09-23  
canonical: https://www.mindstick.com/interview/22993/how-to-include-a-file-in-erlang  
category: "erlang"  
tags: ["concurrent programming", "erlang"]  
reading_time: 1 minute  

---

# How to Include a file in Erlang?

**To include a file using preprocessors:***-include(FileName).**-include_lib(FileName).**FileName*, is a string which is pointing to a file. and the contents will be included according to the position of the directive. The FileName is recommended to use the file name which has *.hrl* extension for including files.**For Example:***-include("sample_file.hrl").**-include("my_records.hrl").**-include_lib("kernel/included_files/my_file.hrl").*

## Answers

### Answer by Tarun Kumar

**To include a file using preprocessors:***-include(FileName).**-include_lib(FileName).**FileName*, is a string which is pointing to a file. and the contents will be included according to the position of the directive. The FileName is recommended to use the file name which has *.hrl* extension for including files.**For Example:***-include("sample_file.hrl").**-include("my_records.hrl").**-include_lib("kernel/included_files/my_file.hrl").*


---

Original Source: https://www.mindstick.com/interview/22993/how-to-include-a-file-in-erlang

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
