提升 - 交叉检查我做对了(Windows)

时间:2013-04-26 01:32:56

标签: c++ boost cygwin

我已启动并运行cygwin(编译并运行示例代码。没问题)。

我在这里下载了boost: C:\cygwin\lib\boost_1_53_0

并运行bootstrap.sh(运行没问题)。

我跑了: $ ./b2 install --prefix=../boost

当我在./lib/boost_1_53_0时假设它会安装到./lib

现在确实我有: C:\cygwin\lib\boost

我正在尝试编译并运行:

        #include<iostream>
        #include<boost/any.hpp>

        int main()
        {
        boost::any a(5);
        a = 7.67;
        std::cout<<boost::any_cast<double>(a)<<std::endl;
        }

位于./home/usr/,我明白了:

        Jason@ITHAKA-DB44CFE1 /home/jason
        $  g++  -o first first.cpp
        first.cpp:2:24: boost/any.hpp: No such file or directory
        first.cpp: In function `int main()':
        first.cpp:6: error: `boost' has not been declared
        first.cpp:6: error: `any' undeclared (first use this function)
        first.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
        first.cpp:6: error: expected `;' before "a"
        first.cpp:7: error: `a' undeclared (first use this function)
        first.cpp:8: error: `boost' has not been declared
        first.cpp:8: error: `any_cast' undeclared (first use this function)
        first.cpp:8: error: expected primary-expression before "double"
        first.cpp:8: error: expected `;' before "double"
        first.cpp:9:2: warning: no newline at end of file

        Jason@ITHAKA-DB44CFE1 /home/jason
        $

我尽可能多地提供解决此问题的详细信息,但我不确定为什么会这样。应该在其他地方加强--prefix吗?

any.hpp的路径是:C:\cygwin\lib\boost\include\boost\any.hpp

$ g++ -v -o first first.cpp的结果是:

            Jason@ITHAKA-DB44CFE1 /home/jason
            $  g++ -v -o first first.cpp
            Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
            Configured with: /managed/gcc-build/final-v3-bootstrap/gcc-3.4.4-999/configure --verbose --program-suffix=-3 --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug
            Thread model: posix
            gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
             /usr/lib/gcc/i686-pc-cygwin/3.4.4/cc1plus.exe -quiet -v -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api -idirafter /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/../../include/w32api first.cpp -quiet -dumpbase first.cpp -mtune=pentiumpro -auxbase first -version -o /tmp/ccNdgnCA.s
            ignoring nonexistent directory "/usr/local/include"
            ignoring nonexistent directory "/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/include"
            ignoring duplicate directory "/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/../../include/w32api"
            #include "..." search starts here:
            #include <...> search starts here:
             /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++
             /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/i686-pc-cygwin
             /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward
             /usr/lib/gcc/i686-pc-cygwin/3.4.4/include
             /usr/include
             /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api
            End of search list.
            GNU C++ version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) (i686-pc-cygwin)
                    compiled by GNU C version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125).
            GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
            first.cpp:7:2: warning: no newline at end of file
             /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/as.exe -o /tmp/ccCB9HBt.o /tmp/ccNdgnCA.s
             /usr/lib/gcc/i686-pc-cygwin/3.4.4/collect2.exe -Bdynamic --dll-search-prefix=cyg -o first.exe /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../crt0.o -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../.. /tmp/ccCB9HBt.o -lstdc++ -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc

0 个答案:

没有答案