0

I am working on a C library. It contains a data file, as a CSV file.

The library opens and read this file as needed.

But how do I install this file, and open it (in C) in such a way that it works in both testing and after it is installed?

Right now I copy the file to the build directory so it can be found during testing. But this won't work for an installed library.

# Copy the data file with the NOAA abbreviations.
configure_file(src/noaa_grib2_params.csv ${CMAKE_CURRENT_BINARY_DIR}/noaa_grib2_params.csv COPYONLY)

Even if I install the data file with the library, how can the library open it? Does the library have to know the install path so it can find the data file?

Edward Hartnett
  • 882
  • 7
  • 16
  • There are osdependent ways of finding the location of your binary at runtime (e.g. https://stackoverflow.com/questions/6924195/get-dll-path-at-runtime) As for testing: you probably won't use the final executable in tests directly, so simply provide determine the absolute file path to open in the program you're deploying as well as in the test exe and pass that path to the library in both cases... It shouldn't be too hard to pass info as absolute paths to the test exe. – fabian Sep 21 '22 at 16:59

0 Answers0