I reply in that OLD thread only because actually i am in the same situation and i found a banal typo error in graphics.h;
downloaded from mantainer’s website; i notice too many posts throughout the web refer to that problem;
I suppose that library is quite old and i am wondering how all that time the maintainer prof Main was not aware about
i.e. how no one in the world complained to him —instead complain on the forums— about that annoyance;
Hopefully now on newcomers (mostly students i guess) will compile and run their winbgim app without that particular
headache
Enjoy
Let’s recap
As @WhoAmI reported the following error is presented to me too but the fact is that C:B(Release 13.12 rev 9501 (2013/12/25 19:25:45) gcc 4.7.1 Windows/unicode — 32 bit)/mingw(4.8.1) system is right
c:program filescodeblocksmingwbin..libgccmingw324.4.1........includegraphics.h|302|error: redefinition of 'int right'|
c:program filescodeblocksmingwbin..libgccmingw324.4.1........includegraphics.h|302|error: 'int right' previously declared here|
||=== Build finished: 2 errors, 0 warnings ===|
i did a try also with Geany/mingw system and the result was the same(always with same mingw)
g++ -m32 -Wall -std=c++11 -pedantic -g "first-sample.c" -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 -o "first-sample.exe" (in directory: C:Documents and SettingsOwnerΕπιφάνεια εργασίαςBOBcourcesNPTELbooksProgrlangCbooksC50bookstest)
In file included from c:mingwincludegraphics.h:29:0,
from first-sample.c:1:
c:mingwincludegraphics.h:302:40: error: redefinition of 'int right'
int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
^
In file included from first-sample.c:1:0:
c:mingwincludegraphics.h:302:27: error: 'int right' previously declared here
int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX,
^
Compilation failed.
so my curiosity rise high and i saw that in line 302 graphics.h had a typo error.
... int left=0, int right=0, int right=INT_MAX, int bottom=INT_MAX, ...
to be surest i downloaded the C:B-EP and compare my file with the graphics.h there and definitely my graphics.h ( i had downloaded it from Mainland’s Uni page** http://www.cs.colorado.edu/~main/cs1300-old/cs1300/doc/bgi/bgi.html precisely from http://www.cs.colorado.edu/~main/bgi/dev-c++/ —because was the first result in google—) had that typo error.
So all we in the world (except maybe the lucky users of CodeBlocks-EP) had an erratic graphics.h file
I notify (i hope main@colorado.edu is a valid/active email address) Michael Main trough an email about that hopefully he will correct it. Meanwhile i hope this post be proficient for who encounter the above mentioned errors
PS:
After have corrected the graphics.h (int right=0 —> int top=0 ) actually the sample program first-sample.cxx compile flawlessly but crash in runtime . Ok that’s another problem.
Instead C:B_EP work as intended;
<edit>
About first-sample.c ‘s crashing i have followed prof. Main’s instructions (download graphics.h , libbgim.a and put them in include and lib dirs respectively but Main refers to his CSCI 1300 Software Package instead i put them in mingw’s include and lib dirs i guess the problem is there; when i have time to see what is going on i post here
<edit>
<final_edit 18/07/14>
was not a file’s placement in the right directories issue but a libbgim.a «oldness» problem (thanks for the hint codeur ) i.e. libbgim.a was too old to live and behave as intended so i downloaded the library’s source from http://winbgim.codecutter.net/ and recompile it with the actual version of mingw (4.8.1) and substitute the freshly
compiled libbgim.a in place of the ancestral libbgim.a(downloaded from the maintainers webpage ) and as if by magic all was tele-transported in our days and worked flawlessly as it should
Prof Micahel Main reply me (15/7/14) a thanking for my advise but up to few minutes ago all his pages related to winbgim library remain as were. Dunno his timing constraints so meanwhile right now I put here as attachment the 2 necessary and sufficient files for use the library i.e. graphics.h and the newly compiled libbgim.a; a bit later i put them in my account in github too.
Unfortunately here is not permitted upload .h and .a (i am wondered why?) files so after you download the files do not forget to delete the fake *.patch extension in each of them
<final_edit>
**
Many Computer Science faculty have recommended the use of graphics to help
motivate the study of introductory programming and as a vehicle to help students
understand how to use libraries and to call functions.
To reduce the overhead required to introduce graphics, we decided to use
WinBGIm (Windows BGI with the addition of mouse control), which is a package based
on the Turbo Pascal BGI (Borland Graphics Interface) library.
WinBGIm was created to run on top of the Win32 library by Michael Main and his
students at the Computer Science Department, University of Colorado Boulder.
Several development platforms appropriate for CS 1 courses have incorporated
WinBGIm. Quincy (developed by Al Stevens) is an open-source student oriented
C++ IDE that includes WinBGIm as well as more advanced libraries.
A command-line platform based on the open-source GNU g++ compiler and the
emacs program editor is distributed by the University of Colorado. WinBGIm is
also available for (n.d.r. nowadays deprecated and buggy) Bloodshed Software’s Dev-C++ ,
Microsoft’s Visual Studio C++ (n.d.r and obviously for Codeblocs — Edu Portable that includes
as well other more advanced libraries) .
excerpt from Hanly-Koffman’s Problem Solving and Program Design in C
Cheers,
Harry
[attachment deleted by admin]
zhundik 0 / 0 / 1 Регистрация: 12.03.2014 Сообщений: 61 |
||||
1 |
||||
20.11.2014, 14:29. Показов 3212. Ответов 6 Метки нет (Все метки)
Ребят, подскажите, хочу начать работать с графикой, но не пойму что делаю не так…
Если ли другие способы вывести графику через CodeBlock?
__________________
0 |
zss Модератор 12641 / 10135 / 6102 Регистрация: 18.12.2011 Сообщений: 27,170 |
||||
20.11.2014, 14:47 |
2 |
|||
int right=0, int right=INT_MAX 2 раза right
0 |
zhundik 0 / 0 / 1 Регистрация: 12.03.2014 Сообщений: 61 |
||||
20.11.2014, 15:09 [ТС] |
3 |
|||
и что делать? это же стандартный заголовок ((( Добавлено через 4 минуты Добавлено через 7 минут Добавлено через 9 минут
теперь просто программа завершается(
0 |
2062 / 618 / 41 Регистрация: 23.10.2011 Сообщений: 4,468 Записей в блоге: 2 |
|
20.11.2014, 15:13 |
4 |
zhundik, OpenGL для графики — лучше не придумаешь.
1 |
zhundik 0 / 0 / 1 Регистрация: 12.03.2014 Сообщений: 61 |
||||
20.11.2014, 15:31 [ТС] |
5 |
|||
Спасибо,поставил) Работает, НО элементарные функции и фигуры все равно не знаю как вывести(( пример:
0 |
16495 / 8988 / 2205 Регистрация: 30.01.2014 Сообщений: 15,611 |
|
20.11.2014, 17:41 |
6 |
и что делать? это же стандартный заголовок ((( Второй right переименуй в right1 например.
и не повторяйте слово int: У него там функция и параметры, это не же не паскаль, чтобы так делать
0 |
Модератор 12641 / 10135 / 6102 Регистрация: 18.12.2011 Сообщений: 27,170 |
|
20.11.2014, 18:49 |
7 |
У него там функция Пардон, не разглядел — уж очень мелкие скобочки!
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
20.11.2014, 18:49 |
Помогаю со студенческими работами здесь codeblocks Codeblocks CodeBlocks Codeblocks! Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 7 |
- Forum
- General C++ Programming
- WinBGIm error: redefinition of ‘int righ
WinBGIm error: redefinition of ‘int right’
I don’t know whether it suits this forum or not but I just wanted to tell (the world) something. I recently decided to try out WinBGIm library, so I downloaded the package and after setting up all the compiler and linker settings, ran my simple «Hello World» Code. But I got the following message from my compiler (MinGW, CodeBlocks IDE).
d:codeblocksmingwbin..libgccmingw324.4.1........includegraphics.h|302|error: redefinition of 'int right'| d:codeblocksmingwbin..libgccmingw324.4.1........includegraphics.h|302|error: 'int right' previously declared here| ||=== Build finished: 2 errors, 0 warnings ===|
After having googled the problem I found out nothing (If you don’t count a suggestion to use CodeBlocks-EP as a Solution).
As I was taking a look at the header files, I found the problem (yeah!!!)
The problem was with the function printimage.
The original declaration was
|
|
So what I did is that, I simply changed one of the «right» (the later former one) variable to «top». That’s it.
|
|
As simple as that (shame on me to waste a full 2 hours at that problem). So, I decided to put this information for other many WinBGIm beginners.
Last edited on
Is it possible that you changed the wrong ‘right’? This way ‘top’ is equal to ‘bottom’ and ‘left’ to ‘right’ which is a rather strange rectangle ~0.
if you replace the first ‘right’ with ‘top’ and leave the second ‘right’ as is it’d be the maximum possible rectangle
@coder777, sorry, my bad. I shall edit it ASAP. And thanks for the correction..
Topic archived. No new replies allowed.