I am trying to write a program that fopen()s an image so I can use it later.

I've wired my SD card adapter exactly the way shown here: [![enter image description here][1]][1]

And I'm using the following code to fopen():

FILE *streamIn;
streamIn = fopen("pic.bmp", "r");

When I compile, I get the following error:

In function main:

ccA5H011.ltrans0.o:(.text.startup+0x29a): undefined reference to `fopen'

  • I have the most up-to-date Arduino software.
  • I am using the Arduino MEGA.
  • The image "pic.bmp" is 100x100 and is not in any folder of the SD card, it is located right in it instead (If I click on the SD Card in "My Files" when it is plugged into my computer, pic.bmp is there).
  • 1
    Where did you find fopen() in here? Jun 3, 2017 at 2:18
  • 3
    You need to use the SD library and its functions instead.
    – Delta_G
    Jun 3, 2017 at 2:37

1 Answer 1


Simple answer: use the SD library provided by the IDE.

Long answer: fopen etc are designed for use with an operating system. While it is possible to 'bend' them to work without a kernel or filesystem abstraction layer, it's not easy. The AVR compiler and libraries don't provide the facilities for doing it.

So you need to use the method that is specific to the Arduino, which is contained in a library supplied with the IDE called SD.h. It has examples with it to show you how to use it.

There are other alternatives, as well, such as the much better written FatFS that has been ported to many platforms, Arduino included.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.