首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cmake找不到libstdc++

cmake找不到libstdc++
EN

Stack Overflow用户
提问于 2016-02-04 12:30:14
回答 1查看 1.5K关注 0票数 0

(使用元素/Ubuntu)

我正在交叉编译x265,我鼓励恼人的问题。由于某些原因,cmake不想接受-static++,因为ld显然找不到它。Cmake是从源代码构建的,在没有-static++的情况下工作得很好,如果我然后将libstdc++-6. well从mingw-w64库复制到带有x265.exe的文件夹中,它工作得很好,但我希望它能够用它构建。mingw是用这个剧本构建的,包含了这些库,但我不知道在哪里可以找到它们。

以下是cmake尝试的输出:

代码语言:javascript
复制
-- cmake version 3.5.0-rc1
-- The C compiler identification is GNU 5.2.0
-- The CXX compiler identification is GNU 5.2.0
-- Check for working C compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++ -- broken
CMake Error at /usr/local/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message):
  The C++ compiler
  "/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++" is not
  able to compile a simple test program.

  It fails with the following output:

   Change Dir: /home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp



  Run Build Command:"/usr/bin/make" "cmTC_e7611/fast"

  /usr/bin/make -f CMakeFiles/cmTC_e7611.dir/build.make
  CMakeFiles/cmTC_e7611.dir/build

  make[1]: Entering directory
  `/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp'

  Building CXX object CMakeFiles/cmTC_e7611.dir/testCXXCompiler.cxx.obj

  /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
  -static-libgcc -static-libstdc++ -o
  CMakeFiles/cmTC_e7611.dir/testCXXCompiler.cxx.obj -c
  /home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

  Linking CXX executable cmTC_e7611.exe

  /usr/local/bin/cmake -E cmake_link_script
  CMakeFiles/cmTC_e7611.dir/link.txt --verbose=1

  /usr/local/bin/cmake -E remove -f CMakeFiles/cmTC_e7611.dir/objects.a

  /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-ar cr
  CMakeFiles/cmTC_e7611.dir/objects.a @CMakeFiles/cmTC_e7611.dir/objects1.rsp

  /home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
  -static-libgcc -static-libstdc++ -Wl,--whole-archive
  CMakeFiles/cmTC_e7611.dir/objects.a -Wl,--no-whole-archive -o
  cmTC_e7611.exe -Wl,--out-implib,libcmTC_e7611.dll.a
  -Wl,--major-image-version,0,--minor-image-version,0
  @CMakeFiles/cmTC_e7611.dir/linklibs.rsp


  /home/myname/mingw-w64/mingw-w64-x86_64/lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld:
  cannot find -lstdc++

  collect2: error: ld returned 1 exit status

  make[1]: *** [cmTC_e7611.exe] Error 1

  make[1]: Leaving directory
  `/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeTmp'

  make: *** [cmTC_e7611/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:19 (project)


-- Configuring incomplete, errors occurred!
See also "/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeOutput.log".
See also "/home/myname/x265/build/linux/12bit/CMakeFiles/CMakeError.log".
make: *** No targets specified and no makefile found.  Stop.

Cmake像下面的代码一样运行。

代码语言:javascript
复制
cmake -DCMAKE_C_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc' -DCMAKE_CXX_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++' -DCMAKE_RC_COMPILER='/home/myname/mingw-w64/mingw-w64-x86_64/bin/x86_64-w64-mingw32-windres' -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_C_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_TOOLCHAIN_FILE='/home/myname/x265/build/linux/build.cmake' ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
make ${MAKEFLAGS}

build.cmake文件在这里并不重要,但它包含:

代码语言:javascript
复制
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_ASM_YASM_COMPILER yasm)

有什么想法使-静态-libstdc++工作吗?我试着把它链接到很多文件夹中,但是我找不到它在哪里。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-04 16:17:08

我设法解决了这个问题。造成我困惑的原因是您可以使用-static,所以我认为-static++应该可以工作。问题是确实存在库,但没有libstdc++的libstdc++文件。在使用脚本时,可以使用此参数禁用这些参数。然后这两种-静态库选项都能很好地工作。

代码语言:javascript
复制
bash ./mingw-w64-build-3.6.7 --disable-shared
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35201086

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档