I am creating a c++ program that can use GDAL (if present). I can check the presence of GDAL in the system but how I need to code my program to include/not include the GDAL libraries if my program was compiled using GDAL?
Many thanks,
Carlos.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
While I haven’t used CMake, but if the library is available you can link with it and also pass a flag to the compiler defining a macro (e.g.
-DHAVE_GDAL). Then in your source you use the preprocessor to check forHAVE_GDALand only use GDAL functionality if it’s defined.Something like this in your source: