简体   繁体   English

CMake和Visual Studio构建错误

[英]CMake And Visual Studio build errors

I've been trying to compile tulip using cmake to generate visual studio 2012 project files. 我一直在尝试使用cmake编译郁金香以生成Visual Studio 2012项目文件。 It's giving me lots of trouble. 这给我带来很多麻烦。 I don't know how to get this to build. 我不知道该如何构建。 I've been trying to get visual studio to build this for 4 days now, and I'm extremely frustrated. 我一直试图让Visual Studio来构建它已有4天了,对此我感到非常沮丧。 Essentially, I follow the steps here , and then set the variables CMAKE_LIBRARY_PATH AND CMAKE_INCLUDE_PATH according to these instructions . 本质上,我按照此处的步骤进行操作,然后根据这些说明设置变量CMAKE_LIBRARY_PATH和CMAKE_INCLUDE_PATH。

To get to where I'm at, all you have to do is download tulip , and: 要到达我所在的位置,只需下载tulip ,然后:

  1. Unzip it, create a separate build directory outside of this source directory 解压缩它,在此源目录之外创建一个单独的构建目录
  2. Open CMake-gui to the source and build directories 打开CMake-gui到源代码并构建目录
  3. Hit configure. 点击配置。 Check use qt5, tell it where qmake is (make sure it's qt5) 检查使用qt5,告诉它qmake在哪里(确保它是qt5)
  4. You need some dependencies as described in The Independent CMake tutorial. 如The Independent CMake教程中所述,您需要一些依赖项。 Grab all those dependencies 抓住所有那些依赖
  5. As you continue to hit configure, specify each of the directories that it asks for as it errors out. 当您继续单击configure时,请指定错误时要求的每个目录。 It should ask for freetype, glew, zlib and sphinx. 它应该询问freetype,glew,zlib和sphinx。 It shouldn't ask for where libxml or libpng, or libjpeg are. 它不应该询问libxml或libpng或libjpeg的位置。 I don't know why it doesn't ask for those. 我不知道为什么它不要求那些。
  6. Generate, and then browse to the ALL_BUILD that you've generated. 生成,然后浏览到您生成的ALL_BUILD。 Open it with visual studio 用Visual Studio打开
  7. try to build it with visual studio. 尝试使用Visual Studio构建它。

In those instructions and in the process of getting CMake to generate the visual studio build files, it specifically asks for freetype's location. 在这些说明中以及在使CMake生成Visual Studio构建文件的过程中,它特别要求freetype的位置。 But in my build, it doesn't have a clue how to link the freetype library. 但是在我的构建中,它不知道如何链接自由类型库。

Here are the errors that I get 这是我得到的错误

Here is my CMakeCached.txt 这是我的CMakeCached.txt

I know that many people aren't going to want to exactly try and go about replicating the build environment, so I've uploaded my build directory to dropbox. 我知道很多人都不想完全尝试复制构建环境,因此我已将构建目录上载到Dropbox。 You can pull the entire thing down, and then open it in cmake gui and open the visual studio files in there too. 您可以下拉整个内容,然后在cmake gui中将其打开,并在其中也打开Visual Studio文件。 https://www.dropbox.com/sh/qsvukh9t5gb6bvt/tOfOBxWgd0 https://www.dropbox.com/sh/qsvukh9t5gb6bvt/tOfOBxWgd0

The linker errors you point to (mostly "unresolved external" errors) indicate that there are missing libraries on the link command line. 您指向的链接器错误(主要是“未解决的外部错误”)表明链接命令行上缺少库。

That is most likely happening because target_link_libraries calls in the tulip project are either being skipped or being called with library names that do not match the library names on disk. 这很可能是由于郁金香项目中的target_link_libraries调用被跳过或以与磁盘上的库名不匹配的库名被调用。

Open up the solution in Visual Studio and right click the project and choose "Properties" -- look at the "Linker > Input" panel at the "Additional Dependencies" field. 在Visual Studio中打开解决方案,然后右键单击该项目,然后选择“属性”-在“其他依赖项”字段中查看“链接器>输入”面板。 That should list all the libraries it wants to link to. 那应该列出它要链接的所有库。 Is there a freetype library listed there? 那里有一个自由类型库吗? Does that library exist in the referenced location on your disk? 该库在磁盘上的引用位置中是否存在?

There could be a mistake in the tulip project, or there could just be something wrong with your build/install of freetype... 郁金香项目中可能有错误,或者Freetype的构建/安装中可能有问题...

UPDATE AFTER SOME CHAT:

Or it may be that you have some libraries built for x86 and some for x64 ... or maybe some for Debug and some for Release ... or maybe even some with the MinGW compiler and some with the Visual Studio compiler. 也可能是您有一些针对x86构建的库,一些针对x64构建的库...,或者某些针对Debug的库 ,某些针对Release的库 ...,甚至有些是使用MinGW编译器而有些是使用Visual Studio编译器。 If that's the case, start over, from a clean slate, and build everything with a consistent compiler, configuration type and architecture. 如果是这种情况,请从头开始,并使用一致的编译器,配置类型和体系结构构建所有内容。 Then report back again with an update and see if the problems still remain. 然后再次报告更新,以查看问题是否仍然存在。

I do with Dave, 我和戴夫在一起

You should try to fix your error 1 by 1. The first error seems to be a link error: 您应该尝试通过1来修复错误1。第一个错误似乎是链接错误:

Error   1   error LNK2019: unresolved external symbol gzread referenced in function "public: virtual int __cdecl gzstreambuf::underflow(void)" (?underflow@gzstreambuf@@UEAAHXZ)    C:\Users\kenne_000\tulip-build\tulip-build-debug\thirdparty\gzstream\gzstream.obj   gzstream

gzstream is a third party lib included with tulip source in: gzstream是包含在以下郁金香源中的第三方库:

thirdparty\gzstream

from

thirdparty\gzstream\CMakeLists.txt

you can see that the missing symbols should be coming from ZLIB. 您会看到缺少的符号应该来自ZLIB。 However your CMakeCache.txt indicate that 但是,您的CMakeCache.txt指出

ZLIB_LIBRARY:FILEPATH=C:/Users/kenne_000/dependencies/zlib128-dll/lib/zdll.lib

is found. 被发现。

So the question may be, was this dependency compiled with the same compiler? 因此问题可能是,此依赖项是否已使用同一编译器进行编译? Don't you have compiler-specific name mangling issue ? 您没有编译器专有的名称修改问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM