Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:04:41+00:00 2026-06-12T19:04:41+00:00

I am cross compiling (host: x86 linux) for raspberry pi (ARM) using arm-bcm2708hardfp-linux-gnueabi-g++ When

  • 0

I am cross compiling (host: x86 linux) for raspberry pi (ARM) using

arm-bcm2708hardfp-linux-gnueabi-g++

When I choose g++ it all works out fine and compiles.
But when cross compiling I get:

 error: 'close' was not declared in this scope

This is the simplified source code

#include <iostream>
#include <fcntl.h>

using namespace std;
int fd;

int main() {
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    close(fd);
    return 0;
}

Any idea? Did I forget to include smth? I am using eclipse as IDE.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:04:42+00:00Added an answer on June 12, 2026 at 7:04 pm

    I believe it’s as simple as this: close is declared in <unistd.h>, not <fcntl.h>. To find out what header file declares a symbol, you should always check the man pages first.

    #include <iostream>
    #include <unistd.h>  // problem solved! it compiles!
    
    using namespace std;
    int fd;
    
    int main() {
        cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
        close(fd);  // but explicitly closing fd 0 (stdin) is not a good idea anyway
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am interested in cross-compiling a Linux kernel for an ARM target on a
I am in the process of cross-compiling Fontconfig for Windows using Mingw-w64 (the host
my program compiles and runs fine under Linux. Cross-compiling it for Windows also is
I would like to cross-compile a simple program for ARM architecture using the arm-linux-gcc
How should I handle character encoding/conversion issues when cross-compiling from Linux to Windows using
I'm using Debian Squeeze, cross compiling for windows targets using mingw32. For a Linux
IF(UNIX) # CROSS COMPILATION! ON/OFF #SET(CMAKE_C_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-gcc) #SET(CMAKE_CXX_COMPILER /home/username/projects/buildroot/output/host/usr/bin/arm-linux-g++) #SET(CMAKE_C_COMPILER /home/username/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-gcc) #SET(CMAKE_CXX_COMPILER /home/username/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-g++) here
NOTE: Please do not comment on all the perils of cross-compiling. Thank you. I
I'm cross compiling to an arm embedded system and receiving an error that I
I am cross compiling linux kernel. I have the following program which compiles perfectly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.