| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
| :list-unsubscribe:list-subscribe:list-archive:list-post | |
| :list-help:sender:mime-version:in-reply-to:references:from:date | |
| :message-id:subject:to:content-type; q=dns; s=default; b=yQBjZ2r | |
| 5jHO7FVuHnrLqYhIlQejPbZ+rtJDpzQRiMOeV0YVR/VkAih4M/rBXd4B30MJkYT3 | |
| yK1SSelywUYCxvLI8tk0/meY20l6NXusvD3fUoc8ikcuDQSKQRuvIqLstYzkrzhT | |
| TwvGK0WOag9ojH4Q+qpMFqDZDH9QTYLHVkHQ= | |
| DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
| :list-unsubscribe:list-subscribe:list-archive:list-post | |
| :list-help:sender:mime-version:in-reply-to:references:from:date | |
| :message-id:subject:to:content-type; s=default; bh=6QbZvIWympGrV | |
| DvdhGczGL0cVw0=; b=sRNGDVHS/LuAOYDLFcx/2bX5eBEDhBPqW8Il8s08pEK8w | |
| Me60BJIUw6vQb589jlNcs0GCWDUL6IjGTVUoyo2wn++rim2vbpe219mwpOKHekOi | |
| 9D0uMCKa7f7X+cKcvTxhHRxPsDj7gf9K8h8giOlzc3vpCMktPwAMZguO/fYULU= | |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Authentication-Results: | sourceware.org; auth=none |
| X-Virus-Found: | No |
| X-Spam-SWARE-Status: | No, score=2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 |
| X-HELO: | mail-vc0-f182.google.com |
| X-Received: | by 10.52.50.178 with SMTP id d18mr114703vdo.53.1394805629185; Fri, 14 Mar 2014 07:00:29 -0700 (PDT) |
| MIME-Version: | 1.0 |
| In-Reply-To: | <CAFrJEvN+Rckr6_XDYr5WUWLtYA6T6694bwPZAzUmR8OZdJ-_Zw@mail.gmail.com> |
| References: | <CAFrJEvN+Rckr6_XDYr5WUWLtYA6T6694bwPZAzUmR8OZdJ-_Zw AT mail DOT gmail DOT com> |
| From: | rexdf Rexdf <weiyong DOT mao AT gmail DOT com> |
| Date: | Fri, 14 Mar 2014 22:00:08 +0800 |
| Message-ID: | <CAFrJEvPQuSLeXriH=s_VOkbR0S4E2+LR=NHzZsERa_-g=2LJng@mail.gmail.com> |
| Subject: | Re: Some Problems about gcc 4.8.2 on cygwin |
| To: | cygwin AT cygwin DOT com |
If you use -O3 or -O2, then the loop is optimed to nothing. Because
the a++ never is used.
My question is :
1. On archlinux gcc 4.8.2, `gcc curses_test.c $(pkg-config --libs
--cflags ncurses) -o curses_test` and `gcc $(pkg-config --libs
--cflags ncurses) curses_test.c -o curses_test` works.
On cygwin it doesn't work, why?
2. what is wrong in openmp on cygwin? How can I fix it?
2014-03-14 20:42 GMT+08:00 rexdf Rexdf <weiyong DOT mao AT gmail DOT com>:
> 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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |