This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Some Problems about gcc 4.8.2 on cygwin


1.the following code:

#include <unistd.h>
#include <curses.h>
int main() {
   initscr();
   move(0, 0);
   addstr("hello, world\n");
   refresh();
   sleep(5);
   endwin();
   return 0;
}

The following is my shell command:

$ pkg-config --libs --cflags ncurses
-I/usr/include/ncurses  -lncurses

$ gcc $(pkg-config --libs --cflags ncurses) curses_test.c -o curses_test
/tmp/cc74H73T.o:curses_test.c:(.text+0xf): undefined reference to `initscr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x14): undefined reference to
`ncwrap_stdscr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x2c): undefined reference to `wmove'
/tmp/cc74H73T.o:curses_test.c:(.text+0x31): undefined reference to
`ncwrap_stdscr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x49): undefined reference to `waddnstr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x4e): undefined reference to
`ncwrap_stdscr'
/tmp/cc74H73T.o:curses_test.c:(.text+0x56): undefined reference to `wrefresh'
/tmp/cc74H73T.o:curses_test.c:(.text+0x67): undefined reference to `endwin'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
/tmp/cc74H73T.o: bad reloc address 0x20 in section `.eh_frame'
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld:
final link failed: Invalid operation
collect2: error: ld returned 1 exit status

$ gcc curses_test.c $(pkg-config --libs --cflags ncurses) -o curses_test

$ ./curses_test.exe


Do I have to put the source file before `-I/usr/include/ncurses
-lncurses`? And why?


2.It's about OpenMP
openmp_1.cpp
#include <iostream>
#include <time.h>
void test()
{
    int a = 0;
    for (int i=0;i<100000000;i++)
        a++;
}
int main()
{
    clock_t t1 = clock();
    for (int i=0;i<8;i++)
        test();
    clock_t t2 = clock();
    std::cout<<"time: "<<t2-t1<<std::endl;
}

openmp_2.cpp
#include <iostream>
#include <time.h>
void test()
{
    int a = 0;
    for (int i=0;i<100000000;i++)
        a++;
}
int main()
{
    clock_t t1 = clock();
    #pragma omp parallel for
    for (int i=0;i<8;i++)
        test();
    clock_t t2 = clock();
    std::cout<<"time: "<<t2-t1<<std::endl;
}

On cygwin
g++ openmp_1.cpp -o openmp_1.exe
g++ openmp_2.cpp -o opemnp_2.exe -fopenmp
time 1937
time 2297

On MingW-g++ 4.8.1
g++ openmp_1.cpp -o openmp_1.exe
g++ openmp_2.cpp -o opemnp_2.exe -fopenmp
time 1975
time 492

On Visual Studio 2013
Openmp_2.cpp Project
C/C++ --> Language --> Open MP Support yes(/openmp)
time 1849
time 321

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]