Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I use gcc to create .so file #87

Closed
SmileChen007 opened this issue Apr 3, 2019 · 2 comments
Closed

how can I use gcc to create .so file #87

SmileChen007 opened this issue Apr 3, 2019 · 2 comments

Comments

@SmileChen007
Copy link

Thanks, I use Python, so i use lodepng.c and lodepng.h to create .so file by gcc on ubuntu, then it create liblodepng.so .
The order is 'gcc lodepng.c -I ./ -fPIC -shared -o liblodepng.so'
but when i use this liblodepng.so, it report a bug,
image

The bug is :
bash: line 1: 14557 Segmentation fault (core dumped) env "PYTHONUNBUFFERED"="1" "PYTHONPATH"="/tmp/pycharm_project_500:/root/.pycharm_helpers/pycharm_matplotlib_backend" "PYCHARM_HOSTED"="1" "JETBRAINS_REMOTE_RUN"="1" "PYCHARM_MATPLOTLIB_PORT"="52649" "PYTHONIOENCODING"="UTF-8" '/home/ubuntu/env/env_fun/bin/python3.5' '-u' '/tmp/pycharm_project_500/png/test.py'

i don't why, the zip file it contains liblodepng.so
liblodepng.zip

@lvandeve
Copy link
Owner

lvandeve commented Apr 3, 2019

Thanks for your report,

Is there any way in your setup that you can get a stack trace of the C code that runs?

In C, the signature of lodepng_decode32_file is:

unsigned lodepng_decode32_file(unsigned char** out, unsigned* w, unsigned* h,
const char* filename);

Are width and height pointers in your code? If "width = 0" means it's a null pointer, that will cause a crash since it wants to write the width to the unsigned integer it points to. Same also for raw_rgba_pixels where it wants to output a pointer to a a buffer it allocates inside. How are pointers handled in this setup?

Thanks

@SmileChen007
Copy link
Author

ok,thanks,I try another way to solve my problem, I run executable file to handle my png.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants