News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Console Applications

Started by Paolo_R, June 20, 2009, 08:15:55 AM

Previous topic - Next topic

Paolo_R

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

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

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

Forget my previous post! I have found the .h files - but I still get the 'unresolved external' errors.

Robert

.o and .a libraries are for Linux. You have to build the library for Windows.

Robert Wishlaw

Paolo_R

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

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

Romashka: thx. I have no idea about the  "__declspec(dllimport/dllexport) crap" but I'll give it a go tomorrow.

nicolas.sitbon


Paolo_R

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

#10
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:
#pragma comment(lib, "pdcurses.lib")
#include <curses.h>

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

  return 0;
}


enjoy!

Paolo_R

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

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

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

Can you post an example of code that reproduce the problem please.