User forums > Help

Building Console application - ncurses

(1/2) > >>

csanyipal:
Hi,
I have installed Code::Blocks 16.01 on my Gentoo linux system.
I am using gcc version 5.
I am new to C programming.
I just created a Console application project within Code::Blocks. I want to use ncurses library in it.
It contains so far only the main.c source file:

--- Code: ---#include <ncurses.h>

int main()
{
initscr(); /* Start curses mode   */
printw("Hello World !!!"); /* Print Hello World   */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode   */

return 0;
}
--- End code ---

So when I want to build it, I get error messages:
-------------- Build: Debug in NcursesMenu01 (compiler: GNU GCC Compiler)---------------

g++  -o bin/Debug/NcursesMenu01 obj/Debug/main.o   -lpthread -lX11 -lncurses
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../x86_64-pc-linux-gnu/bin/ld: obj/Debug/main.o: undefined reference to symbol 'stdscr'
/lib64/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I added in Project / Build options / Linker settings
followings:
pthread
X11
ncurses
both in Debug and in Release.

What should I do to solve this problem?

stahta01:
1. Verify the code you posted was saved.
2. Do a rebuild instead of build
3. Post the full rebuild log here so we can maybe help you.

Edit: http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

If we can NOT help you, you will need to find a programming site that can help you.

Tim S.

csanyipal:

--- Quote from: stahta01 on February 28, 2017, 04:26:03 pm ---1. Verify the code you posted was saved.
2. Do a rebuild instead of build
3. Post the full rebuild log here so we can maybe help you.

Edit: http://wiki.codeblocks.org/index.php/FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

If we can NOT help you, you will need to find a programming site that can help you.

Tim S.

--- End quote ---
1. Done.
2. Done.
3.
-------------- Clean: Debug in NcursesMenu01 (compiler: GNU GCC Compiler)---------------

Cleaned "NcursesMenu01 - Debug"

-------------- Build: Debug in NcursesMenu01 (compiler: GNU GCC Compiler)---------------

gcc -Wall -g  -c /home/pali/Irataim/Programozas/Code::Blocks/NcursesProgramok/NcursesMenu_01/NcursesMenu01/main.c -o obj/Debug/main.o
g++  -o bin/Debug/NcursesMenu01 obj/Debug/main.o   -lpthread -lX11 -lncurses
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/../../../../x86_64-pc-linux-gnu/bin/ld: obj/Debug/main.o: undefined reference to symbol 'stdscr'
/lib64/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

stahta01:
To csanyipal: I did NOT see any problem; likely will need to find a programming help site.
Edit: Posted the likely fix in my next post.

But, first I suggest trying two things.

Remove the X11 library because it is NOT needed.
See if the next rebuild works.

If it still has the problem remove pthread library; I have no idea if it is needed.
Rebuild a second time with both X11 and pthread libraries removed from CB link library list.

Tim S.



stahta01:
Per http://stackoverflow.com/questions/26267788/linking-fails-with-gcc-4-8-2-ld-2-24-succeeds-with-gcc-4-4-7-ld-2-20

Try adding tinfo library after ncurses in the CB link library list.

Please also read this site rules. I have almost violated the rules helping you with this problem.
http://forums.codeblocks.org/index.php/topic,9996.0.html

Tim S.

Navigation

[0] Message Index

[#] Next page

Go to full version