NOAA-EMC / wgrib2

Provides functionality for interacting with, reading, writing, and manipulating GRIB2 files.
35 stars 14 forks source link

Building shared lib on a mac #280

Open stackjohn opened 2 days ago

stackjohn commented 2 days ago

Hello....

With the following, I can build the main exe, but I cannot build the shared lib, these are the steps:

export OpenMP_ROOT=$(brew --prefix)/opt/libomp
export NetCDF_ROOT=$(brew --prefix)/opt/netcdf
mkdir build && cd build
cmake ..
make wgrib2_exe

This compiles and wgrib2/wgrib2 exists

Then I try the following:

make wgrib2_lib

snip

[ 29%] Building C object wgrib2/CMakeFiles/wgrib2_lib.dir/Config.c.o
/wgrib2/wgrib2/Config.c:14:10: fatal error: 'netcdf.h' file not found
#include <netcdf.h>
         ^~~~~~~~~~
1 error generated.

Only change to my main CMakeLists.txt is:

-option(BUILD_SHARED_LIB "Build shared library?" off)
+option(BUILD_SHARED_LIB "Build shared library?" on)

How can I resolve this?

Thanks in advance for any help.

stackjohn commented 1 day ago

Created a PR for this which seems to allow it to build for me.

https://github.com/NOAA-EMC/wgrib2/pull/281