I'm trying to build my project on linux but I need to use two shared libraries (SDL2 and SDL2 image), the problem is that the path to the libraries depends on the distro. For example:
on Ubuntu the libraries are saved in /usr/lib/x86_64-linux-gnu/ but on Fedora are saved in /usr/lib64/. How can I make a single binding.gyp file for all distros?
This is the current binding.gyp file:
{
'targets': [
{
'target_name': 'canvas_sdl2',
'sources': [
'src/init.cpp',
'src/sdl2node.cpp',
'src/sdl2image_node.cpp',
'src/common.cpp'
],
'cflags!': ['-fno-exceptions'],
'cflags_cc!': ['-fno-exceptions'],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.7'
},
'msvs_settings': {
'VCCLCompilerTool': {'ExceptionHandling': 1},
},
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
],
'include_dirs': [
"<(module_root_dir)/include/sdl/",
"<(module_root_dir)/include/sdlimg/",
"<!@(node -p \"require('node-addon-api').include\")",
],
'conditions': [
["OS==\"win\"", {
'libraries': [
"<(module_root_dir)/bin/sdl/winx64/SDL2.lib",
"<(module_root_dir)/bin/sdlimg/winx64/SDL2_image.lib",
],
'copies': [
{
'destination': '<(module_root_dir)/build/Release/',
'files': [
'<(module_root_dir)/bin/sdl/winx64/SDL2.dll',
'<(module_root_dir)/bin/sdlimg/winx64/SDL2_image.dll'
]
}
]
}],
["OS==\"linux\"", {
"libraries": [
"/lib/x86_64-linux-gnu/libSDL2-2.0.so.0",
"/lib/x86_64-linux-gnu/libSDL2_image-2.0.so.0",
]
# How can I make it compatible with other distributions?
}]
]
}
]
}
I honestly haven't found much online and haven't tried much.
EDIT:
What i tried:
I changed the absoulte path into -lSDL2 and with ubuntu it still works but with fedora I get this error: /usr/bin/ld: cannot find -lSDL2: File or directory does not exist
I fixed it by putting
Where "-L$(LIB)" is the path to the folder that contains all the libraries