Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jul 2020 17:27:38 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 247976] pkg-config produces icorrect linkage information about libncursesw
Message-ID:  <bug-247976-7788@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D247976

            Bug ID: 247976
           Summary: pkg-config produces icorrect linkage information about
                    libncursesw
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: internalmike@gmail.com

Consider the following program:

```c
#include <locale.h>
#include <curses.h>

int main() {
    setlocale(LC_ALL, "");
    initscr();
    cbreak();=20
    noecho();=20
    keypad(stdscr, true);
    clear();
    move(10, 10);
    addnstr("x", 1);
    move(10, 10);
    insnstr("=D0=9F=D1=80=D0=B8=D0=B2=D0=B5=D1=82", 2);
    getch();
    endwin();
    return 0;
}
```

If you compile it in direct way and run resulting binary:

```sh
$ cc main.c -o main -lncursesw
$ ./main
```
you will get correct-working program: "./main" will display "=D0=9Fx" on sc=
reen.
(Please, consider [this stackoverflow
answer](https://stackoverflow.com/questions/62897474/what-is-the-exact-mean=
ing-of-the-second-parameter-of-the-insnstr-ncurses-funct/62898381#62898381)
if you have doubts about expected ncurses behavior.)

But pkg-config provides the following info about linkage:

```sh
$ pkg-config --libs ncursesw
-L/usr/local/lib -Wl,-rpath,/usr/local/lib -lncursesw -ltinfow
```

And if you compile and run the program with all this flags:

```sh
$ cc -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lncursesw -ltinfow main.c =
-o
main -lncursesw
$ ./main
```
you will get very different result on screen: "=D0=9F=D1=80x".

If you remove `-L/usr/local/lib` part, you get correct behavior back.

I believe, pkg-config should provide information, which does not broke
programs.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-247976-7788>