6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
|
1 | |
Разное поведение программы в линукс и windows05.04.2016, 00:06. Показов 1330. Ответов 19
Метки нет (Все метки)
Программа после компиляции Qt Creator -> MinGW ведет себя не так как при обычной (GCC). В среде линукс программа ведет себя как и задумывалось, данные обрабатывались и никаких проблем не наблюдалось. Как только скомпилил в EXEшник появились проблемы. Что делать? Проект выкладывать?
ЗЫ: выложил... как работает в линукс как получилось с MinGW даже не знаю что и думать...
0
|
05.04.2016, 00:06 | |
Ответы с готовыми решениями:
19
Разное поведение программы при run и debug Разное поведение программы с отладчиком и без него Разное поведение программы в консоли и в Visual Studio 2010 C++ std::thread разное поведение на linux и windows |
1403 / 1260 / 262
Регистрация: 10.11.2013
Сообщений: 3,763
|
|
05.04.2016, 06:51 | 2 |
Проблема то в чём? Математика лажает?
0
|
05.04.2016, 07:24 | 3 | |||||
А так - из студии
Либо уточните сценарий, либо не используйте статические вектора там, где должны быть динамические.
0
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
||||||||||||||||
05.04.2016, 07:35 [ТС] | 4 | |||||||||||||||
icpu, вы имеете ввиду, что вместо
и еще - ваш вывод из студии: я работаю в среде openSuse 13.2 в Qt Creator - он расчеты выполняет корректно. Если ваши замечания я понял верно - исправлю, если нет прошу объяснить подробнее
0
|
05.04.2016, 07:41 | 5 |
Сообщение было отмечено anton_anatskiy как решение
Решение
anton_anatskiy, как минимум, выделение памяти и умный указатель
std::unique_ptr<double[]> WvResist(new double[DoubleCounter]) Весь остальной синтаксис не изменится. Добавлено через 1 минуту Ну, кроме нахождения размера массива, если эту операцию необходимо производить, используйте std::array
1
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
|
05.04.2016, 19:03 [ТС] | 6 |
0
|
7795 / 6561 / 2985
Регистрация: 14.04.2014
Сообщений: 28,683
|
|
05.04.2016, 19:17 | 7 |
Поддержка C++11 есть?
0
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
|
05.04.2016, 19:29 [ТС] | 8 |
Код
gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-suse-linux/4.8/lto-wrapper Target: i586-suse-linux Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --enable-linux-futex --program-suffix=-4.8 --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=i586-suse-linux --host=i586-suse-linux Thread model: posix gcc version 4.8.3 20140627 [gcc-4_8-branch revision 212064] (SUSE Linux) в меню QtCreator->Tools->Compiles добавил GCC компилятор с флагами -std=c++11 результата ноль
0
|
7795 / 6561 / 2985
Регистрация: 14.04.2014
Сообщений: 28,683
|
|
05.04.2016, 19:30 | 9 |
Текст ошибки какой?
0
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
|
05.04.2016, 19:36 [ТС] | 10 |
Код
../TyagovyRaschet/dialog.cpp:111:21: error: expected primary-expression before 'double' std::unique_ptr<double[]> WvResist(new double[Counter]); ^ ../TyagovyRaschet/dialog.cpp:111:21: error: expected ';' before 'double' ../TyagovyRaschet/dialog.cpp:130:10: error: 'WvResist' was not declared in this scope WvResist[i] = (ThisQgr[i] + QLenta + Qr1) * 0.032 * myTrace[i].GetLenght() + myTrace[i].GetSinus() * (ThisQgr[i] + QLenta) * myTrace[i].GetLenght(); ^ ../TyagovyRaschet/dialog.cpp:143:19: error: 'WvResist' was not declared in this scope WVObsh += WvResist[y]; ^ ../TyagovyRaschet/dialog.cpp:198:17: error: 'WvResist' was not declared in this scope Natjag += WvResist[i]; ^ ../TyagovyRaschet/dialog.cpp:229:18: error: 'WvResist' was not declared in this scope Natjag2 += WvResist[i]; ^ ../TyagovyRaschet/dialog.cpp:319:29: error: 'WvResist' was not declared in this scope BNatjag1 -= WvResist[i]; ^ ../TyagovyRaschet/dialog.cpp:383:30: error: 'WvResist' was not declared in this scope BNatjagN2 -= WvResist[i]; ^ Makefile:228: recipe for target 'dialog.o' failed make: *** [dialog.o] Error 1 19:25:26: Процесс «/usr/bin/make» завершился с кодом 2. Ошибка при сборке/установке проекта TyagovyRaschet (комплект: Desktop) When executing step "Сборка" 19:25:26: Прошло времени: 00:02. Добавлено через 3 минуты вот полный вывод Код
19:25:24: Выполняются этапы для проекта TyagovyRaschet... 19:25:24: Настройки не изменились, этап qmake пропускается. 19:25:24: Запускается: «/usr/bin/make» g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../TyagovyRaschet -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -I../TyagovyRaschet -I. -o dialog.o ../TyagovyRaschet/dialog.cpp ../TyagovyRaschet/dialog.cpp: In member function 'void Dialog::on_pushButton_clicked()': ../TyagovyRaschet/dialog.cpp:111:5: error: 'unique_ptr' is not a member of 'std' std::unique_ptr<double[]> WvResist(new double[Counter]); ^ ../TyagovyRaschet/dialog.cpp:111:21: error: expected primary-expression before 'double' std::unique_ptr<double[]> WvResist(new double[Counter]); ^ ../TyagovyRaschet/dialog.cpp:111:21: error: expected ';' before 'double' ../TyagovyRaschet/dialog.cpp:130:10: error: 'WvResist' was not declared in this scope WvResist[i] = (ThisQgr[i] + QLenta + Qr1) * 0.032 * myTrace[i].GetLenght() + myTrace[i].GetSinus() * (ThisQgr[i] + QLenta) * myTrace[i].GetLenght(); ^ ../TyagovyRaschet/dialog.cpp:143:19: error: 'WvResist' was not declared in this scope WVObsh += WvResist[y]; ^ ../TyagovyRaschet/dialog.cpp:198:17: error: 'WvResist' was not declared in this scope Natjag += WvResist[i]; ^ ../TyagovyRaschet/dialog.cpp:229:18: error: 'WvResist' was not declared in this scope Natjag2 += WvResist[i]; ^ ../TyagovyRaschet/dialog.cpp:319:29: error: 'WvResist' was not declared in this scope BNatjag1 -= WvResist[i]; ^ ../TyagovyRaschet/dialog.cpp:383:30: error: 'WvResist' was not declared in this scope BNatjagN2 -= WvResist[i]; ^ Makefile:228: recipe for target 'dialog.o' failed make: *** [dialog.o] Error 1 19:25:26: Процесс «/usr/bin/make» завершился с кодом 2. Ошибка при сборке/установке проекта TyagovyRaschet (комплект: Desktop) When executing step "Сборка" 19:25:26: Прошло времени: 00:02.
0
|
7795 / 6561 / 2985
Регистрация: 14.04.2014
Сообщений: 28,683
|
|
05.04.2016, 19:46 | 11 |
Значит, не поддерживается unique_ptr или include не вставил. Не используй его.
0
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
|
05.04.2016, 20:20 [ТС] | 13 |
не совсем понял где чего писать...
у меня есть TyagovyRaschet.pro - в нем что ли? или где то в настройках QtCreator...
0
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
|
05.04.2016, 20:33 [ТС] | 15 |
Код
#------------------------------------------------- # # Project created by QtCreator 2016-03-01T18:25:32 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = TyagovyRaschet TEMPLATE = app SOURCES += main.cpp\ dialog.cpp \ section.cpp HEADERS += dialog.hpp \ section.hpp FORMS += dialog.ui CONFIG += c++11 Код
20:30:08: Выполняются этапы для проекта TyagovyRaschet... 20:30:08: Настройки не изменились, этап qmake пропускается. 20:30:08: Запускается: «/usr/bin/make» g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../TyagovyRaschet -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -I../TyagovyRaschet -I. -o dialog.o ../TyagovyRaschet/dialog.cpp ../TyagovyRaschet/dialog.cpp: In member function 'void Dialog::on_pushButton_clicked()': ../TyagovyRaschet/dialog.cpp:113:5: error: 'unique_ptr' is not a member of 'std' std::unique_ptr<double[]> WvResist(new double[Counter]); и так далее :-| может стоит пересоздать прект... может с ним самим чего не так...
0
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
|
05.04.2016, 21:40 [ТС] | 17 |
та же фигня - Qt Creator не понимает чего от него хотят, а что бы перейти на нечто более работоспособное моих мозгов пока не хватает.
странное дело - пересоздал проект, перекомпилировал и лаги пропали... не знаю что происходит, но прога работает
0
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
|
07.04.2016, 13:07 [ТС] | 19 |
нашел решение: в файле pro указал cxx... както там +=c++11 (простите за каламбур щас на другой машине сижу на работе - как вернусь укажу правильно), а затем применил
Код
std::unique_ptr<double[]> WvResist(new double[DoubleCounter]) Код
arraysize = sizeof(WvResist) / sizeof(WvResist[0])
0
|
6 / 6 / 2
Регистрация: 28.03.2014
Сообщений: 74
|
||||||
08.04.2016, 19:12 [ТС] | 20 | |||||
0
|
08.04.2016, 19:12 | |
08.04.2016, 19:12 | |
Помогаю со студенческими работами здесь
20
Visual Studio 2010 разное поведение программы при запуске *.exe и из VS Visual Studio 2010 разное поведение программы при запуске *.exe и из VS Разное поведение DateTimePicker Разное поведение функции Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |