Creating a HelloWorld C ++ program on Linux with ncurses

I successfully ran sudo apt-get install libncurses5-dev

In my Eclipse window, I will try to create the following HelloWord.cpp program:

 #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; } 

I get the following error:

 Invoking: GCC C++ Linker g++ -m32 -lncurses -L/opt/lib -o "Test_V" ./src/curseTest.o ./src/trajectory.o ./src/xJus-epos.o -lEposCmd /usr/bin/ld: cannot find -lncurses collect2: error: ld returned 1 exit status make: *** [Test_V] Error 1 

It seems that the compiler is looking for the ncurses library and cannot find it? I checked /usr/lib and the library does not exist there, so I need to manually link the ncurses library there - I thought the get-apt installer will automatically do this?

+4
source share
1 answer
 g++ HelloWorld.cpp -lncurses -o HelloWolrd 

If you have a 32-bit machine, gcc compile m32 auto . If you have a 64-bit machine and you want to compile 32 bits, you

+3
source

All Articles