C Libraries - Windows

Questions about programming languages and debugging
Post Reply
eppik
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 212
Joined: 26 Mar 2006, 16:00
18
Location: Infinite Loop
Contact:

C Libraries - Windows

Post by eppik »

I was wondering where to copy the src files from a library you download so you can use them on windows (codeblocks)

Cant seem to get a library to work, even if I #include "libname.h" and then put libname.h on the project root or release root

(i'm trying to "install" the g2 graphic library that seems to be compatible with windows and is working fine for me under ubuntu (installed through software manager))

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

Re: C Libraries - Windows

Post by maboroshi »

Hey I haven't tried this but looks like they explain it quite well. If it doesn't work maybe Gogeta can help you :D

http://www.learncpp.com/cpp-tutorial/a3 ... odeblocks/

eppik
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 212
Joined: 26 Mar 2006, 16:00
18
Location: Infinite Loop
Contact:

Re: C Libraries - Windows

Post by eppik »

Thanks I wasnt sure if it would break anything if I added entries to those lists,

testing it now but appears to be working.

eppik
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 212
Joined: 26 Mar 2006, 16:00
18
Location: Infinite Loop
Contact:

Re: C Libraries - Windows

Post by eppik »

There are no .lib files included, gonna install mingw again with MSYS and try and compile the library

eppik
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 212
Joined: 26 Mar 2006, 16:00
18
Location: Infinite Loop
Contact:

Re: C Libraries - Windows

Post by eppik »

Still no go.

I compiled using the following instructions:

Code: Select all


UNIX
1. Extract package with gzip -dc g2-xxxx.tar.gz | tar xvf -
2. Run ’./con gure’
3. Optionally run ’make depend’
4. Run ’make’
5. Run ’make install’ or copy libg2.a and g2.h(p. ??), g2_X11.h(p. ??), g2_gd.h(p. ??), anf g2_PS.h(p. ??) to the default locations for library and include les. 

WINDOWS NT
1. Extract package using either the .tar.gz or the .zip distribution

2. MS Visual C++ users can build both library and demos with the supplied project le: g2.dsw(To obtain an icon and use menu functions you must also build the g2res project in g2.dsw)  ((((I tried with MSVC++ 2010 and it fails to open all project files)))

3. users of gcc or other commandline based compilers with make support continue as in Unixexample  (((I did this)))

4. It is also possible to compile g2 on winNT/95 using the free cygwin32 library and a X-windows library for windows. Theoretically it should be possible to support both X-windowsand native NT/95 windows at the same time
Then on codeblocks on the compiler settings I set the folders where the files are located, and on the project build options I added g2lib.a to the linker settings.

When I try to compile the following:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>

#include <g2_win32.h>
#include <g2_X11.h>
#include <g2.h>

int main()

{

    g2_open_X11(200,200); //This is supposed to open a X11 window with a 200x200 pixels size

return (0);
}
But it gives the following error:

Code: Select all

obj\Release\main.o:main.c|| undefined reference to `g2_open_X11'|
||=== Build finished: 1 errors, 0 warnings ===|
It only gets this error on g2_open_X11 or g2_open_win32, as in g2_open_PS it compiles successfully.

What am I missing (can anyone try and install this library and see if it works?)

Also is there any other 2D graphic library that is as simple as this one? (and fast to learn)

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Re: C Libraries - Windows

Post by Gogeta70 »

Why not just use windows gd api? It's great for 2d graphics.

Anyway, try putting the "#include <g2.h> before the includes for the other g2 headers, as the other ones may rely on declarations in the main header, though i doubt this is the problem it's worth a try. Also, you should build your project in debug mode, as release mode is only for software that is ready to be... well, released.

Anyway, it doesn't appear to be a linker error, which is good.
¯\_(ツ)_/¯ It works on my machine...

eppik
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 212
Joined: 26 Mar 2006, 16:00
18
Location: Infinite Loop
Contact:

Re: C Libraries - Windows

Post by eppik »

My main goal is to get some kind of graphic interface for a program that will read a .txt file containing lines of comma separated data, then do some live calculations with them (the file is constantly updated by another program) and then display the data and the results on the screen with refresh capabilities.

What Library do you recommend would accomplish this with ease? Preferably something quick and easy to learn.

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Re: C Libraries - Windows

Post by Gogeta70 »

I don't know why you would want to use a graphics library to display text based data, but i would recommend just using windows gd, since it's a part of the windows api. It's pretty easy to use too.

Also, the refresh rate of your program is totally in your hands. If you do use 2d graphics to display your data, i would set a timer that executed something like this:

Code: Select all


case WM_TIMER:
{
  //Parse new text data here, then call
  InvalidateRect(hwnd, NULL, FALSE); // This redraws the window by sending a WM_PAINT message to your window (you shouldn't send this message directly, just fyi)
}
break;

case WM_PAINT:
{
  PAINTSTRUCT ps;
  BeginPaint(hwnd, &ps);
  MyGraphicsDrawingFunction(); // This is a function written by you to update the screen. Should only be called between beginpaint & endpaint function calls.
  EndPaint(hwnd, &ps);
}
break;

¯\_(ツ)_/¯ It works on my machine...

eppik
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 212
Joined: 26 Mar 2006, 16:00
18
Location: Infinite Loop
Contact:

Re: C Libraries - Windows

Post by eppik »

Yeah I actually did a project that drew a map and some roads that received input from a file, and it got updated as we wished. Right now I'm trying to learn Win32 Api

Post Reply