Question
I'm trying to include LibPng library in my Tizen native project. I've followed these steps:
- Added "png" and "z" in Libraries (-l) under:
- C/C++ Build → Settings → Tool Settings → C++ Linker → Libraries
- Added library paths:
- "...\libpng-1.6.24"
- "...\zlib-1.2.8" in the Library search path (-L)
However, I'm getting the following build error:
cannot find -lpng
ninja: build stopped: subcommand failed.
Could anyone help me resolve this issue with including external libraries in Tizen native projects?
Answer
Problem Understanding
The issue occurs when trying to link external libraries (LibPng and zlib) in a Tizen native project. The error suggests the linker cannot find the specified library files despite the paths being configured.
Solution Methods
-
Verify Library Paths:
- Ensure the paths you provided are absolute and correct
- Check that the library files (libpng.a/libpng.so and zlib.a/zlib.so) actually exist in the specified directories
-
Proper Library Naming:
- Tizen typically expects library files to be named with the "lib" prefix (e.g., libpng.a)
- Make sure your library files follow this naming convention
-
Project Configuration:
- In your project's manifest.xml, add:
<library-path>path_to_your_libraries</library-path> - For Tizen Studio projects, also check:
- Project Properties → C/C++ Build → Settings → Tool Settings
- Ensure both the library names and paths are correctly specified
- In your project's manifest.xml, add:
-
Build System Considerations:
- For CMake projects, add these lines to your CMakeLists.txt:
find_library(PNG_LIBRARY png) find_library(ZLIB_LIBRARY z) target_link_libraries(your_target ${PNG_LIBRARY} ${ZLIB_LIBRARY})
- For CMake projects, add these lines to your CMakeLists.txt:
Additional Tips
- Always use absolute paths for library locations
- Verify the library architecture matches your target device (arm/arm64/x86)
- Check file permissions on the library files
- For Tizen 5.5+, consider using the pkg-config approach if available