aarch64-linux-gnu/sys/cdefs.h:24:11: fatal error: features.h: No such file or directory
by oti from LinuxQuestions.org on (#6FR3B)
Hi there!
It would be great if you could assist me on this problem. I do not think it is a question about a missing header file, although it seems so, as I generally can build programs (without using the curl library). It could also be something in the CMakeLists.txt.
I did all kinds of sudo upgrades and updates and build-essential etc..
Anyway, I am getting this message when attempting to build a c++ executable on my raspberry pi 400 (OS is Raspberry PI OS 64 BIT Full version from 2023-10-10) for a pico w. The complete message is as follows:
oti@raspberrypi:~/pico/test/build $ cmake --build .
[ 1%] Performing build step for 'PioasmBuild'
[100%] Built target pioasm
[ 1%] No install step for 'PioasmBuild'
[ 1%] Completed 'PioasmBuild'
[ 4%] Built target PioasmBuild
[ 5%] Built target cyw43_driver_picow_cyw43_bus_pio_spi_pio_h
[ 6%] Performing build step for 'ELF2UF2Build'
[100%] Built target elf2uf2
[ 6%] No install step for 'ELF2UF2Build'
[ 6%] Completed 'ELF2UF2Build'
[ 9%] Built target ELF2UF2Build
[ 10%] Built target bs2_default
[ 11%] Built target bs2_default_padded_checksummed_asm
[ 11%] Building CXX object CMakeFiles/test.dir/test.cpp.obj
In file included from /usr/include/newlib/wchar.h:16,
from /usr/include/newlib/c++/12.2.1/cwchar:44,
from /usr/include/newlib/c++/12.2.1/bits/postypes.h:40,
from /usr/include/newlib/c++/12.2.1/iosfwd:40,
from /usr/include/newlib/c++/12.2.1/ios:38,
from /usr/include/newlib/c++/12.2.1/ostream:38,
from /usr/include/newlib/c++/12.2.1/iostream:39,
from /home/oti/pico/test/test.cpp:1:
/usr/include/aarch64-linux-gnu/sys/cdefs.h:24:11: fatal error: features.h: No such file or directory
24 | # include <features.h>
| ^~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/test.dir/build.make:76: CMakeFiles/test.dir/test.cpp.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1510: CMakeFiles/test.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
My CMakeLists.txt contains this:
cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake)
project(test_project C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
add_executable(test test.cpp)
pico_sdk_init()
pico_enable_stdio_usb(test 1)
pico_enable_stdio_uart(test 1)
pico_add_extra_outputs(test)
target_include_directories(test PRIVATE ${CMAKE_CURRENT_LIST_DIR} )
target_link_libraries(test pico_cyw43_arch_lwip_threadsafe_background pico_stdlib)
My program looks like this (may contain errors - I never got far enough to see..):
#include <iostream>
#include <string>
#include <curl/curl.h>
size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
size_t totalSize = size * nmemb;
output->append(static_cast<char*>(contents), totalSize);
return totalSize;
}
int main() {
// Initialize libcurl
CURL* curl = curl_easy_init();
if (!curl) {
std::cerr << "Error initializing libcurl" << std::endl;
return 1;
}
// Specify the URL of the file to download
std::string url = "https://api.energidataservice.dk/dataset/Elspotprices";
// Create a string to store the downloaded data
std::string downloadedData;
// Set the URL and callback function
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &downloadedData);
// Perform the request
CURLcode res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cerr << "Failed to download the file: " << curl_easy_strerror(res) << std::endl;
}
else {
std::cout << "File downloaded successfully." << std::endl;
// The downloaded file contents are stored in 'downloadedData'
std::cout << "Downloaded Data:\n" << downloadedData << std::endl;
}
// Clean up libcurl
curl_easy_cleanup(curl);
return 0;
}
It would be great if you could assist me on this problem. I do not think it is a question about a missing header file, although it seems so, as I generally can build programs (without using the curl library). It could also be something in the CMakeLists.txt.
I did all kinds of sudo upgrades and updates and build-essential etc..
Anyway, I am getting this message when attempting to build a c++ executable on my raspberry pi 400 (OS is Raspberry PI OS 64 BIT Full version from 2023-10-10) for a pico w. The complete message is as follows:
oti@raspberrypi:~/pico/test/build $ cmake --build .
[ 1%] Performing build step for 'PioasmBuild'
[100%] Built target pioasm
[ 1%] No install step for 'PioasmBuild'
[ 1%] Completed 'PioasmBuild'
[ 4%] Built target PioasmBuild
[ 5%] Built target cyw43_driver_picow_cyw43_bus_pio_spi_pio_h
[ 6%] Performing build step for 'ELF2UF2Build'
[100%] Built target elf2uf2
[ 6%] No install step for 'ELF2UF2Build'
[ 6%] Completed 'ELF2UF2Build'
[ 9%] Built target ELF2UF2Build
[ 10%] Built target bs2_default
[ 11%] Built target bs2_default_padded_checksummed_asm
[ 11%] Building CXX object CMakeFiles/test.dir/test.cpp.obj
In file included from /usr/include/newlib/wchar.h:16,
from /usr/include/newlib/c++/12.2.1/cwchar:44,
from /usr/include/newlib/c++/12.2.1/bits/postypes.h:40,
from /usr/include/newlib/c++/12.2.1/iosfwd:40,
from /usr/include/newlib/c++/12.2.1/ios:38,
from /usr/include/newlib/c++/12.2.1/ostream:38,
from /usr/include/newlib/c++/12.2.1/iostream:39,
from /home/oti/pico/test/test.cpp:1:
/usr/include/aarch64-linux-gnu/sys/cdefs.h:24:11: fatal error: features.h: No such file or directory
24 | # include <features.h>
| ^~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/test.dir/build.make:76: CMakeFiles/test.dir/test.cpp.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1510: CMakeFiles/test.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
My CMakeLists.txt contains this:
cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake)
project(test_project C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
add_executable(test test.cpp)
pico_sdk_init()
pico_enable_stdio_usb(test 1)
pico_enable_stdio_uart(test 1)
pico_add_extra_outputs(test)
target_include_directories(test PRIVATE ${CMAKE_CURRENT_LIST_DIR} )
target_link_libraries(test pico_cyw43_arch_lwip_threadsafe_background pico_stdlib)
My program looks like this (may contain errors - I never got far enough to see..):
#include <iostream>
#include <string>
#include <curl/curl.h>
size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* output) {
size_t totalSize = size * nmemb;
output->append(static_cast<char*>(contents), totalSize);
return totalSize;
}
int main() {
// Initialize libcurl
CURL* curl = curl_easy_init();
if (!curl) {
std::cerr << "Error initializing libcurl" << std::endl;
return 1;
}
// Specify the URL of the file to download
std::string url = "https://api.energidataservice.dk/dataset/Elspotprices";
// Create a string to store the downloaded data
std::string downloadedData;
// Set the URL and callback function
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &downloadedData);
// Perform the request
CURLcode res = curl_easy_perform(curl);
if (res != CURLE_OK) {
std::cerr << "Failed to download the file: " << curl_easy_strerror(res) << std::endl;
}
else {
std::cout << "File downloaded successfully." << std::endl;
// The downloaded file contents are stored in 'downloadedData'
std::cout << "Downloaded Data:\n" << downloadedData << std::endl;
}
// Clean up libcurl
curl_easy_cleanup(curl);
return 0;
}