Author Topic: Work with winBGIm in C::B  (Read 21877 times)

Offline herosz

  • Multiple posting newcomer
  • *
  • Posts: 12
Work with winBGIm in C::B
« on: January 20, 2014, 02:30:28 pm »
Hy!

I'm trying to run the simple graphic program, but no chance..

Quote
#include <iostream>
#include<graphics.h>
#include<string>

using namespace std;

int main()
{
  int gdriver = DETECT, gmode;
  initgraph (&gdriver, &gmode,""); // initialize graphics mode
    cout << "Hello world!" << endl;
    return 0;
}

I receive segmentation fault  ???

Quote
-------------- Build: Debug in ata6 (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -g -fexceptions -g -Wall -g  -c E:\C++\ata6\main.cpp -o obj\Debug\main.o
E:\C++\ata6\main.cpp: In function 'int main()':
E:\C++\ata6\main.cpp:14:35: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
mingw32-g++.exe  -o bin\Debug\ata6.exe obj\Debug\main.o  -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32  -lbgi -lbgi
Output file is bin\Debug\ata6.exe with size 1.03 MB
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 1 warning(s) (0 minute(s), 1 second(s))

Quote
[debug]Command-line: E:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args E:/C++/ata6/bin/Debug/ata6.exe
[debug]Working dir : E:\C++\ata6

Starting debugger: E:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args E:/C++/ata6/bin/Debug/ata6.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from E:\C++\ata6\bin\Debug\ata6.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.5
[debug]Copyright (C) 2012 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "i686-pc-mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.5

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source E:\Program Files\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory E:/C++/ata6/
[debug]Source directories searched: E:/C++/ata6;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: E:\C++\ata6\bin\Debug\ata6.exe

Child process PID: 3092

[debug][New Thread 3092.0xf24]
[debug]Program received signal SIGSEGV, Segmentation fault.
[debug]0x0045549f in std::string::assign(char const*, unsigned int) ()
[debug]>>>>>>cb_gdb:

Program received signal SIGSEGV, Segmentation fault.
In std::string::assign(char const*, unsigned int) () ()

[debug]> info locals
[debug]No symbol table info available.
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No symbol table info available.
[debug]>>>>>>cb_gdb:
[debug]> bt 30
[debug]#0  0x0045549f in std::string::assign(char const*, unsigned int) ()
[debug]#1  0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:

Continuing...

[debug]> cont
[debug]Continuing.
[debug]Program received signal SIGSEGV, Segmentation fault.
[debug]0x0045549f in std::string::assign(char const*, unsigned int) ()
[debug]>>>>>>cb_gdb:

Program received signal SIGSEGV, Segmentation fault.
In std::string::assign(char const*, unsigned int) () ()

[debug]> info locals
[debug]No symbol table info available.
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No symbol table info available.
[debug]>>>>>>cb_gdb:
[debug]> bt 30
[debug]#0  0x0045549f in std::string::assign(char const*, unsigned int) ()
[debug]#1  0x00000000 in ?? ()
[debug]>>>>>>cb_gdb:

Continuing...

[debug]> cont
[debug]Continuing.
[debug][Inferior 1 (process 3092) exited with code 030000000005]
[debug]>>>>>>cb_gdb:

[Inferior 1 (process 3092) exited with code 030000000005]

[debug]> quit

Debugger finished with status 0

Any help appreciated, thank's
« Last Edit: January 21, 2014, 10:37:07 pm by herosz »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7137
    • My Best Post
Re: Work with winBGIm in C::B
« Reply #1 on: January 20, 2014, 03:10:41 pm »
Compiler name and version?
Source of Library? Self Compiled?
Version of Library?

OS Name and Version?

NOTE: The winBGIm lib may NOT be 64 Bit compatible.

While looking at winBGIm; I accidentally forked a git project.
I decided to do something with the fork to test how well git reorders project structure.
https://github.com/stahta01/windows-games

I created a CB Project to build a static winBGIm lib.
I also got the tetris code from the site I forked to build and run using Code::Blocks with MinGW GCC.

Still have lots of warnings.

I suggest downloading the zip to help you use winBGIm if you are a Windows 32 bit user.
Link to zip; NOTE, I am a Git newbie so I might be doing a lot of Git Stuff wrong.
https://github.com/stahta01/windows-games/archive/master.zip

Edit: I am a advanced beginner to using the CB Debugger; so, I am NOT able to help you with that.

Tim S.
« Last Edit: January 20, 2014, 09:26:50 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline herosz

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Work with winBGIm in C::B
« Reply #2 on: January 20, 2014, 10:13:44 pm »
I use code blocks 13.12 under XP but I don't have to connection with any games (see your links)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7137
    • My Best Post
Re: Work with winBGIm in C::B
« Reply #3 on: January 21, 2014, 12:01:34 am »
I use code blocks 13.12 under XP but I don't have to connection with any games (see your links)

One [are] you are saying you are NOT on the Internet on the Internet?

You have no idea what a Compiler is?

You have no idea where you got the library from?

Tim S.
« Last Edit: January 21, 2014, 03:51:10 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline herosz

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Work with winBGIm in C::B
« Reply #4 on: January 21, 2014, 05:09:40 pm »
I left all at default as debugger log show:

>>compiler mingw32-g++.exe 4.8.1
link library >> libbgi.a -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
« Last Edit: January 22, 2014, 08:06:41 pm by herosz »

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Work with winBGIm in C::B
« Reply #5 on: January 22, 2014, 05:09:22 am »
There are no spaces between 'include's in the 2nd and 3rd lines below.
Code
#include <iostream>
#include<graphics.h>
#include<string>

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7137
    • My Best Post
Re: Work with winBGIm in C::B
« Reply #6 on: January 22, 2014, 10:22:08 am »
There are no spaces between 'include's in the 2nd and 3rd lines below.
Code
#include <iostream>
#include<graphics.h>
#include<string>


That would only cause a compiler error and normally never even causes that.

I am guessing he has a bad library but, the person seems to NOT understand the question about the library version and source.

Or Compiler version and source.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline herosz

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Work with winBGIm in C::B
« Reply #7 on: January 22, 2014, 08:22:32 pm »
I am guessing he has a bad library but, the person seems to NOT understand the question about the library version and source.

Or Compiler version and source.

Tim S.


let's try again:

I downloaded New C:B release 13.12 from http://sourceforge.net/projects/codeblocks/
codeblocks-13.12mingw-setup-TDM-GCC-481.exe   << GCC version 4.8.1

Borland BGI Graphics emulation for the MingW (GCC port) Compiler from http://winbgim.codecutter.org/
Library built with MingW 5.0.3 and GCC 3.4.5

Copy headers winbgim.h, and  graphics.h in %Program Files%\CodeBlocks\MingW\include directory.
Copy library libbgi.a in %Program Files%\CodeBlocks\MingW\lib directory.

Add  Settings >> Compiler >>linker settings
     >>        link libraries: libbgi.a
     >> other linkers options: -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32   

I don't modify anything else, my library and my compiller its from original package.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7137
    • My Best Post
Re: Work with winBGIm in C::B
« Reply #8 on: January 22, 2014, 09:04:41 pm »
Looks to be a bad Library and Compiler Combination.

But, that makes sense the ABI has changed at least twice since 3.4.5 MinGW GCC.

Edit2: ABI Application Binary Interface.

When trying to run the project I just a crash code of C.....05 which is STATUS_ACCESS_VIOLATION when using the Downloaded bgi lib.

Tim S.
« Last Edit: January 22, 2014, 09:22:39 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7137
    • My Best Post
Re: Work with winBGIm in C::B
« Reply #9 on: January 22, 2014, 09:43:51 pm »
I believe that I have uploaded a good Static Lib to here https://github.com/stahta01/windows-games/blob/master/WinBGIm/lib/libbgi.a

Note: I complied it with MinGW GCC TDM 4.8 SJLJ

Click on "Raw" button to download it.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline herosz

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Work with winBGIm in C::B
« Reply #10 on: January 23, 2014, 01:33:47 pm »
I believe that I have uploaded a good Static Lib

 Tim S.


Thank's for help,You are the Best, all work nice now  :) :-* :)