NO

Author Topic: Console Applications  (Read 16792 times)

Paolo_R

  • Guest
Console Applications
« on: June 20, 2009, 08:15:55 AM »
I want to develop console applications and was wondering whether I can use Pelles C with a library like curses/ncurses/pdcurses (or any other free libraries supporting text mode windowing-type interfaces.)

If so, how would I set up Pelles C to recognise the libraries and include them in compilation?

Are there any such libraries available that I could use with Pelles C?

Thanks

Romashka

  • Guest
Re: Console Applications
« Reply #1 on: June 20, 2009, 02:06:40 PM »
In Project Options dialog add paths to *.lib and *.h of the required libraries on Folders tab, and add the required .lib file on Linker tab,
and of course #include the required headers in your C source code.
I don't know if any of *curses libraries are usable on Windows.

Paolo_R

  • Guest
Re: Console Applications
« Reply #2 on: June 21, 2009, 03:22:05 AM »
Romashka: thank you for the reply. I have found PDcurses (public domain) which comes with .c source code. It also comes with .o files and 2 libraries - panel.a and pdcurses.a, each of which contains the .o files. These are supposed to work under any x 86 architecture.There are no .h files.

I tried compiling the small test program (that came with the package) with BCC5.5 but received a lot of 'unresolved external' errors which I guess is due to the fact that I was unable to #include <curses.h>

Is there any way I could build the libraries under Pelles C and somehow extract the required .h files?

Thanks

Paolo_R

  • Guest
Re: Console Applications
« Reply #3 on: June 21, 2009, 04:51:06 AM »
Forget my previous post! I have found the .h files - but I still get the 'unresolved external' errors.

Offline Robert

  • Member
  • *
  • Posts: 245
Re: Console Applications
« Reply #4 on: June 21, 2009, 05:41:28 AM »
.o and .a libraries are for Linux. You have to build the library for Windows.

Robert Wishlaw

Paolo_R

  • Guest
Re: Console Applications
« Reply #5 on: June 21, 2009, 05:50:47 AM »
Robert:yes, I am now realising that! However, I don't know how to build the library for Windows - I've never built a library before. Any clues - or even solutions - would help!!

Romashka

  • Guest
Re: Console Applications
« Reply #6 on: June 21, 2009, 11:13:57 AM »
Well, the easiest way to try is New -> Project -> Win32 Static library (LIB) then add all .c files from PDCurses to it and then build it.
This way you will get a static library which means every application you link with it will have it embedded in the .exe.

Creating a DLL is more complex becase of __declspec(dllimport/dllexport) crap, and it depends if the library already supports DLL building or you have to add it by yourself.

Paolo_R

  • Guest
Re: Console Applications
« Reply #7 on: June 21, 2009, 11:40:10 AM »
Romashka: thx. I have no idea about the  "__declspec(dllimport/dllexport) crap" but I'll give it a go tomorrow.

nicolas.sitbon

  • Guest
Re: Console Applications
« Reply #8 on: June 21, 2009, 12:20:49 PM »

Paolo_R

  • Guest
Re: Console Applications
« Reply #9 on: June 21, 2009, 01:04:39 PM »
Nicolas: thanks. I have downloaded the file.

Which lib would I use with Pelles C? In the GnuWin\lib directory there are the following files:

curses.dll.a
curses.lib
curses-bcc.lib
libcurses.a
libpanel.a

In the GnuWin\bin directory there is also curses2.dll. What is the purpose of this?


nicolas.sitbon

  • Guest
Re: Console Applications
« Reply #10 on: June 21, 2009, 02:04:54 PM »
I'm sorry, bad link.
Here is the way:
- download pdcurses for Win32 from : http://sourceforge.net/project/downloading.php?group_id=30480&filename=pdc34dllw.zip&a=65239577
- extract it
- put *.h in "C:\Program Files\PellesC\Include"
- put pdcurses.lib in "C:\Program Files\PellesC\Lib"
- put pdcurses.dll in "C:\Program Files\PellesC\bin"

test:
Code: [Select]
#pragma comment(lib, "pdcurses.lib")
#include <curses.h>

int main(void)
{
   initscr();
   printw("Hello World !!!\n");
   refresh();
   getch();
   endwin();

   return 0;
}

enjoy!
« Last Edit: June 21, 2009, 02:12:56 PM by nicolas.sitbon »

Paolo_R

  • Guest
Re: Console Applications
« Reply #11 on: June 21, 2009, 10:34:29 PM »
Nicolas: thank you. The test program compiles and executes fine.

However I get a (linking ?) warning:

C:\Program Files\PellesC\Include\curses.h(345): warning #2016: Extended attribute 'dllimport' requires option /Ze; ignored.

What does this mean and how do I eliminate it?

Also why do I need to add the line:

#pragma comment(lib, "pdcurses.lib")

Thanks for your help.



nicolas.sitbon

  • Guest
Re: Console Applications
« Reply #12 on: June 21, 2009, 11:23:38 PM »
In order to suppress the warning, go to Project -> Project Options -> Compiler -> check "Enable Microsoft extensions"
and if you want explanation on that, see this site : http://msdn.microsoft.com/en-us/library/dabb5z75.aspx

About the pragma comment directive, it's a compiler hint, that says, hey guyz, link me with pdcurses, see http://msdn.microsoft.com/en-us/library/d9x1s805(VS.71).aspx.
You can safely remove it, and go to Project -> Project Options -> Linker -> add pdcurses.lib in "Library and object files".

Bye.

Paolo_R

  • Guest
Re: Console Applications
« Reply #13 on: June 21, 2009, 11:39:14 PM »
Nicolas: thanks again.

One comment, I have tried building some of the demo programs that came with the GnuWin version. Some wouldn't run 'cos they couldn't 'find' pdcurses.dll, so I put a copy in my windows/system32 folder and that solved that problem. Why do I need to do this if Pelles C compiler already has a copy in its /bin folder?

A couple of the other demos just hang with a blank screen and flashing cursor. Not sure why if the code is 'common' to all pdcurses platform versions. Something to do with platform-specific #defines?


nicolas.sitbon

  • Guest
Re: Console Applications
« Reply #14 on: June 21, 2009, 11:42:18 PM »
Can you post an example of code that reproduce the problem please.