New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
ZeroGraviti opened this issue
Dec 29, 2017
· 7 comments
Comments
I dont have Windows 10 and I did try MinGW…. with no success at all. The only shot I have of some success is with cygwin and I believe I did make some progress… Will update OP with this.
I am currently stuck with
netbase.cpp:720:41: error: `strerror_r' was not declared in this scope
if (strerror_r(err, buf, sizeof(buf)))
which might be caused because of no glibc support (perhaps) in cygwin, so maybe I have to try something like newlib
?
Not really sure… some help/advice would be great !
I have pastebin’ed the latest config.log link and the error console output in the OP….
@datsec @molxyz @laanwj The compilation is because <string.h>
is probably not being included somewhere somehow. The function strerror_r()
is not being declared in the scope in which it is used in netbase.cpp
. So, it’s not being included somewhere, or perhaps it just isn’t there within Cygwin. However, I believe it’s under the newlib
source files in Cygwin which implement the strerror_r()
function.
MarcoFalke
changed the title
Unable to compile 0.15 on Cygwin
Unable to compile 0.15 on Cygwin (strerror_r was not declared)
Jul 18, 2018
Is this still an issue with a recent version of Bitcoin Core? If yes, what are the steps to reproduce?
bitcoin
locked as resolved and limited conversation to collaborators
Feb 15, 2022
- Forum
- The Ubuntu Forum Community
- Ubuntu Specialised Support
- Ubuntu Servers, Cloud and Juju
- Server Platforms
- [ubuntu] Getting errors compiling application
-
Getting errors compiling application
I am trying to compile an application on ubuntu server, but it keeps failing. This is the return:
Code:
c++ -MD -I. -g0 -O6 -Winline -fno-check-new -fno-exceptions -fomit-frame-pointer -fexpensive-optimizations -c acl.cpp -o .objs/acl.o c++ -MD -I. -g0 -O6 -Winline -fno-check-new -fno-exceptions -fomit-frame-pointer -fexpensive-optimizations -c gre.cpp -o .objs/gre.o gre.cpp: In member function ‘void Proxy::greThread()’: gre.cpp:38: error: ‘memset’ was not declared in this scope gre.cpp:121: error: ‘memcpy’ was not declared in this scope make: *** [.objs/gre.o] Error 1 c++ -MD -I. -g0 -O6 -Winline -fno-check-new -fno-exceptions -fomit-frame-pointer -fexpensive-optimizations -c link.cpp -o .objs/link.o acl.cpp: In member function ‘void Proxy::addACL(char*)’: acl.cpp:21: error: ‘strdup’ was not declared in this scope make: *** [.objs/acl.o] Error 1 c++ -MD -I. -g0 -O6 -Winline -fno-check-new -fno-exceptions -fomit-frame-pointer -fexpensive-optimizations -c log.cpp -o .objs/log.o link.cpp: In constructor ‘Proxy::Link::Link(Proxy*, int)’: link.cpp:107: error: ‘memset’ was not declared in this scope link.cpp: In member function ‘bool Proxy::Link::tcpPacket(bool)’: link.cpp:306: error: ‘memset’ was not declared in this scope link.cpp:310: error: ‘strcmp’ was not declared in this scope link.cpp:330: error: ‘strcpy’ was not declared in this scope make: *** [.objs/link.o] Error 1 c++ -MD -I. -g0 -O6 -Winline -fno-check-new -fno-exceptions -fomit-frame-pointer -fexpensive-optimizations -c options.cpp -o .objs/options.o log.cpp: In member function ‘void Proxy::fail(const char*, int32_t, const char*, bool, const char*, const char*, ...)’: log.cpp:140: error: ‘strerror’ was not declared in this scope log.cpp:168: error: ‘exit’ was not declared in this scope make: *** [.objs/log.o] Error 1 c++ -MD -I. -g0 -O6 -Winline -fno-check-new -fno-exceptions -fomit-frame-pointer -fexpensive-optimizations -c pairs.cpp -o .objs/pairs.o options.cpp: In function ‘void help(bool)’: options.cpp:44: error: ‘exit’ was not declared in this scope options.cpp: In member function ‘void Proxy::options(char**)’: options.cpp:71: error: ‘exit’ was not declared in this scope options.cpp:94: warning: deprecated conversion from string constant to ‘char*’ pairs.cpp: In member function ‘bool Proxy::parseAddress(uint32_t*, uint32_t*, const char*)’: pairs.cpp:21: error: ‘strdup’ was not declared in this scope pairs.cpp:37: error: ‘free’ was not declared in this scope pairs.cpp:44: error: ‘free’ was not declared in this scope pairs.cpp: In member function ‘void Proxy::addProxyPair(char*)’: pairs.cpp:63: error: ‘strdup’ was not declared in this scope make: *** [.objs/options.o] Error 1 pairs.cpp: In constructor ‘Proxy::Pair::Pair(Proxy*, const char*, uint32_t, uint32_t, const char*, uint32_t, uint32_t)’: pairs.cpp:204: error: ‘memset’ was not declared in this scope c++ -MD -I. -g0 -O6 -Winline -fno-check-new -fno-exceptions -fomit-frame-pointer -fexpensive-optimizations -c utils.cpp -o .objs/utils.o make: *** [.objs/pairs.o] Error 1 utils.cpp: In member function ‘bool Proxy::resolve(uint32_t*, const char*, bool)’: utils.cpp:33: error: ‘sscanf’ was not declared in this scope utils.cpp: In member function ‘void Proxy::daemonize()’: utils.cpp:132: error: ‘exit’ was not declared in this scope utils.cpp:138: error: ‘exit’ was not declared in this scope make: *** [.objs/utils.o] Error 1 make: Target `all' not remade because of errors.
Does anybody know what is going wrong and how to fix it?
-
Re: Getting errors compiling application
How long have you been programming?
You need several include files e.g. <string.h>
Tags for this Thread
Bookmarks
Bookmarks

Posting Permissions
Я написал кросс-платформенный код, который дает текущую дату (мм / дд / гг) и время (чч / мм / сс) и полную дату (ггггммдд). Этот код работает в Windows (MSVS2015), но не работает в Linux (GCC) 4.8.5).
Мой код
#include <iostream>
#ifdef WIN32
#include <windows.h>
#else
#include <cerrno>
#endif
#ifdef WIN32
#include <direct.h>
#include <io.h>
#else
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
#endif
#include <ctime>
#include <bitset>
#include <cstdlib> /*atol*/
#include <iomanip>
#include <stdexcept>
#include <cstring>
#include <cstdio>
#include <fstream>
using namespace std;
template <size_t size>
void GetNowDateTime(char(&c_date)[size], char(&c_time)[size])
{
time_t t;
struct tm now;
strcpy_s(c_date, "00/00/00");
strcpy_s(c_time, "00:00:00");
time(&t);
if (localtime_s(&now, &t) != 0) return;
char temp[3];
sprintf_s(temp, "%.2d", now.tm_mon + 1);
memcpy(c_date, temp, 2);
sprintf_s(temp, "%.2d", now.tm_mday);
memcpy(c_date + 3, temp, 2);
sprintf_s(temp, "%.2d", now.tm_year - 100);
memcpy(c_date + 6, temp, 2);
sprintf_s(temp, "%.2d", now.tm_hour);
memcpy(c_time, temp, 2);
sprintf_s(temp, "%.2d", now.tm_min);
memcpy(c_time + 3, temp, 2);
sprintf_s(temp, "%.2d", now.tm_sec);
memcpy(c_time + 6, temp, 2);
}
int GetToday(void)
{
time_t t;
struct tm now;
time(&t);
if (localtime_s(&now, &t) != 0) return 0;
return (now.tm_year + 1900) * 10000 + (now.tm_mon + 1) * 100 + now.tm_mday;
}
bool OpenOuputFile(ofstream& outputFile)
{
char buf[1024];
#ifdef WIN32
strcpy_s(buf, "C:\Myfolder\output.txt");
#else
strcpy_s(buf, "/home/myfolder/output.txt");
#endif
outputFile.open(buf, ios::out);
if (!outputFile)
{
char szErrorMsg[1024];
strerror_s(szErrorMsg, errno);
cout << "Unable to open input file. " << buf << " Error:" << szErrorMsg << endl;
return 0;
}
return 1;
}
// Вот моя основная функция
int main()
{
char today[9];
char time[9];
ofstream outputFile;
GetNowDateTime(today, time);
int yyyymmdd = GetToday();
if (OpenOuputFile(outputFile))
{
outputFile << "GetNowDateTime functions given is:-t" << today << "t" << time << endl;
outputFile << "GetToday Function given is:-t" << yyyymmdd << endl;
}
else
cout << "No output file written" << endl;
return 0;
}
Ошибки в Linux есть
TimeDate.cpp: In function ‘void GetNowDateTime(char (&)[size], char (&)[size])’:
TimeDate.cpp:34:26: error: there are no arguments to ‘localtime_s’ that depend on a template parameter, so a declaration of ‘localtime_s’ must be available [-fpermissive]
if (localtime_s(&now, &t) != 0) return;
TimeDate.cpp:36:40: error: there are no arguments to ‘sprintf_s’ that depend on a template parameter, so a declaration of ‘sprintf_s’ must be available [-fpermissive]
imeDate.cpp: In function ‘int GetToday()’:
TimeDate.cpp:55:26: error: ‘localtime_s’ was not declared in this scope
if (localtime_s(&now, &t) != 0) return 0;
TimeDate.cpp:74:31: error: ‘strerror_s’ was not declared in this scope
strerror_s(szErrorMsg, errno);
TimeDate.cpp:31:29: error: ‘strcpy_s’ was not declared in this scope
strcpy_s(c_date, "00/00/00");
Эта программа работает в Visual Studio 2015 (Windows) и GCC 4.8.5 (Linux).
Я включил все необходимые заголовки, но он показывает ошибки при компиляции в Linux.
Почему указанные выше ошибки отображаются в Linux, пожалуйста, скажите мне.
SergeyKagen 3 / 4 / 2 Регистрация: 02.04.2018 Сообщений: 315 |
||||
1 |
||||
19.04.2019, 22:16. Показов 132175. Ответов 14 Метки нет (Все метки)
Простой код, но Arduino IDE напрочь отказывается принимать переменные. Что за глюк или я что-то неправильно делаю?
ошибка при компиляции «‘count’ was not declared in this scope», что не так?
__________________
0 |
marat_miaki 495 / 389 / 186 Регистрация: 08.04.2013 Сообщений: 1,688 |
||||
19.04.2019, 23:26 |
2 |
|||
Решение
1 |
Lavad 0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
||||||||
14.09.2019, 22:33 |
3 |
|||||||
Доброго времени суток!
В loop() делаю вызов:
При компиляции выделяется этот вызов, с сообщением: ‘myDisplay’ was not declared in this scope Замучился искать инфу о декларации/обьявлении функции. Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции P.S. Код, что использовал в качестве функции, работоспособен. Раньше находился в loop(). Скетч постепенно разрастается, много однотипных обращений к дисплею…
0 |
8385 / 6147 / 615 Регистрация: 10.12.2010 Сообщений: 28,683 Записей в блоге: 30 |
|
14.09.2019, 23:57 |
4 |
Создал функцию (за пределами setup и loop), Перевидите на нормальный язык. В другом файле что ли? Добавлено через 1 минуту
Замучился искать инфу о декларации/обьявлении функции. Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции Читать учебники по С++ не пробовали? https://metanit.com/cpp/tutorial/3.1.php Специфика Arduino лишь отличается тем что пред объявления не всегда нужны. Добавлено через 7 минут
0 |
ValeryS Модератор 8759 / 6549 / 887 Регистрация: 14.02.2011 Сообщений: 22,972 |
||||
15.09.2019, 00:09 |
5 |
|||
Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции это где ж такое написано?
а объявить уже в удобном месте
0 |
0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
|
15.09.2019, 00:48 |
6 |
Неделю назад ВПЕРВЫЕ включил Arduino Uno. Написал на том же языке, что и читал на всяких форумах и справочниках по Arduino :-). За пределами этих функций — значит не внутри них. Обе приведенных Вами ссылок просмотрел, проверил в скетче… В итоге вылезла другая ошибка: void myDisplay(byte x, byte y, char str) тоже пробовал. Та же ошибка. Что не так на этот раз?
0 |
Модератор 8759 / 6549 / 887 Регистрация: 14.02.2011 Сообщений: 22,972 |
|
15.09.2019, 01:26 |
7 |
В итоге вылезла другая ошибка: точку с запятой в конце поставил?
1 |
Lavad 0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
||||||||||||
15.09.2019, 08:46 |
8 |
|||||||||||
Вот скетч. Проще некуда.
Любое из трех так называемых «объявлений» (строки 7…9) выдает одну и ту же ошибку — я пытаюсь объявить функцию как переменную. Добавлено через 9 минут
Компилятор задумался (я успел обрадоваться), но, зараза :-), он снова поставил свой автограф undefined reference to `myDisplay(unsigned char, unsigned char, char, float) На этот раз он пожаловался на строку вызова функции. Добавлено через 34 минуты
Dispay вместо Display Добавлено через 8 минут
0 |
ValeryS Модератор 8759 / 6549 / 887 Регистрация: 14.02.2011 Сообщений: 22,972 |
||||||||
15.09.2019, 10:36 |
9 |
|||||||
void myDisplay(byte, byte, char, float) = 0; вот так не надо делать(приравнивать функцию к нулю) Добавлено через 5 минут
void myDispay(byte x, byte y, char str, float temp)
myDisplay(0, 0, «C», temp); просишь чтобы функция принимала символ
или проси передавать строку, например так
1 |
Avazart 8385 / 6147 / 615 Регистрация: 10.12.2010 Сообщений: 28,683 Записей в блоге: 30 |
||||
15.09.2019, 12:02 |
10 |
|||
Кроме того наверное лучше так:
Тогда можно будет вынести ф-цию в отдельный файл/модуль.
1 |
locm |
15.09.2019, 21:07
|
Не по теме:
Arduino Uno.
AVR (Basic, немного Assembler). Arduino Uno это AVR, для которого можете писать на бейсике или ассемблере.
0 |
Avazart |
15.09.2019, 21:21
|
Не по теме:
Arduino Uno это AVR, для которого можете писать на бейсике или ассемблере. Но лучше не надо …
0 |
Lavad 0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
||||
16.09.2019, 12:12 |
13 |
|||
это где ж такое написано? Оказалось, что я верно понял чтиво по справочникам:
вот так не надо делать(приравнивать функцию к нулю)… Методом проб и ошибок уже понял :-).
или передавай символ… Если передаю в одинарных кавычках более одного символа, а функция ждет как
или проси передавать строку, например так… Буквально вчера попалось это в справочнике, но как-то не дошло, что тоже мой вариант :-).
Кроме того наверное лучше так:
Тогда можно будет вынести ф-цию в отдельный файл/модуль. Благодарю за совет! Как-нибудь проверю…
0 |
8385 / 6147 / 615 Регистрация: 10.12.2010 Сообщений: 28,683 Записей в блоге: 30 |
|
16.09.2019, 12:54 |
14 |
Оказалось, что я верно понял чтиво по справочникам: если ты вызываешь функцию, это и есть обьявление функции Нафиг выкиньте эти справочники.
0 |
0 / 0 / 0 Регистрация: 03.10.2015 Сообщений: 25 |
|
16.09.2019, 13:00 |
15 |
Ссылки Ваши добавлены в закладки. Время от времени заглядываю.
0 |