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

undefined reference on OpenBSD to some standard C library functions #354

Closed
markand opened this issue Mar 30, 2023 · 10 comments
Closed

undefined reference on OpenBSD to some standard C library functions #354

markand opened this issue Mar 30, 2023 · 10 comments

Comments

@markand
Copy link
Contributor

markand commented Mar 30, 2023

Building latest git throws some undefined reference to some C functions from standard library.

[  4%] Linking C shared library libSDL3_image.so
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/SDL3_image.dir/link.txt --verbose=1
/usr/bin/cc -fPIC -Os -DNDEBUG -Wl,--no-undefined -shared -Wl,-soname,libSDL3_image.so.0 -o libSDL3_image.so.0.0.0 CMakeFiles/SDL3_image.dir/IMG.c.o CMakeFiles/SDL3_image.dir/IMG_WIC.c.o CMakeFiles/SDL3_image.dir/IMG_avif.c.o CMakeFiles/SDL3_image.dir/IMG_bmp.c.o CMakeFiles/SDL3_image.dir/IMG_gif.c.o CMakeFiles/SDL3_image.dir/IMG_jpg.c.o CMakeFiles/SDL3_image.dir/IMG_jxl.c.o CMakeFiles/SDL3_image.dir/IMG_lbm.c.o CMakeFiles/SDL3_image.dir/IMG_pcx.c.o CMakeFiles/SDL3_image.dir/IMG_png.c.o CMakeFiles/SDL3_image.dir/IMG_pnm.c.o CMakeFiles/SDL3_image.dir/IMG_qoi.c.o CMakeFiles/SDL3_image.dir/IMG_stb.c.o CMakeFiles/SDL3_image.dir/IMG_svg.c.o CMakeFiles/SDL3_image.dir/IMG_tga.c.o CMakeFiles/SDL3_image.dir/IMG_tif.c.o CMakeFiles/SDL3_image.dir/IMG_webp.c.o CMakeFiles/SDL3_image.dir/IMG_xcf.c.o CMakeFiles/SDL3_image.dir/IMG_xpm.c.o CMakeFiles/SDL3_image.dir/IMG_xv.c.o CMakeFiles/SDL3_image.dir/IMG_xxx.c.o  -Wl,-z,origin,-rpath,/usr/local/lib: /usr/local/lib/libSDL3.so.0.0.0 /usr/local/lib/libjpeg.so.70.0 /usr/local/lib/libpng.so.18.0 /usr/lib/libz.so.7.0 -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib 
ld: error: undefined symbol: setjmp
>>> referenced by IMG_jpg.c
>>>               CMakeFiles/SDL3_image.dir/IMG_jpg.c.o:(IMG_LoadJPG_RW)
>>> referenced by IMG_png.c
>>>               CMakeFiles/SDL3_image.dir/IMG_png.c.o:(IMG_LoadPNG_RW)
>>> referenced by IMG_png.c
>>>               CMakeFiles/SDL3_image.dir/IMG_png.c.o:(IMG_SavePNG_RW_libpng)

ld: error: undefined symbol: longjmp
>>> referenced by IMG_jpg.c
>>>               CMakeFiles/SDL3_image.dir/IMG_jpg.c.o:(my_error_exit)
>>> referenced by IMG_png.c
>>>               CMakeFiles/SDL3_image.dir/IMG_png.c.o:(IMG_LoadPNG_RW)
>>> referenced by IMG_png.c
>>>               CMakeFiles/SDL3_image.dir/IMG_png.c.o:(IMG_SavePNG_RW_libpng)

ld: error: undefined symbol: memset
>>> referenced by IMG_svg.c
>>>               CMakeFiles/SDL3_image.dir/IMG_svg.c.o:(nsvg__initPaint)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error 1 in . (CMakeFiles/SDL3_image.dir/build.make:421 'libSDL3_image.so.0.0.0')
*** Error 2 in . (CMakeFiles/Makefile2:83 'CMakeFiles/SDL3_image.dir/all')
*** Error 2 in /home/markand/SDL_image-main/build (Makefile:136 'all')

I'll check what can cause the issue.

@DebugBSD
Copy link

DebugBSD commented Dec 14, 2024

Did you solve this problem @markand ? I've exactly the same problem with the current verson of SDL3_image.

If you solved it, please, can you explain how did you do it?

I'm using OpenBSD-current.

EDIT: I've solved the linker error removing the argument --no-undefined from the file CMakeFiles/SDL3_image-shared.dir/link.txt. This is the only solution I've found until now. Later I'll do some tests to be sure I'm not messed everything up and everything works fine.

@sezero
Copy link
Contributor

sezero commented Dec 14, 2024

-Wl,--no-undefined shouldn't be used with OpenBSD: See SDL's own cmake'ry where it's done right. This should be fixed possibly in all SDL satellite libraries, and possibly in all active branches.

CC @madebr

@DebugBSD
Copy link

DebugBSD commented Dec 14, 2024

-Wl,--no-undefined shouldn't be used with OpenBSD: See SDL's own cmake'ry where it's done right. This should be fixed possibly in all SDL satellite libraries, and possibly in all active branches.

CC @madebr

Thank you so much! I knew that something was wrong with that argument. But what I didn't know is how to remove it from CMakefiles cause I don't know how to remove it in the cmake config. (I'm a NOOB with everything related to CMake)

@madebr
Copy link
Contributor

madebr commented Dec 14, 2024

Can you try current main?

@sezero
Copy link
Contributor

sezero commented Dec 14, 2024

Yes, c35c94e looks like the right way to go. It should be backported to SDL2 and release-2.?.x branches too. And the other satellite libs probably need the same treatment.

@DebugBSD
Copy link

DebugBSD commented Dec 14, 2024

In SDL_ttf is fixed in the file cmake/PrivateSdlFunctions.cmake:276
In SDL_mixer is fixed too with the same check

Thank you so much all of you for you help!

@madebr
Copy link
Contributor

madebr commented Dec 14, 2024

I backported it to all SDL3/SDL2 and release branches.

@madebr madebr closed this as completed Dec 14, 2024
@sezero
Copy link
Contributor

sezero commented Dec 14, 2024

I backported it to all SDL3/SDL2 and release branches.

Great.

P.S.: SDL_rtf main + SDL2 branches seem to have been missed.

@madebr
Copy link
Contributor

madebr commented Dec 14, 2024

Done. Will SDL_rtf ever get a release?

@slouken
Copy link
Collaborator

slouken commented Dec 14, 2024

Done. Will SDL_rtf ever get a release?

There's no release planned, no.

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

5 participants