Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLion "Instantiating an unknown structure without reference" but compiles fine

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)

enter image description here

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?

like image 266
TomW Avatar asked Jan 26 '16 21:01

TomW


2 Answers

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

enter image description here

like image 195
Niklas Rosencrantz Avatar answered Oct 01 '22 05:10

Niklas Rosencrantz


Your IDE and building tools are two "completely" different processes. You have nothing to worry about if your code compiles with Cmake and MingW. You probably have configured your IDE with different settings than given in your CMakeLists. You need to link the hdf5 C++ library in your editor to solve the "problems" in your IDE. This will only improve readability.

like image 41
Thomqa Avatar answered Oct 01 '22 05:10

Thomqa