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

isnan, isinf missing in uClibc environment #58

Open
wezm opened this issue Aug 27, 2011 · 3 comments
Open

isnan, isinf missing in uClibc environment #58

wezm opened this issue Aug 27, 2011 · 3 comments

Comments

@wezm
Copy link

wezm commented Aug 27, 2011

Building yajl on a uClibc based Alpine Linux machine failed with the error:

Linking C executable json_reformat
../yajl-2.0.3/lib/libyajl_s.a(yajl_gen.c.o): In function `yajl_gen_double':
yajl_gen.c:(.text+0x565): undefined reference to `__isnan'
yajl_gen.c:(.text+0x580): undefined reference to `__isinf'
collect2: ld returned 1 exit status

I fixed the issue by linking the json_reformat target with libm:

diff --git a/reformatter/CMakeLists.txt b/reformatter/CMakeLists.txt
index da4032b..d48e218 100644
--- a/reformatter/CMakeLists.txt
+++ b/reformatter/CMakeLists.txt
@@ -26,7 +26,7 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)

 ADD_EXECUTABLE(json_reformat ${SRCS})

-TARGET_LINK_LIBRARIES(json_reformat yajl_s)
+TARGET_LINK_LIBRARIES(json_reformat yajl_s m)

 # copy the binary into the output directory
 GET_TARGET_PROPERTY(binPath json_reformat LOCATION)
@royger
Copy link

royger commented Dec 15, 2011

Thanks for the patch!

Could this be added to yajl?

@royger
Copy link

royger commented Dec 19, 2011

The correct fix for this is the following, that compiles yajl with -lm when uclibc is detected, instead of having to add it to every program that depends on yajl:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a1134d1..c3a4fad 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -54,6 +54,11 @@ ADD_LIBRARY(yajl_s STATIC ${SRCS} ${HDRS} ${PUB_HDRS})
 
 ADD_LIBRARY(yajl SHARED ${SRCS} ${HDRS} ${PUB_HDRS})
 
+IF(EXISTS "/usr/include/bits/uClibc_config.h")
+   target_link_libraries(yajl m)
+   target_link_libraries(yajl_s m)
+ENDIF(EXISTS "/usr/include/bits/uClibc_config.h")
+
 #### setup shared library version number
 SET_TARGET_PROPERTIES(yajl PROPERTIES
                       DEFINE_SYMBOL YAJL_SHARED

@volyrique
Copy link

Unfortunately, that is not the correct fix because it does not work when cross-compiling. The initial proposal works fine, though.

a17r added a commit to a17r/gentoo that referenced this issue Aug 18, 2018
See also: lloyd/yajl#58

Closes: https://bugs.gentoo.org/512738
Package-Manager: Portage-2.3.47, Repoman-2.3.10
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

3 participants