SDL + ncurses == error!

Hello everyone!

Okay. I need ncurses, but I also need a network library… The only one
I’ve ever used with C/C++ was SDL_net. I don’t need the base SDL at all.

But wait, there’s a version of PDCurses that runs on SDL, so I compiled
that version and tried to use it. However, on compiling my (yet
hello-world-kinda) program, I get this:---------------------------
C:\Projects\C\TextCS>make
gcc -o ./bin/Test.exe ./obj/main.o ./obj/network.o ./obj/console.o
-lpdcurses
-lmingw32 -lSDLmain -lSDL -lSDL_net
./obj/console.o: In function
InitConsole':C:/Projects/C/TextCS/./src/console.c: 9: undefined reference to_imp__stdscr’
collect2: ld returned 1 exit status
make: *** [TextCS.exe] Error 1

Smells like the order of the libraries when linking is wrong… But I’ve
tried almost every way possible, and it only gets worse, with a bunch of
SDL undefined references.

(Or maybe it’s because it’s 4:05 AM?)

Has anyone on this nice list ever ran through a similar issue, that can
help me? Thanks in advance!

I always though stdscr was automatically declared… Seems not, as this
fixed the issue:

WINDOW *stdscr = initscr();

:frowning:

L-28C wrote:> Hello everyone!

Okay. I need ncurses, but I also need a network library… The only one
I’ve ever used with C/C++ was SDL_net. I don’t need the base SDL at all.

But wait, there’s a version of PDCurses that runs on SDL, so I compiled
that version and tried to use it. However, on compiling my (yet
hello-world-kinda) program, I get this:


C:\Projects\C\TextCS>make
gcc -o ./bin/Test.exe ./obj/main.o ./obj/network.o ./obj/console.o
-lpdcurses
-lmingw32 -lSDLmain -lSDL -lSDL_net
./obj/console.o: In function
InitConsole':C:/Projects/C/TextCS/./src/console.c: 9: undefined reference to_imp__stdscr’
collect2: ld returned 1 exit status
make: *** [TextCS.exe] Error 1

Smells like the order of the libraries when linking is wrong… But I’ve
tried almost every way possible, and it only gets worse, with a bunch of
SDL undefined references.

(Or maybe it’s because it’s 4:05 AM?)

Has anyone on this nice list ever ran through a similar issue, that can
help me? Thanks in advance!

Hello !

-lmingw32 -lSDLmain -lSDL -lSDL_net

Better is i think :

-lSDL_net -lSDLmain -lSDL -lmingw32

If you have MSYS installed please use the output from sdl-config.

CU

L-28C <kixdemp gmail.com> writes:

But wait, there’s a version of PDCurses that runs on SDL, so I compiled
that version and tried to use it. However, on compiling my (yet
hello-world-kinda) program, I get this:


C:\Projects\C\TextCS>make
gcc -o ./bin/Test.exe ./obj/main.o ./obj/network.o ./obj/console.o
-lpdcurses
-lmingw32 -lSDLmain -lSDL -lSDL_net
./obj/console.o: In function
InitConsole':C:/Projects/C/TextCS/./src/console.c: 9: undefined reference to_imp__stdscr’
collect2: ld returned 1 exit status
make: *** [TextCS.exe] Error 1

Smells like the order of the libraries when linking is wrong… But I’ve
tried almost every way possible, and it only gets worse, with a bunch of
SDL undefined references.

I don’t think that library order is your problem. Did you build PDCurses as a
DLL? If so, you need to specify -DPDC_DLL_BUILD when compiling each module that
includes curses.h. (Or you could do it the way the curses.h distributed with the
precompiled DLLs does, with “#define PDC_DLL_BUILD” at the top.)

BTW, I’d also add “-mwindows” to the build options so that the finished
executable doesn’t open a console window along with the SDL window. Unless you
want both…

Well, why’d I want both if SDL redirects stdout and stderr to text
files? :-/

I didn’t need SDL_net after all, I could just use Winsock… :stuck_out_tongue:

William McBrine wrote:> L-28C <kixdemp gmail.com> writes:

But wait, there’s a version of PDCurses that runs on SDL, so I compiled
that version and tried to use it. However, on compiling my (yet
hello-world-kinda) program, I get this:


C:\Projects\C\TextCS>make
gcc -o ./bin/Test.exe ./obj/main.o ./obj/network.o ./obj/console.o
-lpdcurses
-lmingw32 -lSDLmain -lSDL -lSDL_net
./obj/console.o: In function
InitConsole':C:/Projects/C/TextCS/./src/console.c: 9: undefined reference to_imp__stdscr’
collect2: ld returned 1 exit status
make: *** [TextCS.exe] Error 1

Smells like the order of the libraries when linking is wrong… But I’ve
tried almost every way possible, and it only gets worse, with a bunch of
SDL undefined references.

I don’t think that library order is your problem. Did you build PDCurses as a
DLL? If so, you need to specify -DPDC_DLL_BUILD when compiling each module that
includes curses.h. (Or you could do it the way the curses.h distributed with the
precompiled DLLs does, with “#define PDC_DLL_BUILD” at the top.)

BTW, I’d also add “-mwindows” to the build options so that the finished
executable doesn’t open a console window along with the SDL window. Unless you
want both…


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org