Error assert was not declared in this scope

I'm compiling a project in XCode where MySQL++ in included and linked to. For some reason, I keep getting the following compiler error: 'assert’ was not declared in this scope originating from c...

I’m compiling a project in XCode where MySQL++ in included and linked to. For some reason, I keep getting the following compiler error:

‘assert’ was not declared in this scope

originating from cpool.h, a header file that’s part of MySQL++. Does anyone know why this is being triggered?

EDIT: For reference, MySQL++ was installed via Macports.

asked May 25, 2010 at 22:45

Anonymous's user avatar

AnonymousAnonymous

1,7103 gold badges16 silver badges21 bronze badges

3

The most obvious answer would be that «assert.h» is not being included or is not being found in your include path. Another explanation is that the assert macro has been undefined at some point after the header was included.

Edit: Since you say that assert.h is included, and we’ll assume for the moment that it’s being found since it’s a standard header, then that leaves us with the last possibility I stated above i.e. that the macro has been undefined.

Since cpool.h itself will not be doing this it must be the case that assert.h is included earlier either by yourself or indirectly by another 3rd party header and the undefining happening between this and your inclusion of cpool.h. This can easily be tested by moving your cpool.h include to the top of your file.

answered May 25, 2010 at 22:55

Troubadour's user avatar

TroubadourTroubadour

13.2k2 gold badges37 silver badges57 bronze badges

9

In c++ adding cassert header should fix your problem.

#include <cassert>

answered Mar 9, 2016 at 14:16

MBI's user avatar

MBIMBI

5738 silver badges22 bronze badges

It could be that another library in your include path has a different «assert.h» file, and you are unknowingly including that one instead of the system’s standard <assert.h>.

I ran into this issue when writing an application that uses gstreamer on Mac OSX. It turns out that gstreamer’s include directory (/Library/Frameworks/GStreamer.framework/Headers) includes a file «assert.h», which is non-standard and an unsuitable replacement for the real assert.h. When I added -I/Library/Frameworks/GStreamer.frameworks/Headers to my compilation command, suddenly my sources, which just said «#include <assert.h>» where including the gstreamer version. This caused my compilation to fail with the same error you were getting.

answered Jul 9, 2013 at 19:55

Greg Prisament's user avatar

Greg PrisamentGreg Prisament

2,1461 gold badge16 silver badges18 bronze badges

SergeyKagen

3 / 4 / 2

Регистрация: 02.04.2018

Сообщений: 315

1

19.04.2019, 22:16. Показов 131570. Ответов 14

Метки нет (Все метки)


Простой код, но Arduino IDE напрочь отказывается принимать переменные. Что за глюк или я что-то неправильно делаю?

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void setup() {
  
  Serial.begin(9600);
  int count = 0;
  pinMode(7, INPUT);
  pinMode(13, OUTPUT);
 
}
 
void loop() {
 
  if( digitalRead(7) == HIGH ){ 
    
    while(1){ 
      delayMicroseconds(2); 
      count++;  
      if( digitalRead(7) == LOW ){ Serial.println(count); count = 0; break; }
      }
    }  
}

ошибка при компиляции «‘count’ was not declared in this scope», что не так?

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



marat_miaki

495 / 389 / 186

Регистрация: 08.04.2013

Сообщений: 1,688

19.04.2019, 23:26

2

Лучший ответ Сообщение было отмечено SergeyKagen как решение

Решение

C++
1
2
3
4
5
6
7
8
  int count = 0; //глобальная переменная
 
  void setup() {
   Serial.begin(9600);
  pinMode(7, INPUT);
  pinMode(13, OUTPUT);
 
}



1



Lavad

0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

14.09.2019, 22:33

3

Доброго времени суток!
У меня то же сообщение, но на функцию :-(
Создал функцию (за пределами setup и loop), которая только принимает вызов, ничего не возвращает:

C++
1
2
3
4
5
void myDispay(byte x, byte y, char str) {
  lcd.setCursor(x, y);
  lcd.print(temp, 1);   // выводим данные, с точностью до 1 знака после запятой
  lcd.print(str);   // выводим писанину
  }

В loop() делаю вызов:

C++
1
myDisplay(0,0,"C");

При компиляции выделяется этот вызов, с сообщением:

‘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

Цитата
Сообщение от Lavad
Посмотреть сообщение

Создал функцию (за пределами setup и loop),

Перевидите на нормальный язык.
Какие еще пределы?

В другом файле что ли?

Добавлено через 1 минуту

Цитата
Сообщение от Lavad
Посмотреть сообщение

Замучился искать инфу о декларации/обьявлении функции. Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции
Что делаю не так? В чем моя ошибка? Помогите, пожалуйста

Читать учебники по С++ не пробовали?

https://metanit.com/cpp/tutorial/3.1.php
http://cppstudio.com/post/5291/

Специфика Arduino лишь отличается тем что пред объявления не всегда нужны.

Добавлено через 7 минут
Кроме того иногда потеряй скобок {} приводят к таким ошибкам.



0



ValeryS

Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

15.09.2019, 00:09

5

Цитата
Сообщение от Lavad
Посмотреть сообщение

Везде, что находил, понимал одно: если ты вызываешь функцию, это и есть обьявление функции

это где ж такое написано?
функцию нужно объявить перед первым вызовом, сиречь сверху
можно и просто декларировать сверху

C++
1
void myDispay(byte x, byte y, char str);

а объявить уже в удобном месте



0



0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

15.09.2019, 00:48

6

Неделю назад ВПЕРВЫЕ включил Arduino Uno.
Задолго до этого писал программы под Windows (БейсикВизуал) и AVR (Basic, немного Assembler). Т.е. имеется некоторое представление об объявлении переменных, функций,… От Си всегда держался как можно дальше. Это первая и последняя причина «нечитания» книг по Си. За неделю экспериментов на Arduino мнение об этом пока не изменилось — легче вернуться к Ассму, чем копаться в Си.

Написал на том же языке, что и читал на всяких форумах и справочниках по Arduino :-). За пределами этих функций — значит не внутри них.

Обе приведенных Вами ссылок просмотрел, проверил в скетче… В итоге вылезла другая ошибка:
function ‘void myDisplay(byte, byte, char)’ is initialized like a variable

void myDisplay(byte x, byte y, char str) тоже пробовал. Та же ошибка.

Что не так на этот раз? :-(



0



Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

15.09.2019, 01:26

7

Цитата
Сообщение от Lavad
Посмотреть сообщение

В итоге вылезла другая ошибка:
function ‘void myDisplay(byte, byte, char)’ is initialized like a variable

точку с запятой в конце поставил?



1



Lavad

0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

15.09.2019, 08:46

8

Вот скетч. Проще некуда.

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <PCD8544.h>
 
float temp = 0;
static PCD8544 lcd;   // даем имя подключенному дисплею (lcd)
static const byte Lm35Pin = 14;   // аналоговый пин (A0) Arduino, к которому подключен LM35
 
//void myDisplay() = 0;
//void myDisplay(byte, byte, char, float) = 0;
//void myDisplay(byte x, byte y, char str, float temp) = 0;
 
void myDispay(byte x, byte y, char str, float temp) {
  lcd.setCursor(x, y);   // начиная с (x,y)...
  lcd.print(temp, 1);   // выводим temp
  lcd.print(str);   // выводим писанину
}
 
void setup() {
  lcd.begin(84, 48);   // инициализируем дисплей
  analogReference(INTERNAL);   // подключаем внутренний ИОН на 1.1V
}
 
void loop() {
  float temp = analogRead(Lm35Pin) / 9.31;  // подсчитываем температуру (в Цельсиях)...
  myDisplay(0, 0, "C", temp);   // отправляем данные на экран
  delay(500);   // ждем 500 мсек
}

Любое из трех так называемых «объявлений» (строки 7…9) выдает одну и ту же ошибку — я пытаюсь объявить функцию как переменную.

Добавлено через 9 минут
Попробовал так:

C++
1
void myDisplay(byte x, byte y, char str, float temp);

Компилятор задумался (я успел обрадоваться), но, зараза :-), он снова поставил свой автограф :-)

undefined reference to `myDisplay(unsigned char, unsigned char, char, float)

На этот раз он пожаловался на строку вызова функции.

Добавлено через 34 минуты
Когда что-то новое затягивает, забываешь о нормальном отдыхе, теряешь концентрацию…
Нашел ошибку. Чистейшая грамматика

C++
1
void myDispay(byte x,...

Dispay вместо Display

Добавлено через 8 минут
ValeryS, благодарю за попытку помощи!



0



ValeryS

Модератор

Эксперт по электронике

8759 / 6549 / 887

Регистрация: 14.02.2011

Сообщений: 22,972

15.09.2019, 10:36

9

Цитата
Сообщение от Lavad
Посмотреть сообщение

void myDisplay(byte, byte, char, float) = 0;

вот так не надо делать(приравнивать функцию к нулю)
так в классическом С++ объявляют чисто виртуальные функции, и класс в котором объявлена чисто виртуальная функция становится абстрактным. Означает что у функции нет реализации и в дочернем классе нужно обязательно реализовать функцию. А из абстрактного класса нельзя создать объект

Добавлено через 5 минут

Цитата
Сообщение от Lavad
Посмотреть сообщение

void myDispay(byte x, byte y, char str, float temp)

Цитата
Сообщение от Lavad
Посмотреть сообщение

myDisplay(0, 0, «C», temp);

просишь чтобы функция принимала символ char str, а передаешь строку "C"
или передавай символ

C++
1
myDisplay(0, 0, 'C', temp);

или проси передавать строку, например так

C++
1
void myDispay(byte x, byte y, char * str, float temp);



1



Avazart

Эксперт С++

8385 / 6147 / 615

Регистрация: 10.12.2010

Сообщений: 28,683

Записей в блоге: 30

15.09.2019, 12:02

10

Кроме того наверное лучше так:

C++
1
2
3
4
5
6
7
8
void myDispay(PCD8544& lcd,byte x, byte y, char str, float temp) 
{
  lcd.setCursor(x, y);   // начиная с (x,y)...
  lcd.print(temp, 1);   // выводим temp
  lcd.print(str);   // выводим писанину
}
 
myDisplay(lcd,0, 0, 'C', temp);

Тогда можно будет вынести ф-цию в отдельный файл/модуль.



1



locm

15.09.2019, 21:07

Не по теме:

Цитата
Сообщение от Lavad
Посмотреть сообщение

Arduino Uno.

Цитата
Сообщение от Lavad
Посмотреть сообщение

AVR (Basic, немного Assembler).

Arduino Uno это AVR, для которого можете писать на бейсике или ассемблере.



0



Avazart

15.09.2019, 21:21

Не по теме:

Цитата
Сообщение от locm
Посмотреть сообщение

Arduino Uno это AVR, для которого можете писать на бейсике или ассемблере.

Но лучше не надо …



0



Lavad

0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

16.09.2019, 12:12

13

Цитата
Сообщение от ValeryS
Посмотреть сообщение

это где ж такое написано?
функцию нужно объявить перед первым вызовом, сиречь сверху
можно и просто декларировать сверху
а объявить уже в удобном месте

Оказалось, что я верно понял чтиво по справочникам: если ты вызываешь функцию, это и есть обьявление функции. А сама функция может располагаться по скетчу в ЛЮБОМ месте (но за пределами setup, loop и любых других функций). И больше никаких специфических строк.

Цитата
Сообщение от ValeryS
Посмотреть сообщение

вот так не надо делать(приравнивать функцию к нулю)…

Методом проб и ошибок уже понял :-).

Цитата
Сообщение от ValeryS
Посмотреть сообщение

или передавай символ… 'C'

Если передаю в одинарных кавычках

более одного

символа, а функция ждет как char str, то выводятся на экран только самый правый из отправленных символов. Отправил «абв», а выводится «в».
Выкрутился, прописав в функции char str[], а символы отправляю через двойные кавычки.

Цитата
Сообщение от ValeryS
Посмотреть сообщение

или проси передавать строку, например так… char * str

Буквально вчера попалось это в справочнике, но как-то не дошло, что тоже мой вариант :-).

Цитата
Сообщение от Avazart
Посмотреть сообщение

Кроме того наверное лучше так:

C++
1
void myDispay(PCD8544& lcd,byte x, byte y, char str, float temp) {...}

Тогда можно будет вынести ф-цию в отдельный файл/модуль.

Благодарю за совет! Как-нибудь проверю…



0



Эксперт С++

8385 / 6147 / 615

Регистрация: 10.12.2010

Сообщений: 28,683

Записей в блоге: 30

16.09.2019, 12:54

14

Цитата
Сообщение от Lavad
Посмотреть сообщение

Оказалось, что я верно понял чтиво по справочникам: если ты вызываешь функцию, это и есть обьявление функции

Нафиг выкиньте эти справочники.
Почитайте мои ссылки.



0



0 / 0 / 0

Регистрация: 03.10.2015

Сообщений: 25

16.09.2019, 13:00

15

Ссылки Ваши добавлены в закладки. Время от времени заглядываю.
Но теория для меня — всего лишь набор понятий. Я же высказался после практической проверки. А как я понял, так оно и работает :-)



0



Skip to content



Open


Issue created Dec 16, 2018 by ax trifonov@otaku1

[regression] error: ‘assert’ was not declared in this scope

...
In file included from /tmp/makepkg/commander-genius-git/src/Commander-Genius/GsKit/graphics/GsTexture.cpp:1:
/tmp/makepkg/commander-genius-git/src/Commander-Genius/GsKit/graphics/GsTexture.h: In member function 'void GsTexture::unload()':
/tmp/makepkg/commander-genius-git/src/Commander-Genius/GsKit/graphics/GsTexture.h:139:9: error: 'assert' was not declared in this scope
         assert(mpTexture != nullptr);
         ^~~~~~
/tmp/makepkg/commander-genius-git/src/Commander-Genius/GsKit/graphics/GsTexture.h:139:9: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
/tmp/makepkg/commander-genius-git/src/Commander-Genius/GsKit/graphics/GsTexture.h:8:1:
+#include <cassert>

/tmp/makepkg/commander-genius-git/src/Commander-Genius/GsKit/graphics/GsTexture.h:139:9:
         assert(mpTexture != nullptr);
         ^~~~~~

Arch Linux, commander-genius-git package from AUR


Description


Jack Howarth



2010-09-11 01:28:07 UTC

The new g++.dg/torture/pr44972.C fails to compile at all optimization levels on x86_64-apple-darwin10...

FAIL: g++.dg/torture/pr44972.C  -O0  (test for excess errors)
FAIL: g++.dg/torture/pr44972.C  -O1  (test for excess errors)
FAIL: g++.dg/torture/pr44972.C  -O2  (test for excess errors)
FAIL: g++.dg/torture/pr44972.C  -O3 -fomit-frame-pointer  (test for excess errors)
FAIL: g++.dg/torture/pr44972.C  -O3 -g  (test for excess errors)
FAIL: g++.dg/torture/pr44972.C  -Os  (test for excess errors)
FAIL: g++.dg/torture/pr44972.C  -O2 -flto  (test for excess errors)
FAIL: g++.dg/torture/pr44972.C  -O2 -fwhopr  (test for excess errors)

The failures are of the form...


/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/gcc/testsuite/g++/../../g++ -B/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/gcc/testsuite/g++/../../ /sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/gcc/testsuite/g++.dg/torture/pr44972.C -nostdinc++ -I/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.5.0/i386/libstdc++-v3/include/x86_64-apple-darwin10.5.0 -I/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.5.0/i386/libstdc++-v3/include -I/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/libstdc++-v3/libsupc++ -I/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/libstdc++-v3/include/backward -I/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/libstdc++-v3/testsuite/util -fmessage-length=0 -O0 -S -m32 -o pr44972.s
/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/gcc/testsuite/g++.dg/torture/pr44972.C: In member function ‘const T* boost::optional<T>::operator->() const [with T = std::pair<NT, NT>]’:
/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/gcc/testsuite/g++.dg/torture/pr44972.C:137:9:   instantiated from here
/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/gcc/testsuite/g++.dg/torture/pr44972.C:77:35: error: ‘__assert_fail’ was not declared in this scope

Using built-in specs.
COLLECT_GCC=g++-4
COLLECT_LTO_WRAPPER=/sw/lib/gcc4.6/libexec/gcc/x86_64-apple-darwin10.5.0/4.6.0/lto-wrapper
Target: x86_64-apple-darwin10.5.0
Configured with: ../gcc-4.6-20100910/configure --prefix=/sw --prefix=/sw/lib/gcc4.6 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.6/info --enable-languages=c,c++,fortran,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-ppl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.6 --enable-checking=yes
Thread model: posix
gcc version 4.6.0 20100910 (experimental) (GCC)


Comment 1


Jack Howarth



2010-09-11 01:29:47 UTC

Created attachment 21770 [details]
preprocessed source for g++.dg/torture/pr44972.C  -O0

Generated with...

/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/gcc/testsuite/g++/../../g++ -B/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/gcc/testsuite/g++/../../ /sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/gcc/testsuite/g++.dg/torture/pr44972.C -nostdinc++ -I/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.5.0/i386/libstdc++-v3/include/x86_64-apple-darwin10.5.0 -I/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.5.0/i386/libstdc++-v3/include -I/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/libstdc++-v3/libsupc++ -I/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/libstdc++-v3/include/backward -I/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20100910/libstdc++-v3/testsuite/util -fmessage-length=0 -O0 -S -m32 --save-temps -o pr44972.s

on x86_64-apple-darwin10.


Comment 2


Rainer Orth



2010-09-13 16:43:59 UTC

Same on *-*-solaris2* (probably on all non-Linux targets).


Comment 3


Jonathan Wakely



2010-09-13 17:04:52 UTC

the test already includes <cassert> so presumably the fix is simply to replace line 77 with 

 T const* operator->() const { assert(this->is_initialized()) ; return this->get_ptr_impl() ; }


Comment 4


Paolo Carlini



2010-09-13 17:12:25 UTC

I agree with Jon: the expansion of assert to __assert_fail, etc, isn't portable, the testcase should simply use assert.


Comment 5


Jack Howarth



2010-09-13 19:13:16 UTC

I can confirm that the change...

Index: gcc/testsuite/g++.dg/torture/pr44972.C
===================================================================
--- gcc/testsuite/g++.dg/torture/pr44972.C	(revision 164251)
+++ gcc/testsuite/g++.dg/torture/pr44972.C	(working copy)
@@ -74,7 +74,7 @@
 
     T const& get() const ;
 
-    T const* operator->() const { ((this->is_initialized()) ? static_cast<void> (0) : __assert_fail ("this->is_initialized()", "pr44972.C", 78, __PRETTY_FUNCTION__)) ; return this->get_ptr_impl() ; }
+    T const* operator->() const { assert(this->is_initialized()) ; return this->get_ptr_impl() ; }
 
 } ;
 

...eliminates the g++.dg/torture/pr44972.C -O0 failures on x86_64-apple-darwin10 at both -m32 and -m64.


Comment 6


Paolo Carlini



2010-09-13 21:01:48 UTC

Please properly post the patch to the mailing list and let's resolve this rather straightforward issue. Thanks.


Comment 8


Martin Jambor



2010-09-14 11:53:08 UTC

Sorry, I messed up when I tried to remove includes from the testcase.  Thanks for fixing it.

#
5 лет, 6 месяцев назад

(отредактировано

5 лет, 6 месяцев назад)

Темы:

47

Сообщения:

11417

Участник с: 17 февраля 2013

RusWolf
собирается без проблем

Потверждаю, собирается без проблем — устанавливать не стал

==> Выход из окружения fakeroot.
==> Завершена сборка пакета libodb 2.4.0-1 (Вс июл 23 23:43:06 MSK 2017)
==> Очистка...

==> Продолжить установку libodb ? Да/нет [Y/n]
==> [v]просмотреть содержимое пакета [c]проверить пакет при помощи namcap
==> ---------------------------------------------------------------------
==> y

загрузка пакетов...
разрешение зависимостей...
проверка конфликтов...

Пакеты (1) libodb-2.4.0-1

Будет установлено:  0,59 MiB

:: Приступить к установке? [Y/n] 

Ошибки не исчезают с опытом — они просто умнеют

Aoizora

#
5 лет, 6 месяцев назад

Темы:

7

Сообщения:

39

Участник с: 13 июля 2017

Господа, libodb я собрал. Проблема со сборкой libodb-qt! Мои последние посты именно об этом. Я просто не стал начинать новую тему.

vasek

#
5 лет, 6 месяцев назад

Темы:

47

Сообщения:

11417

Участник с: 17 февраля 2013

Aoizora
Господа, libodb я собрал. Проблема со сборкой libodb-qt! Мои последние посты именно об этом. Я просто не стал начинать новую тему.

Просто я не до конца скопировал — сейчас довел до конца, с установкой

==> Выход из окружения fakeroot.
==> Завершена сборка пакета libodb-qt 2.4.0-1 (Вс июл 23 23:53:38 MSK 2017)
==> Очистка...

==> Продолжить установку libodb-qt ? Да/нет [Y/n]
==> [v]просмотреть содержимое пакета [c]проверить пакет при помощи namcap
==> ---------------------------------------------------------------------
==> y

загрузка пакетов...
разрешение зависимостей...
проверка конфликтов...

Пакеты (1) libodb-qt-2.4.0-1

Будет установлено:  0,20 MiB

:: Приступить к установке? [Y/n] y
(1/1) проверка ключей                                                     [##########################################] 100%
(1/1) проверяется целостность пакета                                      [##########################################] 100%
(1/1) загрузка файлов пакетов                                             [##########################################] 100%
(1/1) проверка конфликтов файлов                                          [##########################################] 100%
(1/1) проверяется доступное место                                         [##########################################] 100%
:: Обработка изменений пакета...
(1/1) установка libodb-qt                                                 [##########################################] 100%
:: Работа послеоперационных перехватов...
(1/1) Arming ConditionNeedsUpdate...

Ошибки не исчезают с опытом — они просто умнеют

Aoizora

#
5 лет, 6 месяцев назад

Темы:

7

Сообщения:

39

Участник с: 13 июля 2017

А у меня не собирается. Как можно указать QtCore и к каким файлам Qt надо указывать пути?

serg66

#
5 лет, 6 месяцев назад

Темы:

0

Сообщения:

91

Участник с: 01 ноября 2016

Aoizora
А у меня не собирается.

А у меня тоже собирается…
может это…

vasek

#
5 лет, 6 месяцев назад

Темы:

47

Сообщения:

11417

Участник с: 17 февраля 2013

Aoizora
А у меня не собирается. Как можно указать QtCore и к каким файлам Qt надо указывать пути?

Ты слишком много собирал ручками и устанавливал без pacman, плюс к этому не обновлялся целый год. И там сейчас не Arch, а солянка.
Во вторых не нужно никаких export CPPFLAGS и export LDFLAGS , все должно цепляться автоматом. Это используют обычно при ручной сборке и используют это, насколько я, как чайник в этом деле, понимаю для configure, а не для make — т.е. используется это по другому, погугли на эту тему, начни, например. с этого
И рекомендую все ставить через pacman/AUR, а не через make.

Ошибки не исчезают с опытом — они просто умнеют

vasek

#
5 лет, 6 месяцев назад

(отредактировано

5 лет, 6 месяцев назад)

Темы:

47

Сообщения:

11417

Участник с: 17 февраля 2013

Небольшое дополнение.
LDFLAGS и CPPFLAGS — используются если имеются нестандартные пути размещения

 LDFLAGS - linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir>
CPPFLAGS - (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>

И один из способов их применения

So you set them as an environment variable; configure determines LDFLAGS and CPPFLAGS by checking config files and the environment. You can set them like this ...
export CPPFLAGS='-I/home/..../include'
export LDFLAGS='-L/home/..../lib/'
./configure

Для нормальной системы все пути стантартизованы и используя pacman или AUR ничего этого не нужно, все найдется автоматом.
UPD … обрати внимание на использование CPPFLAGS — нужно писат I , а не l, как написал ты (от слова Include)

PS … посмотри этот топик, где Natrio дал ссылку как он использовал это для лечения конкретного пакета

Ошибки не исчезают с опытом — они просто умнеют

Aoizora

#
5 лет, 6 месяцев назад

Темы:

7

Сообщения:

39

Участник с: 13 июля 2017

Статья про Qt на вики не помогла.
Запустил сборку так:


makepkg CPPFLAGS+='-I/usr/include/qt/QtCore/5.9.1/QtCore' LDFLAGS+='-L/usr/lib'

Получаю ошибку:


checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/home/user/GIT/libodb-qt/src/libodb-qt-2.4.0':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
==> ERROR: A failure occurred in build().
    Aborting...

Может, я указываю не те директории? Директории с либами пытался искать в /lib и в /usr/lib — безуспешно. Есть ли способ определить, где находятся инклуды и либы конкретной версии qt?

Aoizora

#
5 лет, 6 месяцев назад

Темы:

7

Сообщения:

39

Участник с: 13 июля 2017

Поможет ли переустановка Qt5 и насколько опасно ломать зависимости, например, sddm?


[[email protected] Desktop]$ sudo pacman -R qt5-base
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: qbs: removing qt5-base breaks dependency 'qt5-base'
:: qt5-doc: removing qt5-base breaks dependency 'qt5-base'
:: qt5-script: removing qt5-base breaks dependency 'qt5-base'
:: qt5-sensors: removing qt5-base breaks dependency 'qt5-base'
:: qt5-tools: removing qt5-base breaks dependency 'qt5-base'
:: qt5-xmlpatterns: removing qt5-base breaks dependency 'qt5-base'
[[email protected] Desktop]$ sudo pacman -R qt5
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: qbs: removing qt5-base breaks dependency 'qt5-base'
:: qbs: removing qt5-script breaks dependency 'qt5-script'
:: qtcreator: removing qt5-tools breaks dependency 'qt5-tools'
:: qtcreator: removing qt5-quickcontrols breaks dependency 'qt5-quickcontrols'
:: qtcreator: removing qt5-quickcontrols2 breaks dependency 'qt5-quickcontrols2'
:: qtcreator: removing qt5-webengine breaks dependency 'qt5-webengine'
:: sddm: removing qt5-declarative breaks dependency 'qt5-declarative'
[[email protected] Desktop]$

RusWolf

#
5 лет, 6 месяцев назад

RusWolf avatar

Темы:

11

Сообщения:

2413

Участник с: 16 июля 2016

Aoizora, как ты устанавливаешь пакеты из AUR ?

Example

This error happens if a unknown object is used.

Variables

Not compiling:

#include <iostream>

int main(int argc, char *argv[])
{
    {
        int i = 2;
    }

    std::cout << i << std::endl; // i is not in the scope of the main function

    return 0;
}

Fix:

#include <iostream>

int main(int argc, char *argv[])
{
    {
        int i = 2;
        std::cout << i << std::endl;
    }

    return 0;
}

Functions

Most of the time this error occurs if the needed header is not
included (e.g. using std::cout without #include <iostream>)

Not compiling:

#include <iostream>

int main(int argc, char *argv[])
{
    doCompile();

    return 0;
}

void doCompile()
{
    std::cout << "No!" << std::endl;
}

Fix:

#include <iostream>

void doCompile(); // forward declare the function

int main(int argc, char *argv[])
{
    doCompile();

    return 0;
}

void doCompile()
{
    std::cout << "No!" << std::endl;
}

Or:

#include <iostream>

void doCompile() // define the function before using it
{
    std::cout << "No!" << std::endl;
}

int main(int argc, char *argv[])
{
    doCompile();

    return 0;
}

Note: The compiler interprets the code from top to bottom (simplification). Everything must be at least declared (or defined) before usage.

Tips: If you need C++ homework help from experts, you can always rely upon assignment helpers.

Hi there,

I’ve been trying to compile the stub_mm included with the metamod source files but I can’t seem to get around errors relating to static_assert

Code:

In file included from ../core/sourcehook/sourcehook.h:118:0,
                 from ../core/ISmmPlugin.h:37,
                 from stub_mm.h:18,
                 from stub_mm.cpp:16:
../core/sourcehook/FastDelegate.h:181:2: error: identifier �static_assert� is a keyword in C++11 [-Werror=c++0x-compat]
  static_assert(sizeof(InputClass)==sizeof(u) && sizeof(InputClass)==sizeof(Outp
  ^
In file included from ../core/sourcehook/sourcehook.h:118:0,
                 from ../core/ISmmPlugin.h:37,
                 from stub_mm.h:18,
                 from stub_mm.cpp:16:
../core/sourcehook/FastDelegate.h: In function �OutputClass fastdelegate::detail::horrible_cast(InputClass)�:
../core/sourcehook/FastDelegate.h:182:29: error: there are no arguments to �static_assert� that depend on a template parameter, so a declaration of �static_assert� must be available [-fpermissive]
    "Can't use horrible cast");
                             ^
../core/sourcehook/FastDelegate.h:182:29: note: (if you use �-fpermissive�, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
../core/sourcehook/FastDelegate.h: In static member function �static fastdelegate::detail::GenericClass* fastdelegate::detail::SimplifyMemFunc<N>::Convert(X*, XFuncType, GenericMemFuncType&)�:
../core/sourcehook/FastDelegate.h:297:82: error: there are no arguments to �static_assert� that depend on a template parameter, so a declaration of �static_assert� must be available [-fpermissive]
 atic_assert(N >= 100, "Unsupported memeber function pointer on this compiler")

Code:

../core/sourcehook/FastDelegate.h:799:16: error: �static_assert� was not declared in this scope
   static_assert(sizeof(UnvoidStaticFuncPtr)==sizeof(this), "Can't use evil meth

Anyone have any ideas why this would happen? I thought static_assert is a part of c++1X, why would it give me errors that its not declared in the scope.

I have tried using GCC4.1, GCC4.8 and GCC5.2.

Any ideas?

Понравилась статья? Поделить с друзьями:
  • Error assembling war webxml attribute is required or pre existing web inf web xml
  • Error assembling jar
  • Error based sql инъекция
  • Error based sql injection это
  • Error asm operand has impossible constraints