实例化未引用的未知结构

实例化未引用的未知结构

本文介绍了CLion“实例化未引用的未知结构”但编译良好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图使用CLion编辑器和MinGW在Windows 10(64位)上使用HDF5设置我的cmake项目。经过一段时间试图让我的CMakeLists文件设置正确,我有一些工作 - 代码编译,没有从mingw32-make或从cmake的错误。然而,我仍然得到红色下划线的错误在CLION,这似乎没有任何影响建设,但我有一种感觉,他们在那里,因为我做了一些不正确的。 (我是非常新的做比C ++的类项目更多)



这是我的CMakeLists.txt

  cmake_minimum_required(VERSION 2.8)

project(testProject)
add_definitions(-std = c ++ 11)
set SOURCE_FILES hdf_example。 c:\\ Program Files / HDF_Group / HDF5 / 1.8.0 / lib / hdf5_hl_cpp-shared.lib


link_libraries 1.8.16 / lib / hdf5_cpp-shared.lib
C:/ Program Files / HDF_Group / HDF5 / 1.8.16 / lib / hdf5-shared.lib)

add_executable abc hdf_example.cpp)


使用mingw32-make或在IDE中从命令行编译这两个命令都会导致成功的编译,但没有错误或警告,我可以看到。

  C:\Users\Me\Documents\project_name\temp-build\src\abc> mingw32-make 
[50%]构建CXX对象src / s3 / CMakeFiles / abc.dir / hdf_example.cpp.obj
[100%]链接CXX可执行文件abc.exe
[100%]建立目标abc

这是我应该关心的吗?

解决方案

我有这个问题,通过放置 #include< getopt.h> 在C文件中的 #include< unistd.h> 这可能被视为CLION中的一个错误。我为此创建了


I've been trying to get my cmake project set up with HDF5 on Windows 10 (64bit), using the CLion editor and MinGW. After a ton of time trying to get my CMakeLists file set up properly, I got something working - the code compiles, no errors from mingw32-make or from cmake. However, I'm still getting red underlined errors in CLion, which don't seem to have any impact on the build, but I have a feeling that they're there because I did something incorrect. (I'm very new doing anything more than class projects with C++)

Here is my CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

project(testProject)
add_definitions(-std=c++11)
set(SOURCE_FILES hdf_example.cpp)

link_libraries("C:/Program Files/HDF_Group/HDF5/1.8.16/lib/hdf5_hl_cpp-shared.lib"
               "C:/Program Files/HDF_Group/HDF5/1.8.16/lib/hdf5_cpp-shared.lib"
               "C:/Program Files/HDF_Group/HDF5/1.8.16/lib/hdf5-shared.lib")

add_executable (abc hdf_example.cpp)

Compiling this from the command line using mingw32-make or in the IDE both result a successful compilation with no errors or warnings that I can see.

C:\Users\Me\Documents\project_name\temp-build\src\abc>mingw32-make
[ 50%] Building CXX object src/s3/CMakeFiles/abc.dir/hdf_example.cpp.obj
[100%] Linking CXX executable abc.exe
[100%] Built target abc

Is this something I should be concerned about? Or should I just ignore it since everything compiles?

解决方案

I had this problem and solved it by placing #include <getopt.h> above #include <unistd.h> in the C file. This could be viewed as a bug in CLion. I have created an issue for this. The workaround for now is to rearrange your imports.

For details you can also read my question about this.

Instantiating an unknown structure without a reference

这篇关于CLion“实例化未引用的未知结构”但编译良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 00:05