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
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.
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
Forget my previous post! I have found the .h files - but I still get the 'unresolved external' errors.
.o and .a libraries are for Linux. You have to build the library for Windows.
Robert Wishlaw
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!!
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.
Romashka: thx. I have no idea about the "__declspec(dllimport/dllexport) crap" but I'll give it a go tomorrow.
Don't waste your time, take directly the Windows version of pdcurses ;)
http://sourceforge.net/project/downloading.php?groupname=gnuwin32&filename=pdcurses-2.6.exe&use_mirror=freefr (http://sourceforge.net/project/downloading.php?groupname=gnuwin32&filename=pdcurses-2.6.exe&use_mirror=freefr)
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?
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 (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:
#pragma comment(lib, "pdcurses.lib")
#include <curses.h>
int main(void)
{
initscr();
printw("Hello World !!!\n");
refresh();
getch();
endwin();
return 0;
}
enjoy!
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.
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 (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 (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.
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?
Can you post an example of code that reproduce the problem please.
Nicolas: I have attached testcurs.c from the demo programs.
Compiles and builds OK but just hangs when run in an XP console.
OK, i just understand what you say, it is the normal behaviour. You have 2 possiblities :
- put pdcurses.dll in system32
- add C:\Program Files\PellesC\Bin to the %PATH% environment variable
Hi,
third option:
put the .dll beside the executable inside your project folder.
I personally prefere this because of dllhell and different versions of dlls ;-)
Greetings
Seltsamuel
Quote from: Seltsamuel on June 22, 2009, 10:19:28 AM
Hi,
third option:
put the .dll beside the executable inside your project folder.
I personally prefere this because of dllhell and different versions of dlls ;-)
Greetings
Seltsamuel
you need an update : http://www.davidlenihan.com/2007/07/winsxs.html (http://www.davidlenihan.com/2007/07/winsxs.html)
Well, I've spent the day compiling sample programs found in the Index of /HOWTO/NCURSES-Programming-HOWTO.
Some compile and run fine, some I needed to correct for them to run, and others either hang, or bomb due to access violations.
However, I have discovered that the Menu and Form functionality is not implemented in PDCurses - apart from the basic curses functionality only the Panels functions are implemented. This rather limits the use of PDCurses as a windowing/menu based/form data entry library. A bit disappointing really.
Here are all the functions defined by the standard : http://opengroup.org/onlinepubs/007908799/xcurses/curses.h.html (http://opengroup.org/onlinepubs/007908799/xcurses/curses.h.html)
Please can you tell me which functions aren't implemented?
thanks.
Nicolas: PDCurses provides curses.h and panel.h functions but the menu.h and form.h are not provided.
I tried compiling a menu demo program starting thus:
#pragma comment(lib, "pdcurses.lib")
#include <curses.h>
#include <menu.h> ....
and got this error:
C:\WORKAREA\pdcurses tests\menu1\menu1.c(3): fatal error #1035: Can't find include file <menu.h>.
I researched this and found some conversations involving W McBrine (who I believe is supporting PDCurses) and they implied menus and forms are not available.
menu.h is an extension, it is not part of opengroup standard.
OK, it may not be part of opengroup standard but it certainly seems to be part of ncurses. I believed that pdcurses was an implementation of ncurses.
QuotePDCurses is a public domain curses library for DOS, OS/2, Win32, X11 and SDL, implementing most of the functions available in X/Open and System V R4 curses
Nicolas: I obviously misunderstood. thanks for your assistance.
You're welcome. :)
Quote from: Paolo_R on June 21, 2009, 11:39:14 PMOne 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?
pdcurses.dll must be either in the same directory as exe file you're running or in c:\windows\system32 directory
Would you please post a link to a zip file with the working examples? Or you can e-mail them to me and I will make them avalable on my site....
jwzumwalt(at)rock(dot)com
I cut'n'pasted the source code from http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/ncurses_programs/
Got em', thanks!