Issue with using a local build of netcdf-c and netcdf-c++
peter-hristov opened this issue · comments
I'm running Ubuntu 20, netcdf-c 4.7.4 and the "working" branch of netcdf-cxx.
I'm compiling netcdf with
cmake -D CMAKE_INSTALL_PREFIX=~/Projects/libraries/netcdf-c/install
I'm compiling netcdf-cxx with the command:
cmake -D CMAKE_PREFIX_PATH=~/Projects/libraries/netcdf-c/install -D CMAKE_INSTALL_PREFIX=~/Projects/libraries/netcdf-cxx/install ..
In my own application where I would like to use those two librarires I'm compiling with
cmake -D CMAKE_PREFIX_PATH="~/Projects/libraries/netcdf-c/install;~/Projects/libraries/netcdf-cxx/install" ..
In my cmake file the netcdf related things are
find_package(netCDF REQUIRED)
and
target_link_libraries(${PROJECT_NAME}
netcdf
netcdf_c++4
)
Both netcdf-c and netcdf-xx compile and install fine, but when I try to build my application with make I get the following error message: "/usr/local/include/netcdf:5:10: fatal error: netcdf.h: No such file or directory"
I'm not sure why it's not finding the netcdf-cxx header files. Furthermore when I try to use "find_package(netCDFCxx REQUIRED)
" i get the cmake error "Could not find a package configuration file provided by "netCDFCxx" with any of the following names:`
Do you have any idea where I may be going wrong? Please let me know if I can provide any additional information.
I'll take a look at this but I'm curious if the file /usr/local/include/netcdf.h exists on your system? If so, this indicates that there is another system-level netCDF-C install on your system, which may be muddying the waters.
Regarding the find_package(netCDFCxx REQUIRED)
call, the netCDFCxxConfig.cmake is installed into the same directory as the netcdf-c
library. I had to use: cmake .. -DnetCDFCxx_DIR=~/lib/cmake/netCDF/
for you it should be something like: cmake .. -DnetCDFCxx_DIR=~/Projects/libraries/netcdf-cxx/install/lib/cmake/netCDF/
. Maybe there is a way where you can just set CMAKE_PREFIX_PATH
but I haven't found it yet.
Hi,
Thanks for the comments. @WardF there was a leftover file /usr/local/include/netcdf.h and I've removed it along with any other netcdf related files in /usr.
@aosterthun I tried that, but there's no netCDFCxxConfig.cmake file in my install folder, there's only a netCDFCxxConfigVersion.cmake file. Here's the installed filed for both netcdf and netcdf-cxx4
For one it is weird that that .cmake
file is missing.
Besides that the print our you posted shows that you have installed netcdf-cxx4
into both ~/Projects/libraries/netcdf-cxx/install
and ~/Projects/libraries/netcdf-cxx4/install
. I guess that is not what you intended to do.
As you can see in #97 I'm currently also working on getting a project based installation of netcdf-cxx4
to work. I would be interesting to see your build steps. I figure you are using autotools to build netcdf-cxx4
and it's dependencies, since at least for me a full cmake build pipeline did not work.