-2

I was working on a C program with Code::Blocks on Windows when I realized I needed the pdcurses library, so I downloaded it and build it, but after importing it into Code::Blocks, when I ran some test code, I got these errors:

Enter image description here

The code is:

#include <stdio.h>
#include <stdlib.h>
#include <pdcurses.a>

int main(){

    initsrc();

    printw("Hello world!\n");
    refresh();
    getch();

    endwin();
    return 0;
}

How can I resolve this?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Please review *[Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/)* (e.g., *"Images should only be used to illustrate problems that* ***can't be made clear in any other way,*** *such as to provide screenshots of a user interface."*) and [do the right thing](https://stackoverflow.com/posts/71533440/edit). Thanks in advance. – Peter Mortensen May 01 '23 at 18:26
  • There must be a canonical question somewhere for importing binary things. This can't be the first one. – Peter Mortensen May 01 '23 at 18:42
  • Similar (but not necessarily the same cause): *[Daemon on embedded Linux device using BusyBox be written in C or as a script](https://stackoverflow.com/questions/28759855/)* (2015), *[Why do I get weird stray errors with file 'cxxopts.hpp' and Meson + Ninja build?](https://stackoverflow.com/questions/73410284/)* (2022), and *[Android NDK build errors, \221, etc](https://stackoverflow.com/questions/13065790/)* (2012). – Peter Mortensen May 01 '23 at 18:42

2 Answers2

2

A file with an extension of ".a" is a library file, which is binary. You don't include that in your code with #include.

Instead, you should #include the header file(s) associated with this library, and then link in the library file in the project configuration.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dbush
  • 205,898
  • 23
  • 218
  • 273
0

This code was tested to work with PDCurses. Notice you don't need other #include:

#include <curses.h>

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

    endwin();
    return 0;
}
Manol
  • 11
  • 1